agentica 0.0.1__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. agentica-0.0.6/PKG-INFO +180 -0
  2. agentica-0.0.6/README.md +156 -0
  3. agentica-0.0.6/agentica/__init__.py +16 -0
  4. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/assistant.py +13 -13
  5. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/config.py +2 -2
  6. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/document.py +1 -1
  7. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/documents.py +3 -3
  8. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/azure_emb.py +2 -2
  9. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/hash_emb.py +1 -1
  10. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/ollama_emb.py +2 -2
  11. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/openai_emb.py +2 -2
  12. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/text2vec_emb.py +1 -1
  13. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/together_emb.py +1 -1
  14. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/word2vec_emb.py +1 -1
  15. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/file/csv.py +2 -2
  16. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/file/txt.py +1 -1
  17. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/anthropic_llm.py +5 -5
  18. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/azure_llm.py +2 -2
  19. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/base.py +4 -4
  20. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/ollama_llm.py +5 -5
  21. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/openai_llm.py +6 -6
  22. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/together_llm.py +5 -5
  23. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/memory.py +5 -5
  24. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/message.py +1 -1
  25. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/python_assistant.py +4 -4
  26. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/sqlite_storage.py +3 -3
  27. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/task.py +2 -2
  28. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tool.py +1 -1
  29. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/airflow.py +2 -2
  30. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/analyze_image.py +3 -3
  31. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/apify.py +2 -2
  32. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/create_image.py +2 -2
  33. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/duckduckgo.py +2 -2
  34. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/file.py +2 -2
  35. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/jina.py +2 -2
  36. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/ocr.py +2 -2
  37. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/run_nb_code.py +3 -3
  38. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/run_python_code.py +2 -2
  39. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/search_exa.py +2 -2
  40. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/search_serper.py +2 -2
  41. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/shell.py +2 -2
  42. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/sql.py +2 -2
  43. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/url_crawler.py +4 -4
  44. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/wikipedia.py +3 -3
  45. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/yfinance.py +1 -1
  46. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/utils/log.py +1 -1
  47. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/utils/shell.py +1 -1
  48. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/vectordb/base.py +1 -1
  49. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/vectordb/lancedb.py +5 -5
  50. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/vectordb/pgvector.py +5 -5
  51. agentica-0.0.6/agentica/version.py +1 -0
  52. agentica-0.0.1/actionflow/actionflow.py → agentica-0.0.6/agentica/workflow.py +12 -12
  53. agentica-0.0.6/agentica.egg-info/PKG-INFO +180 -0
  54. agentica-0.0.6/agentica.egg-info/SOURCES.txt +81 -0
  55. agentica-0.0.6/agentica.egg-info/top_level.txt +2 -0
  56. {agentica-0.0.1 → agentica-0.0.6}/setup.py +4 -4
  57. {agentica-0.0.1 → agentica-0.0.6}/tests/test_function_create_image.py +3 -3
  58. {agentica-0.0.1 → agentica-0.0.6}/tests/test_function_get_url.py +3 -3
  59. {agentica-0.0.1 → agentica-0.0.6}/tests/test_function_save_file.py +3 -3
  60. {agentica-0.0.1 → agentica-0.0.6}/tests/test_llm.py +2 -2
  61. {agentica-0.0.1 → agentica-0.0.6}/tests/test_run_nb_code.py +1 -1
  62. {agentica-0.0.1 → agentica-0.0.6}/tests/test_sqlite_storage.py +2 -2
  63. {agentica-0.0.1 → agentica-0.0.6}/tests/test_write_code.py +2 -2
  64. {agentica-0.0.1 → agentica-0.0.6}/tests/test_write_plan.py +4 -4
  65. agentica-0.0.1/PKG-INFO +0 -179
  66. agentica-0.0.1/README.md +0 -155
  67. agentica-0.0.1/actionflow/__init__.py +0 -16
  68. agentica-0.0.1/actionflow/version.py +0 -1
  69. agentica-0.0.1/agentica.egg-info/PKG-INFO +0 -179
  70. agentica-0.0.1/agentica.egg-info/SOURCES.txt +0 -85
  71. agentica-0.0.1/agentica.egg-info/top_level.txt +0 -2
  72. agentica-0.0.1/tests/test_flow.py +0 -183
  73. agentica-0.0.1/tests/test_function.py +0 -31
  74. agentica-0.0.1/tests/test_function_summarize_text.py +0 -63
  75. agentica-0.0.1/tests/test_output.py +0 -49
  76. {agentica-0.0.1 → agentica-0.0.6}/LICENSE +0 -0
  77. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/__init__.py +0 -0
  78. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/emb/base.py +0 -0
  79. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/file/__init__.py +0 -0
  80. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/file/base.py +0 -0
  81. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/llm/__init__.py +0 -0
  82. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/references.py +0 -0
  83. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/run_record.py +0 -0
  84. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/tools/__init__.py +0 -0
  85. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/utils/__init__.py +0 -0
  86. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/utils/misc.py +0 -0
  87. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/utils/timer.py +0 -0
  88. {agentica-0.0.1/actionflow → agentica-0.0.6/agentica}/vectordb/__init__.py +0 -0
  89. {agentica-0.0.1 → agentica-0.0.6}/agentica.egg-info/dependency_links.txt +0 -0
  90. {agentica-0.0.1 → agentica-0.0.6}/agentica.egg-info/entry_points.txt +0 -0
  91. {agentica-0.0.1 → agentica-0.0.6}/agentica.egg-info/not-zip-safe +0 -0
  92. {agentica-0.0.1 → agentica-0.0.6}/agentica.egg-info/requires.txt +0 -0
  93. {agentica-0.0.1 → agentica-0.0.6}/setup.cfg +0 -0
  94. {agentica-0.0.1 → agentica-0.0.6}/tests/__init__.py +0 -0
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.1
2
+ Name: agentica
3
+ Version: 0.0.6
4
+ Summary: LLM agents
5
+ Home-page: https://github.com/shibing624/agentica
6
+ Author: XuMing
7
+ Author-email: xuming624@qq.com
8
+ License: Apache License 2.0
9
+ Keywords: Agentica,Agent Tool,action,agent,agentica
10
+ Platform: UNKNOWN
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.8.0
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+
23
+ [**🇨🇳中文**](https://github.com/shibing624/agentica/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/agentica/blob/main/README_EN.md)
24
+
25
+ <div align="center">
26
+ <a href="https://github.com/shibing624/agentica">
27
+ <img src="https://raw.githubusercontent.com/shibing624/agentica/main/docs/logo.png" height="150" alt="Logo">
28
+ </a>
29
+ </div>
30
+
31
+ -----------------
32
+
33
+ # Agentica: Build AI Agents
34
+ [![PyPI version](https://badge.fury.io/py/agentica.svg)](https://badge.fury.io/py/agentica)
35
+ [![Downloads](https://static.pepy.tech/badge/agentica)](https://pepy.tech/project/agentica)
36
+ [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)
37
+ [![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
38
+ [![python_version](https://img.shields.io/badge/Python-3.5%2B-green.svg)](requirements.txt)
39
+ [![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
40
+ [![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)
41
+
42
+
43
+ **agentica**: A Human-Centric Framework for Large Language Model Agent Building.
44
+
45
+ **agentica**: 构建你自己的Agent
46
+
47
+ ## Overview
48
+
49
+ #### LLM Agent
50
+ ![llm_agnet](https://github.com/shibing624/agentica/blob/main/docs/llm_agent.png)
51
+
52
+ - **规划(Planning)**:任务拆解、生成计划、反思
53
+ - **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
54
+ - **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
55
+
56
+ #### agentica架构
57
+ ![agentica_arch](https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png)
58
+
59
+ - **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
60
+ - **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
61
+ - **Solver**:求解器将所有这些输出整合为最终答案
62
+
63
+ ## Features
64
+ `agentica`是一个Agent构建工具,功能:
65
+
66
+ - 简单代码快速编排Agent,支持RAG、Workflow、MultiAgent、MultiRole等
67
+ - Agent支持prompt自定义,支持多种工具调用(tool_calls)
68
+ - 支持OpenAI API和Moonshot API(kimi)调用
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install -U agentica
74
+ ```
75
+
76
+ or
77
+
78
+ ```bash
79
+ git clone https://github.com/shibing624/agentica.git
80
+ cd agentica
81
+ pip install .
82
+ ```
83
+
84
+ ## Getting Started
85
+
86
+ 1. 复制[example.env](https://github.com/shibing624/agentica/blob/main/example.env)文件为`.env`,并粘贴OpenAI API key或者Moonshoot API key。
87
+
88
+ 2. 使用`agentica`构建Agent,拆解任务并执行:
89
+
90
+ 自动调用google搜索工具,示例[examples/web_search_demo.py](https://github.com/shibing624/agentica/blob/main/examples/web_search_demo.py)
91
+
92
+ ```python
93
+ from agentica import Assistant, OpenAILLM, AzureOpenAILLM
94
+ from agentica.tools.search_serper import SearchSerperTool
95
+
96
+ m = Assistant(
97
+ llm=AzureOpenAILLM(),
98
+ description="You are a helpful ai assistant.",
99
+ show_tool_calls=True,
100
+ # Enable the assistant to search the knowledge base
101
+ search_knowledge=False,
102
+ tools=[SearchSerperTool()],
103
+ # Enable the assistant to read the chat history
104
+ read_chat_history=True,
105
+ debug_mode=True,
106
+ )
107
+ m.run("一句话介绍林黛玉")
108
+ m.run("北京最近的新闻", stream=True, print_output=True)
109
+ m.run("总结前面的问答")
110
+ ```
111
+
112
+
113
+ ## Examples
114
+
115
+ | 示例 | 描述 |
116
+ |-------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
117
+ | [examples/naive_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/naive_rag_demo.py) | 实现了基础版RAG,基于Txt文档回答问题 |
118
+ | [examples/advanced_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/advanced_rag_demo.py) | 实现了高级版RAG,基于PDF文档回答问题,新增功能:pdf文件解析、query改写,字面+语义多路召回,召回排序(rerank) |
119
+ | [examples/python_assistant_demo.py](https://github.com/shibing624/agentica/blob/main/examples/python_assistant_demo.py) | 实现了Code Interpreter功能,自动生成python代码,并执行 |
120
+ | [examples/research_demo.py](https://github.com/shibing624/agentica/blob/main/examples/research_demo.py) | 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告 |
121
+ | [examples/run_flow_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/run_flow_news_article_demo.py) | 实现了写新闻稿的工作流,multi-agent的实现,定义了多个Assistant和Task,多次调用搜索工具,并生成高级排版的新闻文章 |
122
+ | [examples/run_flow_investment_demo.py](https://github.com/shibing624/agentica/blob/main/examples/run_flow_investment_demo.py) | 实现了投资研究的工作流:股票信息收集 - 股票分析 - 撰写分析报告 - 复查报告等多个Task |
123
+ | [examples/crawl_webpage.py](https://github.com/shibing624/agentica/blob/main/examples/crawl_webpage.py) | 实现了网页分析工作流:从Url爬取融资快讯 - 分析网页内容和格式 - 提取核心信息 - 汇总保存为md文件 |
124
+ | [examples/find_paper_from_arxiv.py](https://github.com/shibing624/agentica/blob/main/examples/find_paper_from_arxiv.py) | 实现了论文推荐工作流:自动从arxiv搜索多组论文 - 相似论文去重 - 提取核心论文信息 - 保存为csv文件 |
125
+ | [examples/remove_image_background.py](https://github.com/shibing624/agentica/blob/main/examples/remove_image_background.py) | 实现了自动去除图片背景功能,包括自动通过pip安装库,调用库实现去除图片背景 |
126
+ | [examples/text_classification_demo.py](https://github.com/shibing624/agentica/blob/main/examples/text_classification_demo.py) | 实现了自动训练分类模型的工作流:读取训练集文件并理解格式 - 谷歌搜索pytextclassifier库 - 爬取github页面了解pytextclassifier的调用方法 - 写代码并执行fasttext模型训练 - check训练好的模型预测结果 |
127
+
128
+
129
+ ## Contact
130
+
131
+ - Issue(建议)
132
+ :[![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
133
+ - 邮件我:xuming: xuming624@qq.com
134
+ - 微信我: 加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
135
+
136
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
137
+
138
+ ## Citation
139
+
140
+ 如果你在研究中使用了`agentica`,请按如下格式引用:
141
+
142
+ APA:
143
+
144
+ ```
145
+ Xu, M. agentica: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/agentica
146
+ ```
147
+
148
+ BibTeX:
149
+
150
+ ```
151
+ @misc{Xu_agentica,
152
+ title={agentica: A Human-Centric Framework for Large Language Model Agent Workflows},
153
+ author={Xu Ming},
154
+ year={2024},
155
+ howpublished={\url{https://github.com/shibing624/agentica}},
156
+ }
157
+ ```
158
+
159
+ ## License
160
+
161
+ 授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
162
+ ## Contribute
163
+
164
+ 项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
165
+
166
+ - 在`tests`添加相应的单元测试
167
+ - 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
168
+
169
+ 之后即可提交PR。
170
+
171
+ ## Acknowledgements
172
+
173
+ - [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
174
+ - [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
175
+ - [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)
176
+
177
+
178
+ Thanks for their great work!
179
+
180
+
@@ -0,0 +1,156 @@
1
+ [**🇨🇳中文**](https://github.com/shibing624/agentica/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/agentica/blob/main/README_EN.md)
2
+
3
+ <div align="center">
4
+ <a href="https://github.com/shibing624/agentica">
5
+ <img src="https://raw.githubusercontent.com/shibing624/agentica/main/docs/logo.png" height="150" alt="Logo">
6
+ </a>
7
+ </div>
8
+
9
+ -----------------
10
+
11
+ # Agentica: Build AI Agents
12
+ [![PyPI version](https://badge.fury.io/py/agentica.svg)](https://badge.fury.io/py/agentica)
13
+ [![Downloads](https://static.pepy.tech/badge/agentica)](https://pepy.tech/project/agentica)
14
+ [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)
15
+ [![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
16
+ [![python_version](https://img.shields.io/badge/Python-3.5%2B-green.svg)](requirements.txt)
17
+ [![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
18
+ [![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)
19
+
20
+
21
+ **agentica**: A Human-Centric Framework for Large Language Model Agent Building.
22
+
23
+ **agentica**: 构建你自己的Agent
24
+
25
+ ## Overview
26
+
27
+ #### LLM Agent
28
+ ![llm_agnet](https://github.com/shibing624/agentica/blob/main/docs/llm_agent.png)
29
+
30
+ - **规划(Planning)**:任务拆解、生成计划、反思
31
+ - **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
32
+ - **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
33
+
34
+ #### agentica架构
35
+ ![agentica_arch](https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png)
36
+
37
+ - **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
38
+ - **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
39
+ - **Solver**:求解器将所有这些输出整合为最终答案
40
+
41
+ ## Features
42
+ `agentica`是一个Agent构建工具,功能:
43
+
44
+ - 简单代码快速编排Agent,支持RAG、Workflow、MultiAgent、MultiRole等
45
+ - Agent支持prompt自定义,支持多种工具调用(tool_calls)
46
+ - 支持OpenAI API和Moonshot API(kimi)调用
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install -U agentica
52
+ ```
53
+
54
+ or
55
+
56
+ ```bash
57
+ git clone https://github.com/shibing624/agentica.git
58
+ cd agentica
59
+ pip install .
60
+ ```
61
+
62
+ ## Getting Started
63
+
64
+ 1. 复制[example.env](https://github.com/shibing624/agentica/blob/main/example.env)文件为`.env`,并粘贴OpenAI API key或者Moonshoot API key。
65
+
66
+ 2. 使用`agentica`构建Agent,拆解任务并执行:
67
+
68
+ 自动调用google搜索工具,示例[examples/web_search_demo.py](https://github.com/shibing624/agentica/blob/main/examples/web_search_demo.py)
69
+
70
+ ```python
71
+ from agentica import Assistant, OpenAILLM, AzureOpenAILLM
72
+ from agentica.tools.search_serper import SearchSerperTool
73
+
74
+ m = Assistant(
75
+ llm=AzureOpenAILLM(),
76
+ description="You are a helpful ai assistant.",
77
+ show_tool_calls=True,
78
+ # Enable the assistant to search the knowledge base
79
+ search_knowledge=False,
80
+ tools=[SearchSerperTool()],
81
+ # Enable the assistant to read the chat history
82
+ read_chat_history=True,
83
+ debug_mode=True,
84
+ )
85
+ m.run("一句话介绍林黛玉")
86
+ m.run("北京最近的新闻", stream=True, print_output=True)
87
+ m.run("总结前面的问答")
88
+ ```
89
+
90
+
91
+ ## Examples
92
+
93
+ | 示例 | 描述 |
94
+ |-------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
95
+ | [examples/naive_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/naive_rag_demo.py) | 实现了基础版RAG,基于Txt文档回答问题 |
96
+ | [examples/advanced_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/advanced_rag_demo.py) | 实现了高级版RAG,基于PDF文档回答问题,新增功能:pdf文件解析、query改写,字面+语义多路召回,召回排序(rerank) |
97
+ | [examples/python_assistant_demo.py](https://github.com/shibing624/agentica/blob/main/examples/python_assistant_demo.py) | 实现了Code Interpreter功能,自动生成python代码,并执行 |
98
+ | [examples/research_demo.py](https://github.com/shibing624/agentica/blob/main/examples/research_demo.py) | 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告 |
99
+ | [examples/run_flow_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/run_flow_news_article_demo.py) | 实现了写新闻稿的工作流,multi-agent的实现,定义了多个Assistant和Task,多次调用搜索工具,并生成高级排版的新闻文章 |
100
+ | [examples/run_flow_investment_demo.py](https://github.com/shibing624/agentica/blob/main/examples/run_flow_investment_demo.py) | 实现了投资研究的工作流:股票信息收集 - 股票分析 - 撰写分析报告 - 复查报告等多个Task |
101
+ | [examples/crawl_webpage.py](https://github.com/shibing624/agentica/blob/main/examples/crawl_webpage.py) | 实现了网页分析工作流:从Url爬取融资快讯 - 分析网页内容和格式 - 提取核心信息 - 汇总保存为md文件 |
102
+ | [examples/find_paper_from_arxiv.py](https://github.com/shibing624/agentica/blob/main/examples/find_paper_from_arxiv.py) | 实现了论文推荐工作流:自动从arxiv搜索多组论文 - 相似论文去重 - 提取核心论文信息 - 保存为csv文件 |
103
+ | [examples/remove_image_background.py](https://github.com/shibing624/agentica/blob/main/examples/remove_image_background.py) | 实现了自动去除图片背景功能,包括自动通过pip安装库,调用库实现去除图片背景 |
104
+ | [examples/text_classification_demo.py](https://github.com/shibing624/agentica/blob/main/examples/text_classification_demo.py) | 实现了自动训练分类模型的工作流:读取训练集文件并理解格式 - 谷歌搜索pytextclassifier库 - 爬取github页面了解pytextclassifier的调用方法 - 写代码并执行fasttext模型训练 - check训练好的模型预测结果 |
105
+
106
+
107
+ ## Contact
108
+
109
+ - Issue(建议)
110
+ :[![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
111
+ - 邮件我:xuming: xuming624@qq.com
112
+ - 微信我: 加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
113
+
114
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
115
+
116
+ ## Citation
117
+
118
+ 如果你在研究中使用了`agentica`,请按如下格式引用:
119
+
120
+ APA:
121
+
122
+ ```
123
+ Xu, M. agentica: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/agentica
124
+ ```
125
+
126
+ BibTeX:
127
+
128
+ ```
129
+ @misc{Xu_agentica,
130
+ title={agentica: A Human-Centric Framework for Large Language Model Agent Workflows},
131
+ author={Xu Ming},
132
+ year={2024},
133
+ howpublished={\url{https://github.com/shibing624/agentica}},
134
+ }
135
+ ```
136
+
137
+ ## License
138
+
139
+ 授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
140
+ ## Contribute
141
+
142
+ 项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
143
+
144
+ - 在`tests`添加相应的单元测试
145
+ - 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
146
+
147
+ 之后即可提交PR。
148
+
149
+ ## Acknowledgements
150
+
151
+ - [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
152
+ - [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
153
+ - [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)
154
+
155
+
156
+ Thanks for their great work!
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @author:XuMing(xuming624@qq.com)
4
+ @description:
5
+ """
6
+ from agentica.version import __version__ # noqa, isort: skip
7
+ from agentica.config import DOTENV_PATH, SMART_LLM, FAST_LLM # noqa, isort: skip
8
+ from agentica.assistant import Assistant
9
+ from agentica.python_assistant import PythonAssistant
10
+ from agentica.document import Document
11
+ from agentica.documents import Documents
12
+ from agentica.llm.openai_llm import OpenAILLM
13
+ from agentica.llm.azure_llm import AzureOpenAILLM
14
+ from agentica.task import Task
15
+ from agentica.workflow import Workflow
16
+
@@ -28,18 +28,18 @@ from uuid import uuid4
28
28
 
29
29
  from pydantic import BaseModel, ConfigDict, field_validator, ValidationError
30
30
 
31
- from actionflow.document import Document
32
- from actionflow.documents import Documents
33
- from actionflow.llm.base import LLM
34
- from actionflow.memory import AssistantMemory, Memory
35
- from actionflow.message import Message
36
- from actionflow.references import References
37
- from actionflow.run_record import RunRecord
38
- from actionflow.sqlite_storage import SqliteStorage
39
- from actionflow.tool import Tool, Toolkit, Function
40
- from actionflow.utils.log import logger, set_log_level_to_debug, print_llm_stream
41
- from actionflow.utils.misc import merge_dictionaries, remove_indent
42
- from actionflow.utils.timer import Timer
31
+ from agentica.document import Document
32
+ from agentica.documents import Documents
33
+ from agentica.llm.base import LLM
34
+ from agentica.memory import AssistantMemory, Memory
35
+ from agentica.message import Message
36
+ from agentica.references import References
37
+ from agentica.run_record import RunRecord
38
+ from agentica.sqlite_storage import SqliteStorage
39
+ from agentica.tool import Tool, Toolkit, Function
40
+ from agentica.utils.log import logger, set_log_level_to_debug, print_llm_stream
41
+ from agentica.utils.misc import merge_dictionaries, remove_indent
42
+ from agentica.utils.timer import Timer
43
43
 
44
44
 
45
45
  class Assistant(BaseModel):
@@ -269,7 +269,7 @@ class Assistant(BaseModel):
269
269
  def update_llm(self) -> None:
270
270
  if self.llm is None:
271
271
  try:
272
- from actionflow.llm.openai_llm import OpenAILLM
272
+ from agentica.llm.openai_llm import OpenAILLM
273
273
  except ModuleNotFoundError as e:
274
274
  logger.exception(e)
275
275
  logger.error("use `openai` as the default LLM. ")
@@ -19,10 +19,10 @@ try:
19
19
  except ImportError:
20
20
  logger.debug("dotenv not installed, skipping...")
21
21
 
22
- ACTIONFLOW_HOME = os.environ.get("ACTIONFLOW_HOME", os.path.realpath(os.path.curdir))
22
+ AGENTICA_HOME = os.environ.get("AGENTICA_HOME", os.path.realpath(os.path.curdir))
23
23
  current_date = datetime.now()
24
24
  formatted_date = current_date.strftime("%Y%m%d")
25
- LOG_FILE = os.environ.get("LOG_FILE", f"{ACTIONFLOW_HOME}/logs/{formatted_date}.log")
25
+ LOG_FILE = os.environ.get("LOG_FILE", f"{AGENTICA_HOME}/logs/{formatted_date}.log")
26
26
  LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO")
27
27
  SMART_LLM = os.environ.get("SMART_LLM")
28
28
  FAST_LLM = os.environ.get("FAST_LLM")
@@ -9,7 +9,7 @@ from typing import Optional, Dict, Any, List
9
9
 
10
10
  from pydantic import BaseModel, ConfigDict
11
11
 
12
- from actionflow.emb.base import Emb
12
+ from agentica.emb.base import Emb
13
13
 
14
14
 
15
15
  class Document(BaseModel):
@@ -9,9 +9,9 @@ from typing import List, Optional, Iterator, Dict, Any, Union
9
9
 
10
10
  from pydantic import BaseModel, ConfigDict
11
11
 
12
- from actionflow.document import Document
13
- from actionflow.utils.log import logger
14
- from actionflow.vectordb.base import VectorDb
12
+ from agentica.document import Document
13
+ from agentica.utils.log import logger
14
+ from agentica.vectordb.base import VectorDb
15
15
 
16
16
 
17
17
  class Documents(BaseModel):
@@ -8,8 +8,8 @@ from os import getenv
8
8
  from typing import Optional, Dict, List, Tuple, Any
9
9
  from typing_extensions import Literal
10
10
 
11
- from actionflow.emb.base import Emb
12
- from actionflow.utils.log import logger
11
+ from agentica.emb.base import Emb
12
+ from agentica.utils.log import logger
13
13
 
14
14
  try:
15
15
  from openai import AzureOpenAI as AzureOpenAIClient
@@ -6,7 +6,7 @@
6
6
  import hashlib
7
7
  from typing import List
8
8
 
9
- from actionflow.emb.base import Emb
9
+ from agentica.emb.base import Emb
10
10
 
11
11
 
12
12
  class HashEmb(Emb):
@@ -6,8 +6,8 @@ part of the code from https://github.com/phidatahq/phidata
6
6
  """
7
7
  from typing import Optional, Dict, List, Any
8
8
 
9
- from actionflow.emb.base import Emb
10
- from actionflow.utils.log import logger
9
+ from agentica.emb.base import Emb
10
+ from agentica.utils.log import logger
11
11
 
12
12
  try:
13
13
  from ollama import Client as OllamaClient
@@ -9,8 +9,8 @@ from typing import Optional, Dict, List, Tuple, Any
9
9
 
10
10
  from typing_extensions import Literal
11
11
 
12
- from actionflow.emb.base import Emb
13
- from actionflow.utils.log import logger
12
+ from agentica.emb.base import Emb
13
+ from agentica.utils.log import logger
14
14
 
15
15
  try:
16
16
  from openai import OpenAI as OpenAIClient
@@ -11,7 +11,7 @@ except ImportError:
11
11
  raise ImportError(
12
12
  "`text2vec` not installed. Please install it with `pip install text2vec`"
13
13
  )
14
- from actionflow.emb.base import Emb
14
+ from agentica.emb.base import Emb
15
15
 
16
16
 
17
17
  class Text2VecEmb(Emb):
@@ -7,7 +7,7 @@ part of the code from https://github.com/phidatahq/phidata
7
7
  from os import getenv
8
8
  from typing import Optional
9
9
 
10
- from actionflow.emb.openai_emb import OpenAIEmb
10
+ from agentica.emb.openai_emb import OpenAIEmb
11
11
 
12
12
 
13
13
  class TogetherEmb(OpenAIEmb):
@@ -11,7 +11,7 @@ except ImportError:
11
11
  raise ImportError(
12
12
  "`text2vec` not installed. Please install it with `pip install text2vec`"
13
13
  )
14
- from actionflow.emb.base import Emb
14
+ from agentica.emb.base import Emb
15
15
 
16
16
 
17
17
  class Word2VecEmb(Emb):
@@ -2,8 +2,8 @@ import csv
2
2
  from pathlib import Path
3
3
  from typing import Any
4
4
 
5
- from actionflow.file.base import File
6
- from actionflow.utils.log import logger
5
+ from agentica.file.base import File
6
+ from agentica.utils.log import logger
7
7
 
8
8
 
9
9
  class CsvFile(File):
@@ -1,7 +1,7 @@
1
1
  from pathlib import Path
2
2
  from typing import Any
3
3
 
4
- from actionflow.file.base import File
4
+ from agentica.file.base import File
5
5
 
6
6
 
7
7
  class TextFile(File):
@@ -14,16 +14,16 @@ try:
14
14
  except ImportError:
15
15
  raise ImportError("`anthropic` not installed, please install it using `pip install anthropic`.")
16
16
 
17
- from actionflow.llm.base import LLM
18
- from actionflow.message import Message
19
- from actionflow.tool import (
17
+ from agentica.llm.base import LLM
18
+ from agentica.message import Message
19
+ from agentica.tool import (
20
20
  FunctionCall,
21
21
  get_function_call_for_tool_call,
22
22
  extract_tool_from_xml,
23
23
  remove_function_calls_from_string,
24
24
  )
25
- from actionflow.utils.log import logger
26
- from actionflow.utils.timer import Timer
25
+ from agentica.utils.log import logger
26
+ from agentica.utils.timer import Timer
27
27
 
28
28
 
29
29
  class AnthropicLLM(LLM):
@@ -11,8 +11,8 @@ try:
11
11
  from openai import AzureOpenAI as AzureOpenAIClient
12
12
  except ImportError:
13
13
  raise ImportError("`openai` not installed, please run `pip install openai`")
14
- from actionflow.config import FAST_LLM
15
- from actionflow.llm.openai_llm import OpenAILLM
14
+ from agentica.config import FAST_LLM
15
+ from agentica.llm.openai_llm import OpenAILLM
16
16
 
17
17
 
18
18
  class AzureOpenAILLM(OpenAILLM):
@@ -8,10 +8,10 @@ from typing import List, Iterator, Optional, Dict, Any, Callable, Union
8
8
 
9
9
  from pydantic import BaseModel, ConfigDict
10
10
 
11
- from actionflow.message import Message
12
- from actionflow.tool import Function, FunctionCall, Tool, Toolkit
13
- from actionflow.utils.log import logger
14
- from actionflow.utils.timer import Timer
11
+ from agentica.message import Message
12
+ from agentica.tool import Function, FunctionCall, Tool, Toolkit
13
+ from agentica.utils.log import logger
14
+ from agentica.utils.timer import Timer
15
15
 
16
16
 
17
17
  class LLM(BaseModel):
@@ -13,11 +13,11 @@ try:
13
13
  except ImportError:
14
14
  raise ImportError("`ollama` not installed, please run `pip install ollama`")
15
15
 
16
- from actionflow.llm.base import LLM
17
- from actionflow.message import Message
18
- from actionflow.tool import FunctionCall, get_function_call_for_tool_call
19
- from actionflow.utils.log import logger
20
- from actionflow.utils.timer import Timer
16
+ from agentica.llm.base import LLM
17
+ from agentica.message import Message
18
+ from agentica.tool import FunctionCall, get_function_call_for_tool_call
19
+ from agentica.utils.log import logger
20
+ from agentica.utils.timer import Timer
21
21
 
22
22
 
23
23
  class OllamaLLM(LLM):
@@ -27,12 +27,12 @@ try:
27
27
  from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall
28
28
  except ImportError:
29
29
  raise ImportError("`openai` not installed, please run `pip install openai -U`.")
30
- from actionflow.config import FAST_LLM
31
- from actionflow.llm.base import LLM
32
- from actionflow.message import Message
33
- from actionflow.tool import FunctionCall, get_function_call, get_function_call_for_tool_call
34
- from actionflow.utils.log import logger
35
- from actionflow.utils.timer import Timer
30
+ from agentica.config import FAST_LLM
31
+ from agentica.llm.base import LLM
32
+ from agentica.message import Message
33
+ from agentica.tool import FunctionCall, get_function_call, get_function_call_for_tool_call
34
+ from agentica.utils.log import logger
35
+ from agentica.utils.timer import Timer
36
36
 
37
37
 
38
38
  class OpenAILLM(LLM):
@@ -8,11 +8,11 @@ import json
8
8
  from os import getenv
9
9
  from typing import Optional, List, Iterator, Dict, Any
10
10
 
11
- from actionflow.llm.openai_llm import OpenAILLM
12
- from actionflow.message import Message
13
- from actionflow.tool import FunctionCall, get_function_call_for_tool_call
14
- from actionflow.utils.log import logger
15
- from actionflow.utils.timer import Timer
11
+ from agentica.llm.openai_llm import OpenAILLM
12
+ from agentica.message import Message
13
+ from agentica.tool import FunctionCall, get_function_call_for_tool_call
14
+ from agentica.utils.log import logger
15
+ from agentica.utils.timer import Timer
16
16
 
17
17
 
18
18
  class TogetherLLM(OpenAILLM):