Skip to main content

This repository includes core interfaces for the Swarmauri framework.

Project description

Swamauri Logo

<a href="https://pypi.org/project/swarmauri-core/">
    <img src="https://img.shields.io/pypi/dm/swarmauri-core" alt="PyPI - Downloads"/></a>
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/core/README.md">
    <img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/swarmauri/swarmauri-sdk/pkgs/core/README.md&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false" alt="GitHub Hits"/></a>
<a href="https://pypi.org/project/swarmauri-core/">
    <img src="https://img.shields.io/pypi/pyversions/swarmauri-core" alt="PyPI - Python Version"/></a>
<a href="https://pypi.org/project/swarmauri-core/">
    <img src="https://img.shields.io/pypi/l/swarmauri-core" alt="PyPI - License"/></a>
<a href="https://pypi.org/project/swarmauri-core/">
    <img src="https://img.shields.io/pypi/v/swarmauri-core?label=swarmauri-core&color=green" alt="PyPI - swarmauri-core"/></a>


Swarmauri Core

The Core Library provides the foundational interfaces and abstract base classes necessary for developing scalable and flexible machine learning agents, models, and tools. It is designed to offer a standardized approach to implementing various components of machine learning systems, such as models, parsers, conversations, and vector stores.

Features

  • LLMs Interface: Define and interact with predictive models.
class IPredict(ABC):
    """
    Interface focusing on the basic properties and settings essential for defining models.
    """

    @abstractmethod
    def predict(self, *args, **kwargs) -> any:
        """
        Generate predictions based on the input data provided to the model.
        """
        pass

    @abstractmethod
    async def apredict(self, *args, **kwargs) -> any:
        """
        Generate predictions based on the input data provided to the model.
        """
    ...
  • Agents Interface: Build and manage intelligent agents for varied tasks.
class IAgent(ABC):
    @abstractmethod
    def exec(self, input_data: Optional[Any], llm_kwargs: Optional[Dict]) -> Any:
        """
        Executive method that triggers the agent's action based on the input data.
        """
        pass
  • Tools Interface: Develop tools with standardized execution and configuration.
class ITool(ABC):
    @abstractmethod
    def call(self, *args, **kwargs):
        pass

    @abstractmethod
    def __call__(self, *args, **kwargs) -> Dict[str, Any]:
        pass
  • Parsers and Conversations: Handle and parse text data, manage conversations states.
class IParser(ABC):
    """
    Abstract base class for parsers. It defines a public method to parse input data (str or Message) into documents,
    and relies on subclasses to implement the specific parsing logic through protected and private methods.
    """

    @abstractmethod
    def parse(self, data: Union[str, bytes, FilePath]) -> List[IDocument]:
        """
        Public method to parse input data (either a str or a Message) into a list of Document instances.

        This method leverages the abstract _parse_data method which must be
        implemented by subclasses to define specific parsing logic.
        """
        pass
  • Vector Stores: Interface for vector storage and similarity searches.
class IVectorStore(ABC):
    """
    Interface for a vector store responsible for storing, indexing, and retrieving documents.
    """

    @abstractmethod
    def add_document(self, document: IDocument) -> None:
        """
        Stores a single document in the vector store.

        Parameters:
        - document (IDocument): The document to store.
        """
        pass

    @abstractmethod
    def add_documents(self, documents: List[IDocument]) -> None:
        """
        Stores multiple documents in the vector store.

        Parameters:
        - documents (List[IDocument]): The list of documents to store.
        """
        pass

    ...
  • Document Stores: Manage the storage and retrieval of documents.
class IDocumentStore(ABC):
    """
    Interface for a Document Store responsible for storing, indexing, and retrieving documents.
    """

    @abstractmethod
    def add_document(self, document: IDocument) -> None:
        """
        Stores a single document in the document store.

        Parameters:
        - document (IDocument): The document to store.
        """
        pass

    @abstractmethod
    def add_documents(self, documents: List[IDocument]) -> None:
        """
        Stores multiple documents in the document store.

        Parameters:
        - documents (List[IDocument]): The list of documents to store.
        """
        pass

Getting Started

To start developing with the Core Library, include it as a module in your Python project. Ensure you have Python 3.10 or later installed.

Steps to install via pypi

pip install swarmauri_core

Usage Example

# Example of using an abstract model interface from the Core Library
from swarmauri_core.llms.IPredict import IPredict

class MyModel(IPredict):
    # Implement the abstract methods here
    pass

Contributing

Contributions are welcome! If you'd like to add a new feature, fix a bug, or improve documentation, kindly go through the contributions guidelines first.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_core-0.7.2.dev2.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_core-0.7.2.dev2-py3-none-any.whl (62.2 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_core-0.7.2.dev2.tar.gz.

File metadata

  • Download URL: swarmauri_core-0.7.2.dev2.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for swarmauri_core-0.7.2.dev2.tar.gz
Algorithm Hash digest
SHA256 3468941b73775e7354cfa88f65092756b219958cf677c3e83e48f7ba67209a63
MD5 cb24ac26a855b84823bc9c8a7e6ad868
BLAKE2b-256 61af0e83d6c2fe1643c682446a9864ef46812ed3ca2bfef2ed7c812806b42111

See more details on using hashes here.

File details

Details for the file swarmauri_core-0.7.2.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_core-0.7.2.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d87b4a1d1fb7ff4eb9b7147cb2386fec6931a1c020f25616586a1309e9cab93
MD5 1a36e35355c6ad46132243f6af715d6c
BLAKE2b-256 2dfa9fb81e506755c4203fdd232a13a525fa12909a4a84347a0aa33eaa077055

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page