Actionflow: Agent Workflows with Prompts and Tools
actionflow: A Human-Centric Framework for Large Language Model Agent Workflows, build your agent workflows quickly
actionflow: 快速构建你自己的Agent工作流
Overview
- 规划(Planning):任务拆解、生成计划、反思
- 记忆(Memory):短期记忆(prompt实现)、长期记忆(RAG实现)
- 工具使用(Tool use):function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
- Planner:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
- Worker:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
- Solver:求解器将所有这些输出整合为最终答案
Features
Actionflow是一个Agent工作流构建工具,功能:
- 简单代码快速编排复杂工作流
- 工作流的编排不仅支持prompt命令,还支持工具调用(tool_calls)
- 支持OpenAI API和Moonshot API(kimi)调用
Installation
pip install -U actionflow
or
git clone https://github.com/shibing624/actionflow.git
cd actionflow
pip install .
Getting Started
-
复制example.env文件为
.env,并粘贴OpenAI API key或者Moonshoot API key。 -
运行Agent示例,自动调用google搜索工具:
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 实现了RAG功能,基于PDF文档回答问题
- examples/python_assistant_demo.py 实现了Code Interpreter功能,自动生成python代码,并执行
- examples/research_demo.py 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告
- examples/run_flow_news_article_demo.py 实现了写新闻稿的工作流,multi-agent的实现,定义了多个Assistant和Task,多次调用搜索工具,并生成高级排版的新闻文章
- examples/run_flow_investment_demo.py 实现了投资研究的工作流,依次执行股票信息收集、股票分析、撰写分析报告,复查报告等多个Task
Contact
- Issue(建议)
:
- 邮件我:xuming: xuming624@qq.com
- 微信我: 加我微信号:xuming624, 备注:姓名-公司-NLP 进NLP交流群。
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,可免费用做商业用途。请在产品说明中附加actionflow的链接和授权协议。
Contribute
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
- 在
tests添加相应的单元测试 - 使用
python -m pytest来运行所有单元测试,确保所有单测都是通过的
之后即可提交PR。
Acknowledgements
- https://github.com/langchain-ai/langchain
- https://github.com/simonmesmith/agentflow
- https://github.com/phidatahq/phidata
Thanks for their great work!
Metadata
Release files for actionflow 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| actionflow-0.0.5.tar.gz | 92.9 kB | Without provenance | Details for actionflow-0.0.5.tar.gz |
Release files / actionflow-0.0.5.tar.gz
| Download URL | actionflow-0.0.5.tar.gz |
|---|---|
| Size | 92.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bf42f8af7cfe6950458c306dc8754f611d3cd9f8375dcefb5fa6a7015b0ee29
|
|
BLAKE2b-256 checksum How to use checksums |
b185d5ac7ca1a30a61a7912c06cd554ce3b03ca392347b7c3dec39a03df8fc00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Security for actionflow 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.