Name | agere JSON |
Version |
0.2.0
JSON |
| download |
home_page | |
Summary | The tool is used for building and driving workflows specifically tailored for AI initiatives. It can be used to construct AI agents. |
upload_time | 2024-01-27 14:25:15 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2023 Xueao Chao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
agents
ai
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
![GitHub License](https://img.shields.io/github/license/happyapplehorse/agere)
![PyPI - Version](https://img.shields.io/pypi/v/agere)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/mkdocs.yml?logo=materialformkdocs&label=docs)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/python-publish.yml?logo=pypi)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/codecov.yml?logo=pytest&label=test)
[![codecov](https://codecov.io/gh/happyapplehorse/agere/graph/badge.svg?token=01PNCN77SX)](https://codecov.io/gh/happyapplehorse/agere)
![Static Badge](https://img.shields.io/badge/dependencies-zero-brightgreen)
# Agere
<p align="center">
<img src="https://github.com/happyapplehorse/happyapplehorse-assets/blob/main/imgs/agere_logo_transparent.png" alt="Logo">
</p >
Agere is a lightweight framework for building and driving AI agents or applications based on task flows.
By defining specific jobs or handlers, Agere can automatically organize and execute complex task flows.
# Installation
Agere has no third-party dependencies.
```shell
pip install agere
```
# How to Use
[Getting started](https://happyapplehorse.github.io/agere/getting_started/)
[Guide](https://happyapplehorse.github.io/agere/guide/framework/)
## Architecture Overview
![agere_architecture](https://raw.githubusercontent.com/happyapplehorse/happyapplehorse-assets/main/agere/agere_architecture.png)
## Basic Concepts
### TaskNode
Includes Commander, Job, and handler. Each TaskNode has one parent and 0-n children.
These nodes form a tree structure, where each node determines its own task completion
based on the status of all its child nodes.
### Commander
Commander is responsible for organizing and scheduling task flows, managing an asynchronous Job queue.
It is the top-level TaskNode.
### Job
Job is a class, it is automatically scheduled by the Commander and managed in an asynchronous queue,
ensuring sequentiality. Each Job has a task method, which wraps the actual task of the Job.
Jobs can submit new Jobs or call handlers. You can think of it as submitting tasks to a superior.
### handler
Handler is a method or function. Called directly by the caller without queue waiting,
but it is still a part of the TaskNode system.
A handler can submit new Jobs or call other handlers.
You can think of it as delegating tasks to subordinates.
### Callback
Callbacks can be added at various stages of a task, such as: task start, task completion,
encountering exceptions, task termination, Commander ending, etc.
## Example
For example, if you want to build an application where multiple AI roles participate in a group chat,
it can be broken down into the following task units. (Assuming we call llm in a streaming manner to get replies.
The reply object mentioned here refers to the iterable object obtained when calling llm,
meaning that the information of an exchange is determined,
but the actual generation and receipt of the information may not have started yet and needs to be completed
in the subsequent iteration.)
- **GroupTalkManager** (Job): This task is the first and the top-level parent node for all subsequent group
chat tasks (except the Commander). All its child nodes can access this node through the node's ancestor_chain
attribute, and it can be used to manage group chats. It stores a list (roles_list) containing all the roles
participating in the group chat, and also needs an attribute (speaking) to indicate which role is currently speaking.
You can also add some methods to it, such as create_role, to add new chat roles, and close_group_talk,
to close the group chat.
- **TalkToAll** (Job): Retrieves the list of roles from GroupTalkManager, sends the message to each role,
collects all the reply objects in a dictionary, then sets the GroupTalkManager's speaking attribute to None,
and passes the reply dictionary to (calls) handle_response.
- **handle_response** (handler): This handler processes each reply in the reply dictionary by calling a
parse_stream_response, where multiple parse_stream_responses start executing concurrently.
- **parse_stream_response** (handler): Responsible for actually collecting and processing reply information.
There are two scenarios:
- The role has nothing to say, no need to process.
- The role has something to say, then checks with GroupTalkManager whether someone is currently speaking.
If someone is speaking, it denies the role's request and informs them who is speaking.
If no one is speaking, it allows the role's request, changes the GroupTalkManager's speaking attribute to that role,
and finally submits the role's reply object as a new TalkToAll Job.
This application uses a preemptive chat method, as opposed to a turn-based multi-round dialogue mechanism,
to mimic real-life multi-person chat scenarios. By breaking down the complex task into two Jobs and two handlers,
the Commander can automatically organize and execute the task. In this way, you only need to focus on what to do next,
without needing to plan globally, effectively reducing the difficulty of building complex processes.
The specific implementation of this process can be referred to in the
example code: [openai_group_talk](examples/openai_group_talk.py).
# License
This project is licensed under the [MIT License](./LICENSE).
**Note:** This library is migrated from the commander in gptui's kernel.
Raw data
{
"_id": null,
"home_page": "",
"name": "agere",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "agents,AI",
"author": "",
"author_email": "Xueao Chao <chaoxueao@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e6/d0/b12f63d0447e737b8bd6b993d93ef0c3ec5984469dfcea7de69bc940bf32/agere-0.2.0.tar.gz",
"platform": null,
"description": "![GitHub License](https://img.shields.io/github/license/happyapplehorse/agere)\n![PyPI - Version](https://img.shields.io/pypi/v/agere)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/mkdocs.yml?logo=materialformkdocs&label=docs)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/python-publish.yml?logo=pypi)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/happyapplehorse/agere/codecov.yml?logo=pytest&label=test)\n[![codecov](https://codecov.io/gh/happyapplehorse/agere/graph/badge.svg?token=01PNCN77SX)](https://codecov.io/gh/happyapplehorse/agere)\n![Static Badge](https://img.shields.io/badge/dependencies-zero-brightgreen)\n\n# Agere\n<p align=\"center\">\n <img src=\"https://github.com/happyapplehorse/happyapplehorse-assets/blob/main/imgs/agere_logo_transparent.png\" alt=\"Logo\">\n</p >\n\nAgere is a lightweight framework for building and driving AI agents or applications based on task flows.\nBy defining specific jobs or handlers, Agere can automatically organize and execute complex task flows.\n\n# Installation\nAgere has no third-party dependencies.\n```shell\npip install agere\n```\n\n# How to Use\n\n[Getting started](https://happyapplehorse.github.io/agere/getting_started/) \n[Guide](https://happyapplehorse.github.io/agere/guide/framework/)\n\n## Architecture Overview\n![agere_architecture](https://raw.githubusercontent.com/happyapplehorse/happyapplehorse-assets/main/agere/agere_architecture.png)\n\n## Basic Concepts\n\n### TaskNode\nIncludes Commander, Job, and handler. Each TaskNode has one parent and 0-n children.\nThese nodes form a tree structure, where each node determines its own task completion\nbased on the status of all its child nodes.\n\n### Commander\nCommander is responsible for organizing and scheduling task flows, managing an asynchronous Job queue.\nIt is the top-level TaskNode.\n\n### Job\nJob is a class, it is automatically scheduled by the Commander and managed in an asynchronous queue,\nensuring sequentiality. Each Job has a task method, which wraps the actual task of the Job.\nJobs can submit new Jobs or call handlers. You can think of it as submitting tasks to a superior.\n\n### handler\nHandler is a method or function. Called directly by the caller without queue waiting,\nbut it is still a part of the TaskNode system.\nA handler can submit new Jobs or call other handlers.\nYou can think of it as delegating tasks to subordinates.\n\n### Callback\nCallbacks can be added at various stages of a task, such as: task start, task completion,\nencountering exceptions, task termination, Commander ending, etc.\n\n\n## Example\n\nFor example, if you want to build an application where multiple AI roles participate in a group chat,\nit can be broken down into the following task units. (Assuming we call llm in a streaming manner to get replies.\nThe reply object mentioned here refers to the iterable object obtained when calling llm,\nmeaning that the information of an exchange is determined,\nbut the actual generation and receipt of the information may not have started yet and needs to be completed\nin the subsequent iteration.)\n\n- **GroupTalkManager** (Job): This task is the first and the top-level parent node for all subsequent group\n chat tasks (except the Commander). All its child nodes can access this node through the node's ancestor_chain\n attribute, and it can be used to manage group chats. It stores a list (roles_list) containing all the roles\n participating in the group chat, and also needs an attribute (speaking) to indicate which role is currently speaking.\n You can also add some methods to it, such as create_role, to add new chat roles, and close_group_talk,\n to close the group chat.\n- **TalkToAll** (Job): Retrieves the list of roles from GroupTalkManager, sends the message to each role,\n collects all the reply objects in a dictionary, then sets the GroupTalkManager's speaking attribute to None,\n and passes the reply dictionary to (calls) handle_response.\n- **handle_response** (handler): This handler processes each reply in the reply dictionary by calling a\n parse_stream_response, where multiple parse_stream_responses start executing concurrently.\n- **parse_stream_response** (handler): Responsible for actually collecting and processing reply information.\n There are two scenarios:\n - The role has nothing to say, no need to process.\n - The role has something to say, then checks with GroupTalkManager whether someone is currently speaking.\n If someone is speaking, it denies the role's request and informs them who is speaking.\n If no one is speaking, it allows the role's request, changes the GroupTalkManager's speaking attribute to that role,\n and finally submits the role's reply object as a new TalkToAll Job.\n\nThis application uses a preemptive chat method, as opposed to a turn-based multi-round dialogue mechanism,\nto mimic real-life multi-person chat scenarios. By breaking down the complex task into two Jobs and two handlers,\nthe Commander can automatically organize and execute the task. In this way, you only need to focus on what to do next,\nwithout needing to plan globally, effectively reducing the difficulty of building complex processes.\nThe specific implementation of this process can be referred to in the\nexample code: [openai_group_talk](examples/openai_group_talk.py).\n\n\n# License\nThis project is licensed under the [MIT License](./LICENSE).\n\n**Note:** This library is migrated from the commander in gptui's kernel.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Xueao Chao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "The tool is used for building and driving workflows specifically tailored for AI initiatives. It can be used to construct AI agents.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/happyapplehorse/agere",
"Issues": "https://github.com/happyapplehorse/agere/issues"
},
"split_keywords": [
"agents",
"ai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "12ea2a089c01090b374db17416e888b97caa583ac3738d9466c42d3b8c65dbc6",
"md5": "d326751fd4965f9f630fad5639b40234",
"sha256": "95b320b448f29ae3ac0a0cbbf8e3a3b1b163718cd254fd78b042da32372e3741"
},
"downloads": -1,
"filename": "agere-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d326751fd4965f9f630fad5639b40234",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 19686,
"upload_time": "2024-01-27T14:25:14",
"upload_time_iso_8601": "2024-01-27T14:25:14.033927Z",
"url": "https://files.pythonhosted.org/packages/12/ea/2a089c01090b374db17416e888b97caa583ac3738d9466c42d3b8c65dbc6/agere-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e6d0b12f63d0447e737b8bd6b993d93ef0c3ec5984469dfcea7de69bc940bf32",
"md5": "7f192fc235dff525c7b6b9d4eeac2247",
"sha256": "bd992adf1b398833c8f11404ea7314552ad2a7483266bc4c6f4857a24a3d3e4e"
},
"downloads": -1,
"filename": "agere-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "7f192fc235dff525c7b6b9d4eeac2247",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 20633,
"upload_time": "2024-01-27T14:25:15",
"upload_time_iso_8601": "2024-01-27T14:25:15.626996Z",
"url": "https://files.pythonhosted.org/packages/e6/d0/b12f63d0447e737b8bd6b993d93ef0c3ec5984469dfcea7de69bc940bf32/agere-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-27 14:25:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "happyapplehorse",
"github_project": "agere",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "agere"
}