panel-of-agents


Namepanel-of-agents JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA framework for orchestrating multiple AI agents in collaborative discussions and tasks
upload_time2025-02-04 02:58:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords agents ai automation llms
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PanelOfAgents

A flexible and powerful framework for orchestrating multiple AI agents in domain-specific applications, with support for any LLM backend.

## Introduction

This framework enables seamless orchestration of multiple AI agents for domain-specific applications. Inspired by OpenAI's swarm framework but addressing its limitations, our solution offers greater flexibility in agent interactions without being tied to specific LLM implementations.

### Purpose

- Create a simple yet powerful multi-agent orchestration framework
- Enable flexible task handoffs between agents in single-domain applications
- Provide a production-ready alternative to experimental frameworks
- Support integration with various LLM implementations

### Why This Framework?

Unlike OpenAI's swarm framework, which is limited to GPT models and requires predefined handoffs, this framework offers:
- Model-agnostic implementation
- Dynamic agent interactions
- Production-ready architecture
- Flexible integration options

## Features

- **🚀 Flexible Multi-agent Orchestration** - Dynamic task distribution and collaboration between agents
- **⚡️ Real-time Communication** - Token-by-token streaming with minimal latency
- **🔄 Rich Context Sharing** - Comprehensive context including conversation history, action results, and artifacts
- **🔌 Universal LLM Support** - Compatible with any LangChain BaseChatModel implementation
- **🎯 Targeted Agent Usage** - Smart agent selection based on capabilities rather than predefined rules
- **⚙️ Developer-First Design** - Flexible state management and easy service integration

## Installation

```bash
pip install panel-of-agents
```

## Usage

### Context

The `Context` object is the central object in the framework. It contains the state of the conversation, the artifacts, and any custom properties. It is shared between all agents.

The `Context` can be initialized with the following parameters:
- `current_question`: The current question to be answered.
- `conversation_history`: A list of messages between the user and the agents. This is a list of `HumanMessage` and `AIMessage` objects from LangChain.
- `artifacts`: A dictionary of artifacts. The key is the index of the conversation turn and the value is an `Artifact` object.
- `target_agent` (optional): The agent that will respond to the user.
- `custom_props` (optional): A dictionary of custom properties. The key is the name of the property and the value is a list of `CustomProp` objects.

#### Initializing an empty context

```python
from panel_of_agents.context import Context

context = Context("Hi", [], {})
```

#### Initializing a context with a conversation history

```python
from langchain_core.messages import HumanMessage, AIMessage

context = Context("Hi", [HumanMessage("Hi"), AIMessage("Hi, how can I help you today?")], {})
```

### Decorators

`panel_of_agents` uses decorators to indicate the actions/tools that an agent can use.

#### `capability`

The `capability` decorator is used to indicate that a function is a capability.

```python
from panel_of_agents.decorators import capability

class SomeAgent(Agent):
    ...

    @capability
    def my_capability(self, context: Context) -> CapabilityResult:
        return CapabilityResult(result="My capability was successful", artifact=None)
```

Capabilities which are the actions that an agent can perform must return a `CapabilityResult` object.

The `CapabilityResult` object contains the following parameters:
- `result`: The result of the capability. The output of the function.
- `artifact`: An optional artifact.

#### Artifacts

Artifacts are outputs of capabilities that may be stored and persisted across multiple conversation turns.

```python
from panel_of_agents.types.context import Artifact

artifact = Artifact(author="SomeAgent", data={"some_data": "some_data"}, artifact_type=ArtifactType.INTERNAL)
```

The `artifact_type` can be either `INTERNAL` or `USER`.

- `INTERNAL`: The artifact is internal to the framework and is not visible to the user.
- `USER`: The artifact is visible to the user and can be used by other capabilities.

Capabilities which create artifacts must be decorated with the `creates_artifact` decorator.

```python
from panel_of_agents.decorators import capability, creates_artifact

class SomeAgent(Agent):
    ...

    @creates_artifact("A list of users")
    @capability
    def my_capability(self, context: Context) -> CapabilityResult:
        artifact = Artifact(author=self.name, data={"some_data": "some_data"}, artifact_type=ArtifactType.INTERNAL)
        return CapabilityResult(result="My capability was successful", artifact=artifact)
```

### Agents

An agent is a self-contained entity that can perform various related actions. In `panel_of_agents`, custom agents can be created by extending the `Agent` class.

An agent requires the following parameters:
- `name`: The name of the agent.
- `personal_biography`: A short biography of the agent.
- `public_biography`: A short biography of the agent that is visible to other agents.
- `model`: The model to use for the agent.
- `max_tries` (optional): The maximum number of tries for an agent to perform an action. Defaults to 3.

#### Creating an agent

```python

class AdditionAgent(Agent):
    def __init__(self, model: BaseChatModel, max_tries: int = 3):
        personal_biography = "You are an agent that performs addition on two numbers."
        public_biography = "An agent that performs addition on two numbers."

        super().__init__(
            name="Addition Agent",
            personal_biograhpy=personal_biography,
            public_biograhpy=public_biography,
            model=model,
            max_tries=max_tries
        )

    @agent_capability
    def add(self, a: float, b: float) -> CapabilityResult:
        result = a + b
        return CapabilityResult(result=result, artifact=None)


addition_agent = AdditionAgent(model, max_tries=5)
```

### Moderator

The `Moderator` is responsible for orchestrating the conversation between the agents. It is responsible for selecting the initial agent (when `target_agent` is not set), and for controlling the number of times agents execute to answer a given question.

#### Creating a moderator

The `Moderator` requires the following parameters:
- `panel_of_agents`: A list of agents to be used in the conversation. These are instances of the subclassed `Agent` class.
- `leader`: The agent that will respond to the user.
- `moderator_cast_vote`: Whether the moderator will cast a vote on whether an agent is capable of answering a given question. If not set, each agent will vote on whether they are capable of answering the question.

```python
from panel_of_agents.moderator import Moderator

moderator = Moderator(
    panel_of_agents=[AdditionAgent(), SubtractionAgent()],
    leader="Addition Agent",
    moderator_cast_vote=True
)
```

### Transmitter

The `Transmitter` is responsible for transmitting the conversation between the agents. It is responsible for formatting the conversation for the user and for streaming the conversation to the user.

#### Creating a transmitter

```python
from panel_of_agents.transmitter import Transmitter

transmitter = Transmitter(moderator)
```

#### Invoking the transmitter

##### Streaming
```python

for token in transmitter.invoke_moderator(context, stream=True):
    print(token, end="", flush=True)
```

##### Non-streaming

```python
response = transmitter.invoke_moderator(context, stream=False)
```

#### Raw Feed

The `panel_of_agents` framework utilizes a custom communication protocol, for consistent performance, output containing the raw response should be used as the conversation history.

The `raw_feed` can be accessed from the `transmitter` object after an invocation is complete.

```python
response = transmitter.invoke_moderator(context, stream=False)

conversation_history.append(AIMessage(content=transmitter.raw_feed))
```




            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "panel-of-agents",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Mohammed Ali <splitwireml@gmail.com>",
    "keywords": "agents, ai, automation, llms",
    "author": null,
    "author_email": "Mohammed Ali <splitwireml@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f6/da/9421b57513c0211d4818270015e6d1dd890c5467c9c051dd0ae8a60e9766/panel_of_agents-0.1.0.tar.gz",
    "platform": null,
    "description": "# PanelOfAgents\n\nA flexible and powerful framework for orchestrating multiple AI agents in domain-specific applications, with support for any LLM backend.\n\n## Introduction\n\nThis framework enables seamless orchestration of multiple AI agents for domain-specific applications. Inspired by OpenAI's swarm framework but addressing its limitations, our solution offers greater flexibility in agent interactions without being tied to specific LLM implementations.\n\n### Purpose\n\n- Create a simple yet powerful multi-agent orchestration framework\n- Enable flexible task handoffs between agents in single-domain applications\n- Provide a production-ready alternative to experimental frameworks\n- Support integration with various LLM implementations\n\n### Why This Framework?\n\nUnlike OpenAI's swarm framework, which is limited to GPT models and requires predefined handoffs, this framework offers:\n- Model-agnostic implementation\n- Dynamic agent interactions\n- Production-ready architecture\n- Flexible integration options\n\n## Features\n\n- **\ud83d\ude80 Flexible Multi-agent Orchestration** - Dynamic task distribution and collaboration between agents\n- **\u26a1\ufe0f Real-time Communication** - Token-by-token streaming with minimal latency\n- **\ud83d\udd04 Rich Context Sharing** - Comprehensive context including conversation history, action results, and artifacts\n- **\ud83d\udd0c Universal LLM Support** - Compatible with any LangChain BaseChatModel implementation\n- **\ud83c\udfaf Targeted Agent Usage** - Smart agent selection based on capabilities rather than predefined rules\n- **\u2699\ufe0f Developer-First Design** - Flexible state management and easy service integration\n\n## Installation\n\n```bash\npip install panel-of-agents\n```\n\n## Usage\n\n### Context\n\nThe `Context` object is the central object in the framework. It contains the state of the conversation, the artifacts, and any custom properties. It is shared between all agents.\n\nThe `Context` can be initialized with the following parameters:\n- `current_question`: The current question to be answered.\n- `conversation_history`: A list of messages between the user and the agents. This is a list of `HumanMessage` and `AIMessage` objects from LangChain.\n- `artifacts`: A dictionary of artifacts. The key is the index of the conversation turn and the value is an `Artifact` object.\n- `target_agent` (optional): The agent that will respond to the user.\n- `custom_props` (optional): A dictionary of custom properties. The key is the name of the property and the value is a list of `CustomProp` objects.\n\n#### Initializing an empty context\n\n```python\nfrom panel_of_agents.context import Context\n\ncontext = Context(\"Hi\", [], {})\n```\n\n#### Initializing a context with a conversation history\n\n```python\nfrom langchain_core.messages import HumanMessage, AIMessage\n\ncontext = Context(\"Hi\", [HumanMessage(\"Hi\"), AIMessage(\"Hi, how can I help you today?\")], {})\n```\n\n### Decorators\n\n`panel_of_agents` uses decorators to indicate the actions/tools that an agent can use.\n\n#### `capability`\n\nThe `capability` decorator is used to indicate that a function is a capability.\n\n```python\nfrom panel_of_agents.decorators import capability\n\nclass SomeAgent(Agent):\n    ...\n\n    @capability\n    def my_capability(self, context: Context) -> CapabilityResult:\n        return CapabilityResult(result=\"My capability was successful\", artifact=None)\n```\n\nCapabilities which are the actions that an agent can perform must return a `CapabilityResult` object.\n\nThe `CapabilityResult` object contains the following parameters:\n- `result`: The result of the capability. The output of the function.\n- `artifact`: An optional artifact.\n\n#### Artifacts\n\nArtifacts are outputs of capabilities that may be stored and persisted across multiple conversation turns.\n\n```python\nfrom panel_of_agents.types.context import Artifact\n\nartifact = Artifact(author=\"SomeAgent\", data={\"some_data\": \"some_data\"}, artifact_type=ArtifactType.INTERNAL)\n```\n\nThe `artifact_type` can be either `INTERNAL` or `USER`.\n\n- `INTERNAL`: The artifact is internal to the framework and is not visible to the user.\n- `USER`: The artifact is visible to the user and can be used by other capabilities.\n\nCapabilities which create artifacts must be decorated with the `creates_artifact` decorator.\n\n```python\nfrom panel_of_agents.decorators import capability, creates_artifact\n\nclass SomeAgent(Agent):\n    ...\n\n    @creates_artifact(\"A list of users\")\n    @capability\n    def my_capability(self, context: Context) -> CapabilityResult:\n        artifact = Artifact(author=self.name, data={\"some_data\": \"some_data\"}, artifact_type=ArtifactType.INTERNAL)\n        return CapabilityResult(result=\"My capability was successful\", artifact=artifact)\n```\n\n### Agents\n\nAn agent is a self-contained entity that can perform various related actions. In `panel_of_agents`, custom agents can be created by extending the `Agent` class.\n\nAn agent requires the following parameters:\n- `name`: The name of the agent.\n- `personal_biography`: A short biography of the agent.\n- `public_biography`: A short biography of the agent that is visible to other agents.\n- `model`: The model to use for the agent.\n- `max_tries` (optional): The maximum number of tries for an agent to perform an action. Defaults to 3.\n\n#### Creating an agent\n\n```python\n\nclass AdditionAgent(Agent):\n    def __init__(self, model: BaseChatModel, max_tries: int = 3):\n        personal_biography = \"You are an agent that performs addition on two numbers.\"\n        public_biography = \"An agent that performs addition on two numbers.\"\n\n        super().__init__(\n            name=\"Addition Agent\",\n            personal_biograhpy=personal_biography,\n            public_biograhpy=public_biography,\n            model=model,\n            max_tries=max_tries\n        )\n\n    @agent_capability\n    def add(self, a: float, b: float) -> CapabilityResult:\n        result = a + b\n        return CapabilityResult(result=result, artifact=None)\n\n\naddition_agent = AdditionAgent(model, max_tries=5)\n```\n\n### Moderator\n\nThe `Moderator` is responsible for orchestrating the conversation between the agents. It is responsible for selecting the initial agent (when `target_agent` is not set), and for controlling the number of times agents execute to answer a given question.\n\n#### Creating a moderator\n\nThe `Moderator` requires the following parameters:\n- `panel_of_agents`: A list of agents to be used in the conversation. These are instances of the subclassed `Agent` class.\n- `leader`: The agent that will respond to the user.\n- `moderator_cast_vote`: Whether the moderator will cast a vote on whether an agent is capable of answering a given question. If not set, each agent will vote on whether they are capable of answering the question.\n\n```python\nfrom panel_of_agents.moderator import Moderator\n\nmoderator = Moderator(\n    panel_of_agents=[AdditionAgent(), SubtractionAgent()],\n    leader=\"Addition Agent\",\n    moderator_cast_vote=True\n)\n```\n\n### Transmitter\n\nThe `Transmitter` is responsible for transmitting the conversation between the agents. It is responsible for formatting the conversation for the user and for streaming the conversation to the user.\n\n#### Creating a transmitter\n\n```python\nfrom panel_of_agents.transmitter import Transmitter\n\ntransmitter = Transmitter(moderator)\n```\n\n#### Invoking the transmitter\n\n##### Streaming\n```python\n\nfor token in transmitter.invoke_moderator(context, stream=True):\n    print(token, end=\"\", flush=True)\n```\n\n##### Non-streaming\n\n```python\nresponse = transmitter.invoke_moderator(context, stream=False)\n```\n\n#### Raw Feed\n\nThe `panel_of_agents` framework utilizes a custom communication protocol, for consistent performance, output containing the raw response should be used as the conversation history.\n\nThe `raw_feed` can be accessed from the `transmitter` object after an invocation is complete.\n\n```python\nresponse = transmitter.invoke_moderator(context, stream=False)\n\nconversation_history.append(AIMessage(content=transmitter.raw_feed))\n```\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A framework for orchestrating multiple AI agents in collaborative discussions and tasks",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/LighthouseAI-saas/PanelOfAgents",
        "Repository": "https://github.com/LighthouseAI-saas/PanelOfAgents"
    },
    "split_keywords": [
        "agents",
        " ai",
        " automation",
        " llms"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f76c81af02df039da350ad91f26f5c9d2fe99add0c086ef73317227457dd02f0",
                "md5": "0bb2377aae25a9bef308e6ba7693c8a1",
                "sha256": "1120f80f6915acbcb5aa0c75a8ef7a34fd15032f9167c739a38767404097b7d3"
            },
            "downloads": -1,
            "filename": "panel_of_agents-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0bb2377aae25a9bef308e6ba7693c8a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 38103,
            "upload_time": "2025-02-04T02:58:02",
            "upload_time_iso_8601": "2025-02-04T02:58:02.124744Z",
            "url": "https://files.pythonhosted.org/packages/f7/6c/81af02df039da350ad91f26f5c9d2fe99add0c086ef73317227457dd02f0/panel_of_agents-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f6da9421b57513c0211d4818270015e6d1dd890c5467c9c051dd0ae8a60e9766",
                "md5": "469f37fbec1273d1406903a56fa9bde0",
                "sha256": "bc293c01fc080ec9ad84719c0b598884c18ac49cca0c846e31c6cddda40e9948"
            },
            "downloads": -1,
            "filename": "panel_of_agents-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "469f37fbec1273d1406903a56fa9bde0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 72659,
            "upload_time": "2025-02-04T02:58:04",
            "upload_time_iso_8601": "2025-02-04T02:58:04.190856Z",
            "url": "https://files.pythonhosted.org/packages/f6/da/9421b57513c0211d4818270015e6d1dd890c5467c9c051dd0ae8a60e9766/panel_of_agents-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-04 02:58:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LighthouseAI-saas",
    "github_project": "PanelOfAgents",
    "github_not_found": true,
    "lcname": "panel-of-agents"
}
        
Elapsed time: 0.35271s