[**🇨🇳中文**](https://github.com/shibing624/actionflow/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/actionflow/blob/main/README_EN.md)
<div align="center">
<a href="https://github.com/shibing624/actionflow">
<img src="https://raw.githubusercontent.com/shibing624/actionflow/main/docs/logo.png" height="150" alt="Logo">
</a>
</div>
-----------------
# Actionflow: Agent Workflows with Prompts and Tools
[![PyPI version](https://badge.fury.io/py/actionflow.svg)](https://badge.fury.io/py/actionflow)
[![Downloads](https://static.pepy.tech/badge/actionflow)](https://pepy.tech/project/actionflow)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)
[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
[![python_version](https://img.shields.io/badge/Python-3.5%2B-green.svg)](requirements.txt)
[![GitHub issues](https://img.shields.io/github/issues/shibing624/actionflow.svg)](https://github.com/shibing624/actionflow/issues)
[![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)
**actionflow**: A Human-Centric Framework for Large Language Model Agent Workflows, build your agent workflows quickly
**actionflow**: 快速构建你自己的Agent工作流
## Overview
![llm_agnet](https://github.com/shibing624/actionflow/blob/main/docs/llm_agent.png)
- **规划(Planning)**:任务拆解、生成计划、反思
- **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
- **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
![actionflow_arch](https://github.com/shibing624/actionflow/blob/main/docs/actionflow_arch.png)
- **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
- **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
- **Solver**:求解器将所有这些输出整合为最终答案
## Features
`Actionflow`是一个Agent工作流构建工具,功能:
- 简单代码快速编排复杂工作流
- 工作流的编排不仅支持prompt命令,还支持工具调用(tool_calls)
- 支持OpenAI API和Moonshot API(kimi)调用
## Installation
```bash
pip install -U actionflow
```
or
```bash
git clone https://github.com/shibing624/actionflow.git
cd actionflow
pip install .
```
## Getting Started
1. 复制[example.env](https://github.com/shibing624/actionflow/blob/main/example.env)文件为`.env`,并粘贴OpenAI API key或者Moonshoot API key。
2. 运行Agent示例,自动调用google搜索工具:
```python
from actionflow import Assistant, OpenAILLM, AzureOpenAILLM
from actionflow.tools.search_serper import SearchSerperTool
m = Assistant(
llm=AzureOpenAILLM(),
description="You are a helpful ai assistant.",
show_tool_calls=True,
# Enable the assistant to search the knowledge base
search_knowledge=False,
tools=[SearchSerperTool()],
# Enable the assistant to read the chat history
read_chat_history=True,
debug_mode=True,
)
print("LLM:", m.llm)
print(m.run("介绍林黛玉", stream=False))
print(m.run("北京最近的新闻", stream=False))
print(m.run("我前面问了啥", stream=False))
```
## Examples
运行工作流(Workflow)示例:
- [examples/rag_assistant_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/rag_assistant_demo.py) 实现了RAG功能,基于PDF文档回答问题
- [examples/python_assistant_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/python_assistant_demo.py) 实现了Code Interpreter功能,自动生成python代码,并执行
- [examples/research_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/research_demo.py) 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告
- [examples/run_flow_news_article_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/run_flow_news_article_demo.py) 实现了写新闻稿的工作流,multi-agent的实现,定义了多个Assistant和Task,多次调用搜索工具,并生成高级排版的新闻文章
- [examples/run_flow_investment_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/run_flow_investment_demo.py) 实现了投资研究的工作流,依次执行股票信息收集、股票分析、撰写分析报告,复查报告等多个Task
## Contact
- Issue(建议)
:[![GitHub issues](https://img.shields.io/github/issues/shibing624/actionflow.svg)](https://github.com/shibing624/actionflow/issues)
- 邮件我:xuming: xuming624@qq.com
- 微信我: 加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
<img src="https://github.com/shibing624/actionflow/blob/main/docs/wechat.jpeg" width="200" />
## Citation
如果你在研究中使用了`actionflow`,请按如下格式引用:
APA:
```
Xu, M. actionflow: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/actionflow
```
BibTeX:
```
@misc{Xu_actionflow,
title={actionflow: A Human-Centric Framework for Large Language Model Agent Workflows},
author={Xu Ming},
year={2024},
howpublished={\url{https://github.com/shibing624/actionflow}},
}
```
## License
授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`actionflow`的链接和授权协议。
## Contribute
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
- 在`tests`添加相应的单元测试
- 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
之后即可提交PR。
## Acknowledgements
- [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
- [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
- [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)
Thanks for their great work!
Raw data
{
"_id": null,
"home_page": "https://github.com/shibing624/actionflow",
"name": "actionflow",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8.0",
"maintainer_email": null,
"keywords": "actionflow, Agent Tool, action, agent",
"author": "XuMing",
"author_email": "xuming624@qq.com",
"download_url": "https://files.pythonhosted.org/packages/b1/85/d5ac7ca1a30a61a7912c06cd554ce3b03ca392347b7c3dec39a03df8fc00/actionflow-0.0.5.tar.gz",
"platform": null,
"description": "[**\ud83c\udde8\ud83c\uddf3\u4e2d\u6587**](https://github.com/shibing624/actionflow/blob/main/README.md) | [**\ud83c\udf10English**](https://github.com/shibing624/actionflow/blob/main/README_EN.md)\n\n<div align=\"center\">\n <a href=\"https://github.com/shibing624/actionflow\">\n <img src=\"https://raw.githubusercontent.com/shibing624/actionflow/main/docs/logo.png\" height=\"150\" alt=\"Logo\">\n </a>\n</div>\n\n-----------------\n\n# Actionflow: Agent Workflows with Prompts and Tools\n[![PyPI version](https://badge.fury.io/py/actionflow.svg)](https://badge.fury.io/py/actionflow)\n[![Downloads](https://static.pepy.tech/badge/actionflow)](https://pepy.tech/project/actionflow)\n[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)\n[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![python_version](https://img.shields.io/badge/Python-3.5%2B-green.svg)](requirements.txt)\n[![GitHub issues](https://img.shields.io/github/issues/shibing624/actionflow.svg)](https://github.com/shibing624/actionflow/issues)\n[![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)\n\n\n**actionflow**: A Human-Centric Framework for Large Language Model Agent Workflows, build your agent workflows quickly\n\n**actionflow**: \u5feb\u901f\u6784\u5efa\u4f60\u81ea\u5df1\u7684Agent\u5de5\u4f5c\u6d41\n\n## Overview\n![llm_agnet](https://github.com/shibing624/actionflow/blob/main/docs/llm_agent.png)\n\n- **\u89c4\u5212\uff08Planning\uff09**\uff1a\u4efb\u52a1\u62c6\u89e3\u3001\u751f\u6210\u8ba1\u5212\u3001\u53cd\u601d\n- **\u8bb0\u5fc6\uff08Memory\uff09**\uff1a\u77ed\u671f\u8bb0\u5fc6\uff08prompt\u5b9e\u73b0\uff09\u3001\u957f\u671f\u8bb0\u5fc6\uff08RAG\u5b9e\u73b0\uff09\n- **\u5de5\u5177\u4f7f\u7528\uff08Tool use\uff09**\uff1afunction call\u80fd\u529b\uff0c\u8c03\u7528\u5916\u90e8API\uff0c\u4ee5\u83b7\u53d6\u5916\u90e8\u4fe1\u606f\uff0c\u5305\u62ec\u5f53\u524d\u65e5\u671f\u3001\u65e5\u5386\u3001\u4ee3\u7801\u6267\u884c\u80fd\u529b\u3001\u5bf9\u4e13\u7528\u4fe1\u606f\u6e90\u7684\u8bbf\u95ee\u7b49\n\n\n![actionflow_arch](https://github.com/shibing624/actionflow/blob/main/docs/actionflow_arch.png)\n\n- **Planner**\uff1a\u8d1f\u8d23\u8ba9LLM\u751f\u6210\u4e00\u4e2a\u591a\u6b65\u8ba1\u5212\u6765\u5b8c\u6210\u590d\u6742\u4efb\u52a1\uff0c\u751f\u6210\u76f8\u4e92\u4f9d\u8d56\u7684\u201c\u94fe\u5f0f\u8ba1\u5212\u201d\uff0c\u5b9a\u4e49\u6bcf\u4e00\u6b65\u6240\u4f9d\u8d56\u7684\u4e0a\u4e00\u6b65\u7684\u8f93\u51fa\n- **Worker**\uff1a\u63a5\u53d7\u201c\u94fe\u5f0f\u8ba1\u5212\u201d\uff0c\u5faa\u73af\u904d\u5386\u8ba1\u5212\u4e2d\u7684\u6bcf\u4e2a\u5b50\u4efb\u52a1\uff0c\u5e76\u8c03\u7528\u5de5\u5177\u5b8c\u6210\u4efb\u52a1\uff0c\u53ef\u4ee5\u81ea\u52a8\u53cd\u601d\u7ea0\u9519\u4ee5\u5b8c\u6210\u4efb\u52a1\n- **Solver**\uff1a\u6c42\u89e3\u5668\u5c06\u6240\u6709\u8fd9\u4e9b\u8f93\u51fa\u6574\u5408\u4e3a\u6700\u7ec8\u7b54\u6848\n\n## Features\n`Actionflow`\u662f\u4e00\u4e2aAgent\u5de5\u4f5c\u6d41\u6784\u5efa\u5de5\u5177\uff0c\u529f\u80fd\uff1a\n\n- \u7b80\u5355\u4ee3\u7801\u5feb\u901f\u7f16\u6392\u590d\u6742\u5de5\u4f5c\u6d41\n- \u5de5\u4f5c\u6d41\u7684\u7f16\u6392\u4e0d\u4ec5\u652f\u6301prompt\u547d\u4ee4\uff0c\u8fd8\u652f\u6301\u5de5\u5177\u8c03\u7528\uff08tool_calls\uff09\n- \u652f\u6301OpenAI API\u548cMoonshot API(kimi)\u8c03\u7528\n\n## Installation\n\n```bash\npip install -U actionflow\n```\n\nor\n\n```bash\ngit clone https://github.com/shibing624/actionflow.git\ncd actionflow\npip install .\n```\n\n## Getting Started\n\n1. \u590d\u5236[example.env](https://github.com/shibing624/actionflow/blob/main/example.env)\u6587\u4ef6\u4e3a`.env`\uff0c\u5e76\u7c98\u8d34OpenAI API key\u6216\u8005Moonshoot API key\u3002\n\n2. \u8fd0\u884cAgent\u793a\u4f8b\uff0c\u81ea\u52a8\u8c03\u7528google\u641c\u7d22\u5de5\u5177\uff1a\n\n```python\nfrom actionflow import Assistant, OpenAILLM, AzureOpenAILLM\nfrom actionflow.tools.search_serper import SearchSerperTool\n\nm = Assistant(\n llm=AzureOpenAILLM(),\n description=\"You are a helpful ai assistant.\",\n show_tool_calls=True,\n # Enable the assistant to search the knowledge base\n search_knowledge=False,\n tools=[SearchSerperTool()],\n # Enable the assistant to read the chat history\n read_chat_history=True,\n debug_mode=True,\n)\nprint(\"LLM:\", m.llm)\nprint(m.run(\"\u4ecb\u7ecd\u6797\u9edb\u7389\", stream=False))\nprint(m.run(\"\u5317\u4eac\u6700\u8fd1\u7684\u65b0\u95fb\", stream=False))\nprint(m.run(\"\u6211\u524d\u9762\u95ee\u4e86\u5565\", stream=False))\n```\n\n## Examples\n\u8fd0\u884c\u5de5\u4f5c\u6d41\uff08Workflow\uff09\u793a\u4f8b\uff1a\n\n- [examples/rag_assistant_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/rag_assistant_demo.py) \u5b9e\u73b0\u4e86RAG\u529f\u80fd\uff0c\u57fa\u4e8ePDF\u6587\u6863\u56de\u7b54\u95ee\u9898\n- [examples/python_assistant_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/python_assistant_demo.py) \u5b9e\u73b0\u4e86Code Interpreter\u529f\u80fd\uff0c\u81ea\u52a8\u751f\u6210python\u4ee3\u7801\uff0c\u5e76\u6267\u884c\n- [examples/research_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/research_demo.py) \u5b9e\u73b0\u4e86Research\u529f\u80fd\uff0c\u81ea\u52a8\u8c03\u7528\u641c\u7d22\u5de5\u5177\uff0c\u6c47\u603b\u4fe1\u606f\u540e\u64b0\u5199\u79d1\u6280\u62a5\u544a\n- [examples/run_flow_news_article_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/run_flow_news_article_demo.py) \u5b9e\u73b0\u4e86\u5199\u65b0\u95fb\u7a3f\u7684\u5de5\u4f5c\u6d41\uff0cmulti-agent\u7684\u5b9e\u73b0\uff0c\u5b9a\u4e49\u4e86\u591a\u4e2aAssistant\u548cTask\uff0c\u591a\u6b21\u8c03\u7528\u641c\u7d22\u5de5\u5177\uff0c\u5e76\u751f\u6210\u9ad8\u7ea7\u6392\u7248\u7684\u65b0\u95fb\u6587\u7ae0\n- [examples/run_flow_investment_demo.py](https://github.com/shibing624/actionflow/blob/main/examples/run_flow_investment_demo.py) \u5b9e\u73b0\u4e86\u6295\u8d44\u7814\u7a76\u7684\u5de5\u4f5c\u6d41\uff0c\u4f9d\u6b21\u6267\u884c\u80a1\u7968\u4fe1\u606f\u6536\u96c6\u3001\u80a1\u7968\u5206\u6790\u3001\u64b0\u5199\u5206\u6790\u62a5\u544a\uff0c\u590d\u67e5\u62a5\u544a\u7b49\u591a\u4e2aTask\n\n## Contact\n\n- Issue(\u5efa\u8bae)\n \uff1a[![GitHub issues](https://img.shields.io/github/issues/shibing624/actionflow.svg)](https://github.com/shibing624/actionflow/issues)\n- \u90ae\u4ef6\u6211\uff1axuming: xuming624@qq.com\n- \u5fae\u4fe1\u6211\uff1a \u52a0\u6211*\u5fae\u4fe1\u53f7\uff1axuming624, \u5907\u6ce8\uff1a\u59d3\u540d-\u516c\u53f8-NLP* \u8fdbNLP\u4ea4\u6d41\u7fa4\u3002\n\n<img src=\"https://github.com/shibing624/actionflow/blob/main/docs/wechat.jpeg\" width=\"200\" />\n\n## Citation\n\n\u5982\u679c\u4f60\u5728\u7814\u7a76\u4e2d\u4f7f\u7528\u4e86`actionflow`\uff0c\u8bf7\u6309\u5982\u4e0b\u683c\u5f0f\u5f15\u7528\uff1a\n\nAPA:\n\n```\nXu, M. actionflow: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/actionflow\n```\n\nBibTeX:\n\n```\n@misc{Xu_actionflow,\n title={actionflow: A Human-Centric Framework for Large Language Model Agent Workflows},\n author={Xu Ming},\n year={2024},\n howpublished={\\url{https://github.com/shibing624/actionflow}},\n}\n```\n\n## License\n\n\u6388\u6743\u534f\u8bae\u4e3a [The Apache License 2.0](/LICENSE)\uff0c\u53ef\u514d\u8d39\u7528\u505a\u5546\u4e1a\u7528\u9014\u3002\u8bf7\u5728\u4ea7\u54c1\u8bf4\u660e\u4e2d\u9644\u52a0`actionflow`\u7684\u94fe\u63a5\u548c\u6388\u6743\u534f\u8bae\u3002\n## Contribute\n\n\u9879\u76ee\u4ee3\u7801\u8fd8\u5f88\u7c97\u7cd9\uff0c\u5982\u679c\u5927\u5bb6\u5bf9\u4ee3\u7801\u6709\u6240\u6539\u8fdb\uff0c\u6b22\u8fce\u63d0\u4ea4\u56de\u672c\u9879\u76ee\uff0c\u5728\u63d0\u4ea4\u4e4b\u524d\uff0c\u6ce8\u610f\u4ee5\u4e0b\u4e24\u70b9\uff1a\n\n- \u5728`tests`\u6dfb\u52a0\u76f8\u5e94\u7684\u5355\u5143\u6d4b\u8bd5\n- \u4f7f\u7528`python -m pytest`\u6765\u8fd0\u884c\u6240\u6709\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u6240\u6709\u5355\u6d4b\u90fd\u662f\u901a\u8fc7\u7684\n\n\u4e4b\u540e\u5373\u53ef\u63d0\u4ea4PR\u3002\n\n## Acknowledgements \n\n- [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)\n- [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)\n- [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)\n\n\nThanks for their great work!\n\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "LLM agent workflows",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/shibing624/actionflow"
},
"split_keywords": [
"actionflow",
" agent tool",
" action",
" agent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b185d5ac7ca1a30a61a7912c06cd554ce3b03ca392347b7c3dec39a03df8fc00",
"md5": "a845e9092aab9e6aa67ea39ba5143036",
"sha256": "9bf42f8af7cfe6950458c306dc8754f611d3cd9f8375dcefb5fa6a7015b0ee29"
},
"downloads": -1,
"filename": "actionflow-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "a845e9092aab9e6aa67ea39ba5143036",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.0",
"size": 92879,
"upload_time": "2024-06-28T15:24:42",
"upload_time_iso_8601": "2024-06-28T15:24:42.346492Z",
"url": "https://files.pythonhosted.org/packages/b1/85/d5ac7ca1a30a61a7912c06cd554ce3b03ca392347b7c3dec39a03df8fc00/actionflow-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-28 15:24:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shibing624",
"github_project": "actionflow",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "actionflow"
}