agency


Nameagency JSON
Version 1.6.3 PyPI version JSON
download
home_pageNone
SummaryA fast and minimal framework for building agent-integrated systems
upload_time2024-04-24 20:51:23
maintainerNone
docs_urlNone
authorDaniel Rodriguez
requires_python<4.0,>=3.9
licenseGPL-3.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Summary

Agency is a python library that provides an [Actor
model](https://en.wikipedia.org/wiki/Actor_model) framework for creating
agent-integrated systems.

The library provides an easy to use API that enables you to connect agents with
traditional software systems in a flexible and scalable way, allowing you to
develop any architecture you need.

Agency's goal is to enable developers to create custom agent-based applications
by providing a minimal foundation to both experiment and build upon. So if
you're looking to build a custom agent system of your own, Agency might be for
you.

## Features

### Easy to use API
* Straightforward class/method based agent and action definition
* [Up to date documentation](https://createwith.agency) and [examples](./examples/demo/) for reference

### Performance and Scalability
* Supports multiprocessing and multithreading for concurrency
* AMQP support for networked agent systems

### Observability and Control
* Action and lifecycle callbacks
* Access policies and permission callbacks
* Detailed logging

### Demo application available at [`examples/demo`](./examples/demo/)
* Multiple agent examples for experimentation
  * Two OpenAI agent examples
  * HuggingFace transformers agent example
  * Operating system access
* Includes Gradio UI
* Docker configuration for reference and development


# API Overview

In Agency, all entities are represented as instances of the `Agent` class. This
includes all AI-driven agents, software interfaces, or human users that may
communicate as part of your application.

All agents may expose "actions" that other agents can discover and invoke at run
time. An example of a simple agent could be:

```python
class CalculatorAgent(Agent):
    @action
    def add(a, b):
        return a + b
```

This defines an agent with a single action: `add`. Other agents will be able
to call this method by sending a message to an instance of `CalculatorAgent` and
specifying the `add` action. For example:

```python
other_agent.send({
    'to': 'CalcAgent',
    'action': {
        'name': 'add',
        'args': {
            'a': 1,
            'b': 2,
        }
    },
})
```

Actions may specify an access policy, allowing you to control access for safety.

```python
@action(access_policy=ACCESS_PERMITTED) # This allows the action at any time
def add(a, b):
    ...

@action(access_policy=ACCESS_REQUESTED) # This requires review before the action
def add(a, b):
    ...
```

Agents may also define callbacks for various purposes:

```python
class CalculatorAgent(Agent):
    ...
    def before_action(self, message: dict):
        """Called before an action is attempted"""

    def after_action(self, message: dict, return_value: str, error: str):
        """Called after an action is attempted"""

    def after_add(self):
        """Called after the agent is added to a space and may begin communicating"""

    def before_remove(self):
        """Called before the agent is removed from the space"""
```

A `Space` is how you connect your agents together. An agent cannot communicate
with others until it is added to a common `Space`.

There are two included `Space` implementations to choose from:
* `LocalSpace` - which connects agents within the same application.
* `AMQPSpace` - which connects agents across a network using an AMQP
  server like RabbitMQ.

Finally, here is a simple example of creating a `LocalSpace` and adding two
agents to it.

```python
space = LocalSpace()
space.add(CalculatorAgent, "CalcAgent")
space.add(MyAgent, "MyAgent")
# The agents above can now communicate
```

These are just the basic features that Agency provides. For more information
please see [the help site](https://createwith.agency).


# Install

```sh
pip install agency
```
or
```sh
poetry add agency
```


# The Demo Application

The demo application is maintained as an experimental development environment
and a showcase for library features. It includes multiple agent examples which
may communicate with eachother and supports a "slash" syntax for invoking
actions as an agent yourself.

To run the demo, please follow the directions at
[examples/demo](./examples/demo/).

The following is a screenshot of the Gradio UI that demonstrates the example
`OpenAIFunctionAgent` following orders and interacting with the `Host` agent.

<p align="center">
  <img src="https://i.ibb.co/h29m5S4/Screenshot-2023-07-26-at-4-53-05-PM.png"
      alt="Screenshot-2023-07-26-at-4-53-05-PM" border="0">
</p>



# Contributing

Please do!

If you're considering a contribution, please check out the [contributing
guide](./CONTRIBUTING.md).

# Planned Work

[See the issues page.](https://github.com/operand/agency/issues)

If you have any suggestions or otherwise, feel free to add an issue or open a
[discussion](https://github.com/operand/agency/discussions).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "agency",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Daniel Rodriguez",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/81/6a/e6500c20ac3dcf5bc123b70bfbd7acaf14b1c3f6822849754327f55dbe12/agency-1.6.3.tar.gz",
    "platform": null,
    "description": "# Summary\n\nAgency is a python library that provides an [Actor\nmodel](https://en.wikipedia.org/wiki/Actor_model) framework for creating\nagent-integrated systems.\n\nThe library provides an easy to use API that enables you to connect agents with\ntraditional software systems in a flexible and scalable way, allowing you to\ndevelop any architecture you need.\n\nAgency's goal is to enable developers to create custom agent-based applications\nby providing a minimal foundation to both experiment and build upon. So if\nyou're looking to build a custom agent system of your own, Agency might be for\nyou.\n\n## Features\n\n### Easy to use API\n* Straightforward class/method based agent and action definition\n* [Up to date documentation](https://createwith.agency) and [examples](./examples/demo/) for reference\n\n### Performance and Scalability\n* Supports multiprocessing and multithreading for concurrency\n* AMQP support for networked agent systems\n\n### Observability and Control\n* Action and lifecycle callbacks\n* Access policies and permission callbacks\n* Detailed logging\n\n### Demo application available at [`examples/demo`](./examples/demo/)\n* Multiple agent examples for experimentation\n  * Two OpenAI agent examples\n  * HuggingFace transformers agent example\n  * Operating system access\n* Includes Gradio UI\n* Docker configuration for reference and development\n\n\n# API Overview\n\nIn Agency, all entities are represented as instances of the `Agent` class. This\nincludes all AI-driven agents, software interfaces, or human users that may\ncommunicate as part of your application.\n\nAll agents may expose \"actions\" that other agents can discover and invoke at run\ntime. An example of a simple agent could be:\n\n```python\nclass CalculatorAgent(Agent):\n    @action\n    def add(a, b):\n        return a + b\n```\n\nThis defines an agent with a single action: `add`. Other agents will be able\nto call this method by sending a message to an instance of `CalculatorAgent` and\nspecifying the `add` action. For example:\n\n```python\nother_agent.send({\n    'to': 'CalcAgent',\n    'action': {\n        'name': 'add',\n        'args': {\n            'a': 1,\n            'b': 2,\n        }\n    },\n})\n```\n\nActions may specify an access policy, allowing you to control access for safety.\n\n```python\n@action(access_policy=ACCESS_PERMITTED) # This allows the action at any time\ndef add(a, b):\n    ...\n\n@action(access_policy=ACCESS_REQUESTED) # This requires review before the action\ndef add(a, b):\n    ...\n```\n\nAgents may also define callbacks for various purposes:\n\n```python\nclass CalculatorAgent(Agent):\n    ...\n    def before_action(self, message: dict):\n        \"\"\"Called before an action is attempted\"\"\"\n\n    def after_action(self, message: dict, return_value: str, error: str):\n        \"\"\"Called after an action is attempted\"\"\"\n\n    def after_add(self):\n        \"\"\"Called after the agent is added to a space and may begin communicating\"\"\"\n\n    def before_remove(self):\n        \"\"\"Called before the agent is removed from the space\"\"\"\n```\n\nA `Space` is how you connect your agents together. An agent cannot communicate\nwith others until it is added to a common `Space`.\n\nThere are two included `Space` implementations to choose from:\n* `LocalSpace` - which connects agents within the same application.\n* `AMQPSpace` - which connects agents across a network using an AMQP\n  server like RabbitMQ.\n\nFinally, here is a simple example of creating a `LocalSpace` and adding two\nagents to it.\n\n```python\nspace = LocalSpace()\nspace.add(CalculatorAgent, \"CalcAgent\")\nspace.add(MyAgent, \"MyAgent\")\n# The agents above can now communicate\n```\n\nThese are just the basic features that Agency provides. For more information\nplease see [the help site](https://createwith.agency).\n\n\n# Install\n\n```sh\npip install agency\n```\nor\n```sh\npoetry add agency\n```\n\n\n# The Demo Application\n\nThe demo application is maintained as an experimental development environment\nand a showcase for library features. It includes multiple agent examples which\nmay communicate with eachother and supports a \"slash\" syntax for invoking\nactions as an agent yourself.\n\nTo run the demo, please follow the directions at\n[examples/demo](./examples/demo/).\n\nThe following is a screenshot of the Gradio UI that demonstrates the example\n`OpenAIFunctionAgent` following orders and interacting with the `Host` agent.\n\n<p align=\"center\">\n  <img src=\"https://i.ibb.co/h29m5S4/Screenshot-2023-07-26-at-4-53-05-PM.png\"\n      alt=\"Screenshot-2023-07-26-at-4-53-05-PM\" border=\"0\">\n</p>\n\n\n\n# Contributing\n\nPlease do!\n\nIf you're considering a contribution, please check out the [contributing\nguide](./CONTRIBUTING.md).\n\n# Planned Work\n\n[See the issues page.](https://github.com/operand/agency/issues)\n\nIf you have any suggestions or otherwise, feel free to add an issue or open a\n[discussion](https://github.com/operand/agency/discussions).\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "A fast and minimal framework for building agent-integrated systems",
    "version": "1.6.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "393105c87e235ac902852b4ebda382a09f16ea8384b4bf698c4e6bbd0fbba9bb",
                "md5": "ba35c1beca0feb2f5394f8ab0e656886",
                "sha256": "a9087dc7b6c3c5332303019a6921413c3e1b0fdeec9502777fe845fe7880c26f"
            },
            "downloads": -1,
            "filename": "agency-1.6.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ba35c1beca0feb2f5394f8ab0e656886",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 19260,
            "upload_time": "2024-04-24T20:51:17",
            "upload_time_iso_8601": "2024-04-24T20:51:17.121956Z",
            "url": "https://files.pythonhosted.org/packages/39/31/05c87e235ac902852b4ebda382a09f16ea8384b4bf698c4e6bbd0fbba9bb/agency-1.6.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "816ae6500c20ac3dcf5bc123b70bfbd7acaf14b1c3f6822849754327f55dbe12",
                "md5": "23a6042b2e06444a3e53bc595703e47e",
                "sha256": "c4e8392ee628c628ef05c41e0d579d53778cbc46f8aef8e942407dec4c70dd2c"
            },
            "downloads": -1,
            "filename": "agency-1.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "23a6042b2e06444a3e53bc595703e47e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 17434,
            "upload_time": "2024-04-24T20:51:23",
            "upload_time_iso_8601": "2024-04-24T20:51:23.091710Z",
            "url": "https://files.pythonhosted.org/packages/81/6a/e6500c20ac3dcf5bc123b70bfbd7acaf14b1c3f6822849754327f55dbe12/agency-1.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 20:51:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "agency"
}
        
Elapsed time: 0.26300s