actionflow: A Human-Centric Framework for Large Language Model Agent Workflows
ActionFlow
是一个LLMs驱动的工作流构建工具,支持如下功能:
- 通过自然语言(prompt)在
json
文件中编排复杂工作流 - 工作流的编排不仅支持多个prompt命令,还支持工具调用(tool_calls)
- 基于变量名动态更改prompt输入
- 支持OpenAI API和Moonshot API(kimi)调用
pip install -U actionflow
or
git clone https://github.com/shibing624/actionflow.git
cd actionflow
pip install -e .
-
复制example.env文件为
.env
,并粘贴OpenAI API key或者Moonshoot API key。 -
运行actionflow示例:
cd examples
python run_flow_demo.py --flow_path flows/example.json
python run_flow_demo.py --flow_path flows/example_with_variables.json --variables 'market=college students' 'price_point=$50'
复制 examples/flows/example.json 或者按照如下格式创建一个工作流(json文件):
{
"system_message": "An optional message that guides the model's behavior.",
"tasks": [
{
"action": "Instruct the LLM here!"
},
{
"action": "Actions can have settings, including function calls and temperature, like so:",
"settings": {
"tool_name": "save_file",
"temperature": 0.8
}
},
{
"action": "..."
}
]
}
复制 actionflow/tools/save_file.py 并修改,或者按如下指引新增一个工具(记得替换tool_name
为你的工具名):
- 在actionflow/tools文件夹新增
tool_name.py
- 新建类
ToolName
继承自BaseTool
- 在类中新增
get_definition()
和execute()
方法,具体参考BaseTool
这样,你就可以在工作流中使用新增的tool_name
工具。
- Issue(建议) :
- 邮件我:xuming: [email protected]
- 微信我: 加我微信号:xuming624, 备注:姓名-公司-NLP 进NLP交流群。
如果你在研究中使用了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}},
}
授权协议为 The Apache License 2.0,可免费用做商业用途。请在产品说明中附加actionflow
的链接和授权协议。
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
- 在
tests
添加相应的单元测试 - 使用
python -m pytest
来运行所有单元测试,确保所有单测都是通过的
之后即可提交PR。
Thanks for their great work!