agentica 0.1.8__tar.gz → 0.2.0__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 (201) hide show
  1. agentica-0.2.0/PKG-INFO +275 -0
  2. agentica-0.2.0/README.md +244 -0
  3. agentica-0.2.0/agentica/__init__.py +91 -0
  4. agentica-0.2.0/agentica/agent.py +3092 -0
  5. agentica-0.2.0/agentica/agent_session.py +60 -0
  6. {agentica-0.1.8 → agentica-0.2.0}/agentica/config.py +2 -5
  7. {agentica-0.1.8 → agentica-0.2.0}/agentica/document.py +1 -0
  8. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/hash_emb.py +11 -1
  9. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/openai_emb.py +12 -0
  10. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/sentence_transformer_emb.py +1 -1
  11. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/text2vec_emb.py +10 -0
  12. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/word2vec_emb.py +10 -0
  13. agentica-0.2.0/agentica/knowledge/__init__.py +8 -0
  14. agentica-0.1.8/agentica/knowledge/knowledge_base.py → agentica-0.2.0/agentica/knowledge/base.py +61 -31
  15. agentica-0.1.8/agentica/knowledge/langchain.py → agentica-0.2.0/agentica/knowledge/langchain_knowledge.py +4 -4
  16. agentica-0.1.8/agentica/knowledge/llamaindex.py → agentica-0.2.0/agentica/knowledge/llamaindex_knowledge.py +5 -16
  17. agentica-0.2.0/agentica/memory.py +887 -0
  18. agentica-0.2.0/agentica/memorydb.py +600 -0
  19. agentica-0.2.0/agentica/model/anthropic/__init__.py +1 -0
  20. agentica-0.2.0/agentica/model/anthropic/claude.py +670 -0
  21. agentica-0.2.0/agentica/model/aws/api_client.py +43 -0
  22. agentica-0.2.0/agentica/model/aws/bedrock.py +577 -0
  23. agentica-0.2.0/agentica/model/aws/claude.py +223 -0
  24. agentica-0.2.0/agentica/model/azure/__init__.py +1 -0
  25. agentica-0.2.0/agentica/model/azure/openai_chat.py +96 -0
  26. agentica-0.2.0/agentica/model/base.py +530 -0
  27. agentica-0.2.0/agentica/model/cohere/__init__.py +1 -0
  28. agentica-0.2.0/agentica/model/cohere/chat.py +636 -0
  29. agentica-0.2.0/agentica/model/content.py +37 -0
  30. agentica-0.2.0/agentica/model/deepseek/__init__.py +1 -0
  31. agentica-0.2.0/agentica/model/deepseek/chat.py +24 -0
  32. agentica-0.2.0/agentica/model/doubao/__init__.py +1 -0
  33. agentica-0.2.0/agentica/model/doubao/chat.py +24 -0
  34. agentica-0.2.0/agentica/model/fireworks/__init__.py +1 -0
  35. agentica-0.2.0/agentica/model/fireworks/fireworks.py +43 -0
  36. agentica-0.2.0/agentica/model/google/__init__.py +2 -0
  37. agentica-0.2.0/agentica/model/google/gemini.py +780 -0
  38. agentica-0.2.0/agentica/model/google/gemini_openai.py +25 -0
  39. agentica-0.2.0/agentica/model/groq/__init__.py +1 -0
  40. agentica-0.2.0/agentica/model/groq/groq.py +891 -0
  41. agentica-0.2.0/agentica/model/huggingface/__init__.py +1 -0
  42. agentica-0.2.0/agentica/model/huggingface/hf.py +849 -0
  43. agentica-0.2.0/agentica/model/internlm/__init__.py +1 -0
  44. agentica-0.2.0/agentica/model/internlm/chat.py +24 -0
  45. agentica-0.2.0/agentica/model/message.py +129 -0
  46. agentica-0.2.0/agentica/model/mistral/__init__.py +1 -0
  47. agentica-0.2.0/agentica/model/mistral/mistral.py +544 -0
  48. agentica-0.2.0/agentica/model/moonshot/__init__.py +1 -0
  49. agentica-0.2.0/agentica/model/moonshot/chat.py +24 -0
  50. agentica-0.2.0/agentica/model/nvidia/__init__.py +1 -0
  51. agentica-0.2.0/agentica/model/nvidia/chat.py +24 -0
  52. agentica-0.2.0/agentica/model/ollama/__init__.py +3 -0
  53. agentica-0.2.0/agentica/model/ollama/chat.py +724 -0
  54. agentica-0.2.0/agentica/model/ollama/hermes.py +226 -0
  55. agentica-0.2.0/agentica/model/ollama/tools.py +361 -0
  56. agentica-0.2.0/agentica/model/openai/__init__.py +2 -0
  57. agentica-0.2.0/agentica/model/openai/chat.py +1024 -0
  58. agentica-0.2.0/agentica/model/openai/like.py +8 -0
  59. agentica-0.2.0/agentica/model/openrouter/__init__.py +1 -0
  60. agentica-0.2.0/agentica/model/openrouter/openrouter.py +26 -0
  61. agentica-0.2.0/agentica/model/response.py +30 -0
  62. agentica-0.2.0/agentica/model/sambanova/__init__.py +1 -0
  63. agentica-0.2.0/agentica/model/sambanova/sambanova.py +24 -0
  64. agentica-0.2.0/agentica/model/together/__init__.py +1 -0
  65. agentica-0.2.0/agentica/model/together/togetherchat.py +179 -0
  66. agentica-0.2.0/agentica/model/vertexai/__init__.py +1 -0
  67. agentica-0.2.0/agentica/model/vertexai/gemini.py +631 -0
  68. agentica-0.2.0/agentica/model/xai/__init__.py +1 -0
  69. agentica-0.2.0/agentica/model/xai/grok.py +24 -0
  70. agentica-0.2.0/agentica/model/yi/__init__.py +1 -0
  71. agentica-0.2.0/agentica/model/yi/chat.py +24 -0
  72. agentica-0.1.8/agentica/python_assistant.py → agentica-0.2.0/agentica/python_agent.py +86 -83
  73. agentica-0.2.0/agentica/reasoning.py +35 -0
  74. agentica-0.2.0/agentica/reranker/__init__.py +0 -0
  75. agentica-0.2.0/agentica/reranker/base.py +18 -0
  76. agentica-0.2.0/agentica/reranker/bge.py +97 -0
  77. agentica-0.2.0/agentica/reranker/cohere.py +68 -0
  78. agentica-0.2.0/agentica/run_response.py +159 -0
  79. agentica-0.2.0/agentica/storage/__init__.py +0 -0
  80. agentica-0.2.0/agentica/storage/agent/base.py +43 -0
  81. agentica-0.2.0/agentica/storage/agent/json_file.py +89 -0
  82. agentica-0.2.0/agentica/storage/agent/postgres.py +370 -0
  83. agentica-0.2.0/agentica/storage/agent/sqlite.py +384 -0
  84. agentica-0.2.0/agentica/storage/agent/yaml_file.py +89 -0
  85. agentica-0.2.0/agentica/storage/workflow/__init__.py +5 -0
  86. agentica-0.2.0/agentica/storage/workflow/base.py +45 -0
  87. agentica-0.2.0/agentica/storage/workflow/postgres.py +363 -0
  88. agentica-0.2.0/agentica/storage/workflow/sqlite.py +356 -0
  89. agentica-0.2.0/agentica/tools/__init__.py +0 -0
  90. agentica-0.1.8/agentica/tools/airflow.py → agentica-0.2.0/agentica/tools/airflow_tool.py +30 -6
  91. agentica-0.1.8/agentica/tools/analyze_image.py → agentica-0.2.0/agentica/tools/analyze_image_tool.py +22 -14
  92. agentica-0.1.8/agentica/tools/arxiv.py → agentica-0.2.0/agentica/tools/arxiv_tool.py +31 -2
  93. agentica-0.2.0/agentica/tools/baidusearch_tool.py +287 -0
  94. {agentica-0.1.8 → agentica-0.2.0}/agentica/tools/base.py +259 -58
  95. agentica-0.2.0/agentica/tools/calculator_tool.py +190 -0
  96. agentica-0.1.8/agentica/tools/create_image.py → agentica-0.2.0/agentica/tools/create_image_tool.py +38 -27
  97. agentica-0.1.8/agentica/tools/dblp.py → agentica-0.2.0/agentica/tools/dblp_tool.py +5 -0
  98. agentica-0.1.8/agentica/tools/duckduckgo.py → agentica-0.2.0/agentica/tools/duckduckgo_tool.py +19 -6
  99. agentica-0.1.8/agentica/tools/file.py → agentica-0.2.0/agentica/tools/file_tool.py +56 -14
  100. agentica-0.1.8/agentica/tools/hackernews.py → agentica-0.2.0/agentica/tools/hackernews_tool.py +18 -6
  101. agentica-0.1.8/agentica/tools/jina.py → agentica-0.2.0/agentica/tools/jina_tool.py +27 -10
  102. agentica-0.2.0/agentica/tools/newspaper_tool.py +86 -0
  103. agentica-0.2.0/agentica/tools/ocr_tool.py +57 -0
  104. agentica-0.2.0/agentica/tools/resend_tools.py +65 -0
  105. agentica-0.1.8/agentica/tools/run_nb_code.py → agentica-0.2.0/agentica/tools/run_nb_code_tool.py +11 -2
  106. agentica-0.2.0/agentica/tools/run_python_code_tool.py +187 -0
  107. agentica-0.1.8/agentica/tools/search_exa.py → agentica-0.2.0/agentica/tools/search_exa_tool.py +14 -0
  108. agentica-0.1.8/agentica/tools/search_serper.py → agentica-0.2.0/agentica/tools/search_serper_tool.py +21 -16
  109. agentica-0.1.8/agentica/tools/shell.py → agentica-0.2.0/agentica/tools/shell_tool.py +13 -0
  110. agentica-0.1.8/agentica/tools/sql.py → agentica-0.2.0/agentica/tools/sql_tool.py +21 -5
  111. agentica-0.2.0/agentica/tools/text_analysis_tool.py +51 -0
  112. agentica-0.1.8/agentica/tools/url_crawler.py → agentica-0.2.0/agentica/tools/url_crawler_tool.py +19 -22
  113. agentica-0.2.0/agentica/tools/wikipedia_tool.py +47 -0
  114. agentica-0.1.8/agentica/tools/yfinance.py → agentica-0.2.0/agentica/tools/yfinance_tool.py +87 -20
  115. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/__init__.py +0 -1
  116. agentica-0.2.0/agentica/utils/console.py +78 -0
  117. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/file_parser.py +75 -31
  118. agentica-0.2.0/agentica/utils/io.py +18 -0
  119. agentica-0.2.0/agentica/utils/json_util.py +106 -0
  120. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/misc.py +43 -36
  121. {agentica-0.1.8 → agentica-0.2.0}/agentica/vectordb/base.py +25 -8
  122. agentica-0.1.8/agentica/vectordb/chromadb.py → agentica-0.2.0/agentica/vectordb/chromadb_vectordb.py +35 -11
  123. agentica-0.2.0/agentica/vectordb/lancedb_vectordb.py +293 -0
  124. {agentica-0.1.8 → agentica-0.2.0}/agentica/vectordb/memory_vectordb.py +20 -9
  125. agentica-0.1.8/agentica/vectordb/pgvector.py → agentica-0.2.0/agentica/vectordb/pgvectordb.py +46 -6
  126. {agentica-0.1.8 → agentica-0.2.0}/agentica/vectordb/pineconedb.py +99 -29
  127. agentica-0.1.8/agentica/vectordb/qdrant.py → agentica-0.2.0/agentica/vectordb/qdrantdb.py +30 -8
  128. agentica-0.2.0/agentica/version.py +1 -0
  129. agentica-0.2.0/agentica/workflow.py +453 -0
  130. agentica-0.2.0/agentica/workflow_session.py +41 -0
  131. agentica-0.2.0/agentica.egg-info/PKG-INFO +275 -0
  132. agentica-0.2.0/agentica.egg-info/SOURCES.txt +166 -0
  133. agentica-0.2.0/tests/__init__.py +5 -0
  134. {agentica-0.1.8 → agentica-0.2.0}/tests/test_create_image.py +7 -5
  135. agentica-0.2.0/tests/test_file_reader.py +65 -0
  136. {agentica-0.1.8 → agentica-0.2.0}/tests/test_jina_tool.py +8 -15
  137. {agentica-0.1.8 → agentica-0.2.0}/tests/test_llm.py +4 -2
  138. {agentica-0.1.8 → agentica-0.2.0}/tests/test_run_nb_code.py +3 -1
  139. {agentica-0.1.8 → agentica-0.2.0}/tests/test_url_crawler.py +29 -26
  140. agentica-0.1.8/PKG-INFO +0 -258
  141. agentica-0.1.8/README.md +0 -227
  142. agentica-0.1.8/agentica/__init__.py +0 -74
  143. agentica-0.1.8/agentica/assistant.py +0 -1392
  144. agentica-0.1.8/agentica/llm/__init__.py +0 -8
  145. agentica-0.1.8/agentica/llm/azure_openai_llm.py +0 -64
  146. agentica-0.1.8/agentica/llm/base.py +0 -197
  147. agentica-0.1.8/agentica/llm/claude_llm.py +0 -419
  148. agentica-0.1.8/agentica/llm/deepseek_llm.py +0 -75
  149. agentica-0.1.8/agentica/llm/moonshot_llm.py +0 -27
  150. agentica-0.1.8/agentica/llm/ollama_llm.py +0 -640
  151. agentica-0.1.8/agentica/llm/ollama_tools_llm.py +0 -489
  152. agentica-0.1.8/agentica/llm/openai_llm.py +0 -965
  153. agentica-0.1.8/agentica/llm/togetherllm.py +0 -155
  154. agentica-0.1.8/agentica/memory.py +0 -752
  155. agentica-0.1.8/agentica/message.py +0 -114
  156. agentica-0.1.8/agentica/references.py +0 -19
  157. agentica-0.1.8/agentica/run_record.py +0 -52
  158. agentica-0.1.8/agentica/storage/__init__.py +0 -8
  159. agentica-0.1.8/agentica/storage/base.py +0 -38
  160. agentica-0.1.8/agentica/storage/pg_storage.py +0 -234
  161. agentica-0.1.8/agentica/storage/sqlite_storage.py +0 -263
  162. agentica-0.1.8/agentica/task.py +0 -122
  163. agentica-0.1.8/agentica/tools/ocr.py +0 -66
  164. agentica-0.1.8/agentica/tools/run_python_code.py +0 -110
  165. agentica-0.1.8/agentica/tools/wikipedia.py +0 -40
  166. agentica-0.1.8/agentica/vectordb/lancedb.py +0 -204
  167. agentica-0.1.8/agentica/version.py +0 -1
  168. agentica-0.1.8/agentica/workflow.py +0 -161
  169. agentica-0.1.8/agentica.egg-info/PKG-INFO +0 -258
  170. agentica-0.1.8/agentica.egg-info/SOURCES.txt +0 -102
  171. agentica-0.1.8/tests/test_moonshot_llm.py +0 -296
  172. agentica-0.1.8/tests/test_sqlite_storage.py +0 -97
  173. {agentica-0.1.8 → agentica-0.2.0}/LICENSE +0 -0
  174. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/__init__.py +0 -0
  175. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/azure_openai_emb.py +0 -0
  176. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/base.py +0 -0
  177. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/fireworks_emb.py +0 -0
  178. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/genimi_emb.py +0 -0
  179. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/huggingface_emb.py +0 -0
  180. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/ollama_emb.py +0 -0
  181. {agentica-0.1.8 → agentica-0.2.0}/agentica/emb/together_emb.py +0 -0
  182. {agentica-0.1.8 → agentica-0.2.0}/agentica/file/__init__.py +0 -0
  183. {agentica-0.1.8 → agentica-0.2.0}/agentica/file/base.py +0 -0
  184. {agentica-0.1.8 → agentica-0.2.0}/agentica/file/csv.py +0 -0
  185. {agentica-0.1.8 → agentica-0.2.0}/agentica/file/txt.py +0 -0
  186. {agentica-0.1.8/agentica/tools → agentica-0.2.0/agentica/model}/__init__.py +0 -0
  187. {agentica-0.1.8/tests → agentica-0.2.0/agentica/model/aws}/__init__.py +0 -0
  188. {agentica-0.1.8/agentica/knowledge → agentica-0.2.0/agentica/storage/agent}/__init__.py +0 -0
  189. {agentica-0.1.8 → agentica-0.2.0}/agentica/template.py +0 -0
  190. /agentica-0.1.8/agentica/tools/apify.py → /agentica-0.2.0/agentica/tools/apify_tool.py +0 -0
  191. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/log.py +0 -0
  192. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/shell.py +0 -0
  193. {agentica-0.1.8 → agentica-0.2.0}/agentica/utils/timer.py +0 -0
  194. {agentica-0.1.8 → agentica-0.2.0}/agentica/vectordb/__init__.py +0 -0
  195. {agentica-0.1.8 → agentica-0.2.0}/agentica.egg-info/dependency_links.txt +0 -0
  196. {agentica-0.1.8 → agentica-0.2.0}/agentica.egg-info/entry_points.txt +0 -0
  197. {agentica-0.1.8 → agentica-0.2.0}/agentica.egg-info/not-zip-safe +0 -0
  198. {agentica-0.1.8 → agentica-0.2.0}/agentica.egg-info/requires.txt +0 -0
  199. {agentica-0.1.8 → agentica-0.2.0}/agentica.egg-info/top_level.txt +0 -0
  200. {agentica-0.1.8 → agentica-0.2.0}/setup.cfg +0 -0
  201. {agentica-0.1.8 → agentica-0.2.0}/setup.py +0 -0
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.1
2
+ Name: agentica
3
+ Version: 0.2.0
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
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.8.0
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: loguru
22
+ Requires-Dist: markdownify
23
+ Requires-Dist: openai
24
+ Requires-Dist: python-dotenv
25
+ Requires-Dist: pydantic
26
+ Requires-Dist: requests
27
+ Requires-Dist: sqlalchemy
28
+ Requires-Dist: scikit-learn
29
+ Requires-Dist: tqdm
30
+ Requires-Dist: rich
31
+
32
+ [**🇨🇳中文**](https://github.com/shibing624/agentica/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/agentica/blob/main/README_EN.md) | [**🇯🇵日本語**](https://github.com/shibing624/agentica/blob/main/README_JP.md)
33
+
34
+ <div align="center">
35
+ <a href="https://github.com/shibing624/agentica">
36
+ <img src="https://raw.githubusercontent.com/shibing624/agentica/main/docs/logo.png" height="150" alt="Logo">
37
+ </a>
38
+ </div>
39
+
40
+ -----------------
41
+
42
+ # Agentica: Build AI Agents
43
+ [![PyPI version](https://badge.fury.io/py/agentica.svg)](https://badge.fury.io/py/agentica)
44
+ [![Downloads](https://static.pepy.tech/badge/agentica)](https://pepy.tech/project/agentica)
45
+ [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)
46
+ [![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
47
+ [![python_version](https://img.shields.io/badge/Python-3.5%2B-green.svg)](requirements.txt)
48
+ [![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
49
+ [![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)
50
+
51
+
52
+ **Agentica**: A Human-Centric Framework for Large Language Model Agent Building. 快速打造你的专属Agent。
53
+
54
+ ## Overview
55
+
56
+ #### LLM Agent
57
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
58
+
59
+ - **规划(Planning)**:任务拆解、生成计划、反思
60
+ - **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
61
+ - **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
62
+
63
+ #### Agentica Assistant Architecture
64
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
65
+
66
+ - **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
67
+ - **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
68
+ - **Solver**:求解器将所有这些输出整合为最终答案
69
+
70
+
71
+ ## Features
72
+ `Agentica`是一个Agent构建工具,功能:
73
+
74
+ - 简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Multi-Role、Workflow等功能
75
+ - Agent支持prompt自定义,支持多种工具调用(tool_calls)
76
+ - 支持OpenAI/Azure/Deepseek/Moonshot/Claude/Ollama/Together API调用
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ pip install -U agentica
82
+ ```
83
+
84
+ or
85
+
86
+ ```bash
87
+ git clone https://github.com/shibing624/agentica.git
88
+ cd agentica
89
+ pip install .
90
+ ```
91
+
92
+ ## Getting Started
93
+
94
+ #### Run the example
95
+ ```shell
96
+ # Copying required .env file, and fill in the LLM api key
97
+ cp .env.example ~/.agentica/.env
98
+
99
+ cd examples
100
+ python web_search_moonshot_demo.py
101
+ ```
102
+
103
+ 1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填DEEPSEEK_API_KEY、MOONSHOT_API_KEY、OPENAI_API_KEY等任一个即可)。或者使用`export`命令设置环境变量:
104
+
105
+ ```shell
106
+ export MOONSHOT_API_KEY=your_moonshot_api_key
107
+ export SERPER_API_KEY=your_serper_api_key
108
+ ```
109
+
110
+ 2. 使用`agentica`构建Agent并执行:
111
+
112
+ 自动调用google搜索工具,示例[examples/web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/web_search_moonshot_demo.py)
113
+
114
+ ```python
115
+ from agentica import Agent, MoonshotChat, SearchSerperTool
116
+
117
+ m = Agent(model=MoonshotChat(), tools=[SearchSerperTool()], add_datetime_to_instructions=True)
118
+ r = m.run("下一届奥运会在哪里举办")
119
+ print(r)
120
+ ```
121
+
122
+
123
+ ## Web UI
124
+
125
+ [shibing624/ChatPilot](https://github.com/shibing624/ChatPilot) 兼容`agentica`,可以通过Web UI进行交互。
126
+
127
+ Web Demo: https://chat.mulanai.com
128
+
129
+ <img src="https://github.com/shibing624/ChatPilot/blob/main/docs/shot.png" width="800" />
130
+
131
+ ```shell
132
+ git clone https://github.com/shibing624/ChatPilot.git
133
+ cd ChatPilot
134
+ pip install -r requirements.txt
135
+
136
+ cp .env.example .env
137
+
138
+ bash start.sh
139
+ ```
140
+
141
+
142
+ ## Examples
143
+
144
+
145
+ | 示例 | 描述 |
146
+ |-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
147
+ | [examples/01_llm_demo.py](https://github.com/shibing624/agentica/blob/main/examples/01_llm_demo.py) | LLM问答Demo |
148
+ | [examples/02_user_prompt_demo.py](https://github.com/shibing624/agentica/blob/main/examples/02_user_prompt_demo.py) | 自定义用户prompt的Demo |
149
+ | [examples/03_user_messages_demo.py](https://github.com/shibing624/agentica/blob/main/examples/03_user_messages_demo.py) | 自定义输入用户消息的Demo |
150
+ | [examples/04_memory_demo.py](https://github.com/shibing624/agentica/blob/main/examples/04_memory_demo.py) | Agent的记忆Demo |
151
+ | [examples/05_response_model_demo.py](https://github.com/shibing624/agentica/blob/main/examples/05_response_model_demo.py) | 按指定格式(pydantic的BaseModel)回复的Demo |
152
+ | [examples/06_calc_with_csv_file_demo.py](https://github.com/shibing624/agentica/blob/main/examples/06_calc_with_csv_file_demo.py) | LLM加载CSV文件,并执行计算来回答的Demo |
153
+ | [examples/07_create_image_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/07_create_image_tool_demo.py) | 实现了创建图像工具的Demo |
154
+ | [examples/08_ocr_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/08_ocr_tool_demo.py) | 实现了OCR工具的Demo |
155
+ | [examples/09_remove_image_background_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/09_remove_image_background_tool_demo.py) | 实现了自动去除图片背景功能,包括自动通过pip安装库,调用库实现去除图片背景 |
156
+ | [examples/10_vision_demo.py](https://github.com/shibing624/agentica/blob/main/examples/10_vision_demo.py) | 视觉理解Demo |
157
+ | [examples/11_web_search_openai_demo.py](https://github.com/shibing624/agentica/blob/main/examples/11_web_search_openai_demo.py) | 基于OpenAI的function call做网页搜索Demo |
158
+ | [examples/12_web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/12_web_search_moonshot_demo.py) | 基于Moonshot的function call做网页搜索Demo |
159
+ | [examples/13_storage_demo.py](https://github.com/shibing624/agentica/blob/main/examples/13_storage_demo.py) | Agent的存储Demo |
160
+ | [examples/14_custom_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/14_custom_tool_demo.py) | 自定义工具,并用大模型自主选择调用的Demo |
161
+ | [examples/15_crawl_webpage_demo.py](https://github.com/shibing624/agentica/blob/main/examples/15_crawl_webpage_demo.py) | 实现了网页分析工作流:从Url爬取融资快讯 - 分析网页内容和格式 - 提取核心信息 - 汇总存为md文件 |
162
+ | [examples/16_get_top_papers_demo.py](https://github.com/shibing624/agentica/blob/main/examples/16_get_top_papers_demo.py) | 解析每日论文,并保存为json格式的Demo |
163
+ | [examples/17_find_paper_from_arxiv_demo.py](https://github.com/shibing624/agentica/blob/main/examples/17_find_paper_from_arxiv_demo.py) | 实现了论文推荐的Demo:自动从arxiv搜索多组论文 - 相似论文去重 - 提取核心论文信息 - 保存为csv文件 |
164
+ | [examples/18_agent_input_is_list.py](https://github.com/shibing624/agentica/blob/main/examples/18_agent_input_is_list.py) | 展示Agent的message可以是列表的Demo |
165
+ | [examples/19_naive_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/19_naive_rag_demo.py) | 实现了基础版RAG,基于Txt文档回答问题 |
166
+ | [examples/20_advanced_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/20_advanced_rag_demo.py) | 实现了高级版RAG,基于PDF文档回答问题,新增功能:pdf文件解析、query改写,字面+语义多路混合召回,召回排序(rerank) |
167
+ | [examples/21_memorydb_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/21_reference_in_prompt_rag_demo.py) | 把参考资料放到prompt的传统RAG做法的Demo |
168
+ | [examples/22_chat_pdf_app_demo.py](https://github.com/shibing624/agentica/blob/main/examples/22_chat_pdf_app_demo.py) | 对PDF文档做深入对话的Demo |
169
+ | [examples/23_python_agent_memory_demo.py](https://github.com/shibing624/agentica/blob/main/examples/23_python_agent_memory_demo.py) | 实现了带记忆的Code Interpreter功能,自动生成python代码并执行,下次执行时从记忆获取结果 |
170
+ | [examples/24_context_demo.py](https://github.com/shibing624/agentica/blob/main/examples/24_context_demo.py) | 实现了传入上下文进行对话的Demo |
171
+ | [examples/25_tools_with_context_demo.py](https://github.com/shibing624/agentica/blob/main/examples/25_tools_with_context_demo.py) | 工具带上下文传参的Demo |
172
+ | [examples/26_complex_translate_demo.py](https://github.com/shibing624/agentica/blob/main/examples/26_complex_translate_demo.py) | 实现了复杂翻译Demo |
173
+ | [examples/27_research_agent_demo.py](https://github.com/shibing624/agentica/blob/main/examples/27_research_agent_demo.py) | 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告 |
174
+ | [examples/28_rag_integrated_langchain_demo.py](https://github.com/shibing624/agentica/blob/main/examples/28_rag_integrated_langchain_demo.py) | 集成LangChain的RAG Demo |
175
+ | [examples/29_rag_integrated_llamaindex_demo.py](https://github.com/shibing624/agentica/blob/main/examples/29_rag_integrated_llamaindex_demo.py) | 集成LlamaIndex的RAG Demo |
176
+ | [examples/30_text_classification_demo.py](https://github.com/shibing624/agentica/blob/main/examples/30_text_classification_demo.py) | 实现了自动训练分类模型的Agent:读取训练集文件并理解格式 - 谷歌搜索pytextclassifier库 - 爬取github页面了解pytextclassifier的调用方法 - 写代码并执行fasttext模型训练 - check训练好的模型预测结果 |
177
+ | [examples/31_team_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/31_team_news_article_demo.py) | Team实现:写新闻稿的team协作,multi-role实现,委托不用角色完成各自任务:研究员检索分析文章,撰写员根据排版写文章,汇总多角色成果输出结果 |
178
+ | [examples/32_team_debate_demo.py](https://github.com/shibing624/agentica/blob/main/examples/32_team_debate_demo.py) | Team实现:基于委托做双人辩论Demo,特朗普和拜登辩论 |
179
+ | [examples/33_self_evolving_agent_demo.py](https://github.com/shibing624/agentica/blob/main/examples/33_self_evolving_agent_demo.py) | 实现了自我进化Agent的Demo |
180
+ | [examples/34_llm_os_demo.py](https://github.com/shibing624/agentica/blob/main/examples/34_llm_os_demo.py) | 实现了LLM OS的初步设计,基于LLM设计操作系统,可以通过LLM调用RAG、代码执行器、Shell等工具,并协同代码解释器、研究助手、投资助手等来解决问题。 |
181
+ | [examples/35_workflow_investment_demo.py](https://github.com/shibing624/agentica/blob/main/examples/35_workflow_investment_demo.py) | 实现了投资研究的工作流:股票信息收集 - 股票分析 - 撰写分析报告 - 复查报告等多个Task |
182
+ | [examples/36_workflow_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/36_workflow_news_article_demo.py) | 实现了写新闻稿的工作流,multi-agent的实现,多次调用搜索工具,并生成高级排版的新闻文章 |
183
+ | [examples/37_workflow_write_novel_demo.py](https://github.com/shibing624/agentica/blob/main/examples/37_workflow_write_novel_demo.py) | 实现了写小说的工作流:定小说提纲 - 搜索谷歌反思提纲 - 撰写小说内容 - 保存为md文件 |
184
+ | [examples/38_workflow_write_tutorial_demo.py](https://github.com/shibing624/agentica/blob/main/examples/38_workflow_write_tutorial_demo.py) | 实现了写技术教程的工作流:定教程目录 - 反思目录内容 - 撰写教程内容 - 保存为md文件 |
185
+ | [examples/39_audio_multi_turn_demo.py](https://github.com/shibing624/agentica/blob/main/examples/39_audio_multi_turn_demo.py) | 基于openai的语音api做多轮音频对话的Demo |
186
+
187
+
188
+ ### Self-evolving Agent
189
+ The self-evolving agent design:
190
+
191
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/sage_arch.png" width="800" />
192
+
193
+ #### Feature
194
+
195
+ 具有反思和增强记忆能力的自我进化智能体(self-evolving Agents with Reflective and Memory-augmented Abilities, SAGE)
196
+
197
+ 实现方法:
198
+
199
+ 1. 使用PythonAgent作为SAGE智能体,使用AzureOpenAIChat作为LLM, 具备code-interpreter功能,可以执行Python代码,并自动纠错。
200
+ 2. 使用CsvMemoryDb作为SAGE智能体的记忆,用于存储用户的问题和答案,下次遇到相似的问题时,可以直接返回答案。
201
+
202
+ #### Run Self-evolving Agent App
203
+
204
+ ```shell
205
+ cd examples
206
+ streamlit run 33_self_evolving_agent_demo.py
207
+ ```
208
+
209
+ <img alt="sage_snap" src="https://github.com/shibing624/agentica/blob/main/docs/sage_snap.png" width="800" />
210
+
211
+
212
+ ### LLM OS
213
+ The LLM OS design:
214
+
215
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llmos.png" width="800" />
216
+
217
+ #### Run the LLM OS App
218
+
219
+ ```shell
220
+ cd examples
221
+ streamlit run 34_llm_os_demo.py
222
+ ```
223
+
224
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
225
+
226
+ ## Contact
227
+
228
+ - Issue(建议)
229
+ :[![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
230
+ - 邮件我:xuming: xuming624@qq.com
231
+ - 微信我: 加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
232
+
233
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
234
+
235
+ ## Citation
236
+
237
+ 如果你在研究中使用了`agentica`,请按如下格式引用:
238
+
239
+ APA:
240
+
241
+ ```
242
+ Xu, M. agentica: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/agentica
243
+ ```
244
+
245
+ BibTeX:
246
+
247
+ ```
248
+ @misc{Xu_agentica,
249
+ title={agentica: A Human-Centric Framework for Large Language Model Agent Workflows},
250
+ author={Xu Ming},
251
+ year={2024},
252
+ howpublished={\url{https://github.com/shibing624/agentica}},
253
+ }
254
+ ```
255
+
256
+ ## License
257
+
258
+ 授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
259
+ ## Contribute
260
+
261
+ 项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
262
+
263
+ - 在`tests`添加相应的单元测试
264
+ - 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
265
+
266
+ 之后即可提交PR。
267
+
268
+ ## Acknowledgements
269
+
270
+ - [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
271
+ - [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
272
+ - [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)
273
+
274
+
275
+ Thanks for their great work!
@@ -0,0 +1,244 @@
1
+ [**🇨🇳中文**](https://github.com/shibing624/agentica/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/agentica/blob/main/README_EN.md) | [**🇯🇵日本語**](https://github.com/shibing624/agentica/blob/main/README_JP.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. 快速打造你的专属Agent。
22
+
23
+ ## Overview
24
+
25
+ #### LLM Agent
26
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
27
+
28
+ - **规划(Planning)**:任务拆解、生成计划、反思
29
+ - **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
30
+ - **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
31
+
32
+ #### Agentica Assistant Architecture
33
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
34
+
35
+ - **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
36
+ - **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
37
+ - **Solver**:求解器将所有这些输出整合为最终答案
38
+
39
+
40
+ ## Features
41
+ `Agentica`是一个Agent构建工具,功能:
42
+
43
+ - 简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Multi-Role、Workflow等功能
44
+ - Agent支持prompt自定义,支持多种工具调用(tool_calls)
45
+ - 支持OpenAI/Azure/Deepseek/Moonshot/Claude/Ollama/Together API调用
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install -U agentica
51
+ ```
52
+
53
+ or
54
+
55
+ ```bash
56
+ git clone https://github.com/shibing624/agentica.git
57
+ cd agentica
58
+ pip install .
59
+ ```
60
+
61
+ ## Getting Started
62
+
63
+ #### Run the example
64
+ ```shell
65
+ # Copying required .env file, and fill in the LLM api key
66
+ cp .env.example ~/.agentica/.env
67
+
68
+ cd examples
69
+ python web_search_moonshot_demo.py
70
+ ```
71
+
72
+ 1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填DEEPSEEK_API_KEY、MOONSHOT_API_KEY、OPENAI_API_KEY等任一个即可)。或者使用`export`命令设置环境变量:
73
+
74
+ ```shell
75
+ export MOONSHOT_API_KEY=your_moonshot_api_key
76
+ export SERPER_API_KEY=your_serper_api_key
77
+ ```
78
+
79
+ 2. 使用`agentica`构建Agent并执行:
80
+
81
+ 自动调用google搜索工具,示例[examples/web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/web_search_moonshot_demo.py)
82
+
83
+ ```python
84
+ from agentica import Agent, MoonshotChat, SearchSerperTool
85
+
86
+ m = Agent(model=MoonshotChat(), tools=[SearchSerperTool()], add_datetime_to_instructions=True)
87
+ r = m.run("下一届奥运会在哪里举办")
88
+ print(r)
89
+ ```
90
+
91
+
92
+ ## Web UI
93
+
94
+ [shibing624/ChatPilot](https://github.com/shibing624/ChatPilot) 兼容`agentica`,可以通过Web UI进行交互。
95
+
96
+ Web Demo: https://chat.mulanai.com
97
+
98
+ <img src="https://github.com/shibing624/ChatPilot/blob/main/docs/shot.png" width="800" />
99
+
100
+ ```shell
101
+ git clone https://github.com/shibing624/ChatPilot.git
102
+ cd ChatPilot
103
+ pip install -r requirements.txt
104
+
105
+ cp .env.example .env
106
+
107
+ bash start.sh
108
+ ```
109
+
110
+
111
+ ## Examples
112
+
113
+
114
+ | 示例 | 描述 |
115
+ |-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
116
+ | [examples/01_llm_demo.py](https://github.com/shibing624/agentica/blob/main/examples/01_llm_demo.py) | LLM问答Demo |
117
+ | [examples/02_user_prompt_demo.py](https://github.com/shibing624/agentica/blob/main/examples/02_user_prompt_demo.py) | 自定义用户prompt的Demo |
118
+ | [examples/03_user_messages_demo.py](https://github.com/shibing624/agentica/blob/main/examples/03_user_messages_demo.py) | 自定义输入用户消息的Demo |
119
+ | [examples/04_memory_demo.py](https://github.com/shibing624/agentica/blob/main/examples/04_memory_demo.py) | Agent的记忆Demo |
120
+ | [examples/05_response_model_demo.py](https://github.com/shibing624/agentica/blob/main/examples/05_response_model_demo.py) | 按指定格式(pydantic的BaseModel)回复的Demo |
121
+ | [examples/06_calc_with_csv_file_demo.py](https://github.com/shibing624/agentica/blob/main/examples/06_calc_with_csv_file_demo.py) | LLM加载CSV文件,并执行计算来回答的Demo |
122
+ | [examples/07_create_image_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/07_create_image_tool_demo.py) | 实现了创建图像工具的Demo |
123
+ | [examples/08_ocr_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/08_ocr_tool_demo.py) | 实现了OCR工具的Demo |
124
+ | [examples/09_remove_image_background_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/09_remove_image_background_tool_demo.py) | 实现了自动去除图片背景功能,包括自动通过pip安装库,调用库实现去除图片背景 |
125
+ | [examples/10_vision_demo.py](https://github.com/shibing624/agentica/blob/main/examples/10_vision_demo.py) | 视觉理解Demo |
126
+ | [examples/11_web_search_openai_demo.py](https://github.com/shibing624/agentica/blob/main/examples/11_web_search_openai_demo.py) | 基于OpenAI的function call做网页搜索Demo |
127
+ | [examples/12_web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/12_web_search_moonshot_demo.py) | 基于Moonshot的function call做网页搜索Demo |
128
+ | [examples/13_storage_demo.py](https://github.com/shibing624/agentica/blob/main/examples/13_storage_demo.py) | Agent的存储Demo |
129
+ | [examples/14_custom_tool_demo.py](https://github.com/shibing624/agentica/blob/main/examples/14_custom_tool_demo.py) | 自定义工具,并用大模型自主选择调用的Demo |
130
+ | [examples/15_crawl_webpage_demo.py](https://github.com/shibing624/agentica/blob/main/examples/15_crawl_webpage_demo.py) | 实现了网页分析工作流:从Url爬取融资快讯 - 分析网页内容和格式 - 提取核心信息 - 汇总存为md文件 |
131
+ | [examples/16_get_top_papers_demo.py](https://github.com/shibing624/agentica/blob/main/examples/16_get_top_papers_demo.py) | 解析每日论文,并保存为json格式的Demo |
132
+ | [examples/17_find_paper_from_arxiv_demo.py](https://github.com/shibing624/agentica/blob/main/examples/17_find_paper_from_arxiv_demo.py) | 实现了论文推荐的Demo:自动从arxiv搜索多组论文 - 相似论文去重 - 提取核心论文信息 - 保存为csv文件 |
133
+ | [examples/18_agent_input_is_list.py](https://github.com/shibing624/agentica/blob/main/examples/18_agent_input_is_list.py) | 展示Agent的message可以是列表的Demo |
134
+ | [examples/19_naive_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/19_naive_rag_demo.py) | 实现了基础版RAG,基于Txt文档回答问题 |
135
+ | [examples/20_advanced_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/20_advanced_rag_demo.py) | 实现了高级版RAG,基于PDF文档回答问题,新增功能:pdf文件解析、query改写,字面+语义多路混合召回,召回排序(rerank) |
136
+ | [examples/21_memorydb_rag_demo.py](https://github.com/shibing624/agentica/blob/main/examples/21_reference_in_prompt_rag_demo.py) | 把参考资料放到prompt的传统RAG做法的Demo |
137
+ | [examples/22_chat_pdf_app_demo.py](https://github.com/shibing624/agentica/blob/main/examples/22_chat_pdf_app_demo.py) | 对PDF文档做深入对话的Demo |
138
+ | [examples/23_python_agent_memory_demo.py](https://github.com/shibing624/agentica/blob/main/examples/23_python_agent_memory_demo.py) | 实现了带记忆的Code Interpreter功能,自动生成python代码并执行,下次执行时从记忆获取结果 |
139
+ | [examples/24_context_demo.py](https://github.com/shibing624/agentica/blob/main/examples/24_context_demo.py) | 实现了传入上下文进行对话的Demo |
140
+ | [examples/25_tools_with_context_demo.py](https://github.com/shibing624/agentica/blob/main/examples/25_tools_with_context_demo.py) | 工具带上下文传参的Demo |
141
+ | [examples/26_complex_translate_demo.py](https://github.com/shibing624/agentica/blob/main/examples/26_complex_translate_demo.py) | 实现了复杂翻译Demo |
142
+ | [examples/27_research_agent_demo.py](https://github.com/shibing624/agentica/blob/main/examples/27_research_agent_demo.py) | 实现了Research功能,自动调用搜索工具,汇总信息后撰写科技报告 |
143
+ | [examples/28_rag_integrated_langchain_demo.py](https://github.com/shibing624/agentica/blob/main/examples/28_rag_integrated_langchain_demo.py) | 集成LangChain的RAG Demo |
144
+ | [examples/29_rag_integrated_llamaindex_demo.py](https://github.com/shibing624/agentica/blob/main/examples/29_rag_integrated_llamaindex_demo.py) | 集成LlamaIndex的RAG Demo |
145
+ | [examples/30_text_classification_demo.py](https://github.com/shibing624/agentica/blob/main/examples/30_text_classification_demo.py) | 实现了自动训练分类模型的Agent:读取训练集文件并理解格式 - 谷歌搜索pytextclassifier库 - 爬取github页面了解pytextclassifier的调用方法 - 写代码并执行fasttext模型训练 - check训练好的模型预测结果 |
146
+ | [examples/31_team_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/31_team_news_article_demo.py) | Team实现:写新闻稿的team协作,multi-role实现,委托不用角色完成各自任务:研究员检索分析文章,撰写员根据排版写文章,汇总多角色成果输出结果 |
147
+ | [examples/32_team_debate_demo.py](https://github.com/shibing624/agentica/blob/main/examples/32_team_debate_demo.py) | Team实现:基于委托做双人辩论Demo,特朗普和拜登辩论 |
148
+ | [examples/33_self_evolving_agent_demo.py](https://github.com/shibing624/agentica/blob/main/examples/33_self_evolving_agent_demo.py) | 实现了自我进化Agent的Demo |
149
+ | [examples/34_llm_os_demo.py](https://github.com/shibing624/agentica/blob/main/examples/34_llm_os_demo.py) | 实现了LLM OS的初步设计,基于LLM设计操作系统,可以通过LLM调用RAG、代码执行器、Shell等工具,并协同代码解释器、研究助手、投资助手等来解决问题。 |
150
+ | [examples/35_workflow_investment_demo.py](https://github.com/shibing624/agentica/blob/main/examples/35_workflow_investment_demo.py) | 实现了投资研究的工作流:股票信息收集 - 股票分析 - 撰写分析报告 - 复查报告等多个Task |
151
+ | [examples/36_workflow_news_article_demo.py](https://github.com/shibing624/agentica/blob/main/examples/36_workflow_news_article_demo.py) | 实现了写新闻稿的工作流,multi-agent的实现,多次调用搜索工具,并生成高级排版的新闻文章 |
152
+ | [examples/37_workflow_write_novel_demo.py](https://github.com/shibing624/agentica/blob/main/examples/37_workflow_write_novel_demo.py) | 实现了写小说的工作流:定小说提纲 - 搜索谷歌反思提纲 - 撰写小说内容 - 保存为md文件 |
153
+ | [examples/38_workflow_write_tutorial_demo.py](https://github.com/shibing624/agentica/blob/main/examples/38_workflow_write_tutorial_demo.py) | 实现了写技术教程的工作流:定教程目录 - 反思目录内容 - 撰写教程内容 - 保存为md文件 |
154
+ | [examples/39_audio_multi_turn_demo.py](https://github.com/shibing624/agentica/blob/main/examples/39_audio_multi_turn_demo.py) | 基于openai的语音api做多轮音频对话的Demo |
155
+
156
+
157
+ ### Self-evolving Agent
158
+ The self-evolving agent design:
159
+
160
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/sage_arch.png" width="800" />
161
+
162
+ #### Feature
163
+
164
+ 具有反思和增强记忆能力的自我进化智能体(self-evolving Agents with Reflective and Memory-augmented Abilities, SAGE)
165
+
166
+ 实现方法:
167
+
168
+ 1. 使用PythonAgent作为SAGE智能体,使用AzureOpenAIChat作为LLM, 具备code-interpreter功能,可以执行Python代码,并自动纠错。
169
+ 2. 使用CsvMemoryDb作为SAGE智能体的记忆,用于存储用户的问题和答案,下次遇到相似的问题时,可以直接返回答案。
170
+
171
+ #### Run Self-evolving Agent App
172
+
173
+ ```shell
174
+ cd examples
175
+ streamlit run 33_self_evolving_agent_demo.py
176
+ ```
177
+
178
+ <img alt="sage_snap" src="https://github.com/shibing624/agentica/blob/main/docs/sage_snap.png" width="800" />
179
+
180
+
181
+ ### LLM OS
182
+ The LLM OS design:
183
+
184
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llmos.png" width="800" />
185
+
186
+ #### Run the LLM OS App
187
+
188
+ ```shell
189
+ cd examples
190
+ streamlit run 34_llm_os_demo.py
191
+ ```
192
+
193
+ <img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
194
+
195
+ ## Contact
196
+
197
+ - Issue(建议)
198
+ :[![GitHub issues](https://img.shields.io/github/issues/shibing624/agentica.svg)](https://github.com/shibing624/agentica/issues)
199
+ - 邮件我:xuming: xuming624@qq.com
200
+ - 微信我: 加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
201
+
202
+ <img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
203
+
204
+ ## Citation
205
+
206
+ 如果你在研究中使用了`agentica`,请按如下格式引用:
207
+
208
+ APA:
209
+
210
+ ```
211
+ Xu, M. agentica: A Human-Centric Framework for Large Language Model Agent Workflows (Version 0.0.2) [Computer software]. https://github.com/shibing624/agentica
212
+ ```
213
+
214
+ BibTeX:
215
+
216
+ ```
217
+ @misc{Xu_agentica,
218
+ title={agentica: A Human-Centric Framework for Large Language Model Agent Workflows},
219
+ author={Xu Ming},
220
+ year={2024},
221
+ howpublished={\url{https://github.com/shibing624/agentica}},
222
+ }
223
+ ```
224
+
225
+ ## License
226
+
227
+ 授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
228
+ ## Contribute
229
+
230
+ 项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
231
+
232
+ - 在`tests`添加相应的单元测试
233
+ - 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
234
+
235
+ 之后即可提交PR。
236
+
237
+ ## Acknowledgements
238
+
239
+ - [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
240
+ - [https://github.com/simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
241
+ - [https://github.com/phidatahq/phidata](https://github.com/phidatahq/phidata)
242
+
243
+
244
+ Thanks for their great work!
@@ -0,0 +1,91 @@
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 (
8
+ AGENTICA_HOME,
9
+ AGENTICA_DOTENV_PATH,
10
+ AGENTICA_LOG_LEVEL,
11
+ AGENTICA_LOG_FILE,
12
+ ) # noqa, isort: skip
13
+ from agentica.utils.log import set_log_level_to_debug, logger
14
+ from agentica.utils.io import write_audio_to_file
15
+ # model
16
+ from agentica.model.openai.chat import OpenAIChat
17
+ from agentica.model.azure.openai_chat import AzureOpenAIChat
18
+ from agentica.model.moonshot import MoonshotChat
19
+ from agentica.model.deepseek.chat import DeepSeekChat
20
+ from agentica.model.doubao.chat import DoubaoChat
21
+ from agentica.model.together.togetherchat import TogetherChat
22
+ from agentica.model.xai.grok import GrokChat
23
+ from agentica.model.yi.chat import YiChat
24
+
25
+ # memory
26
+ from agentica.model.base import Model, Message
27
+ from agentica.memory import (
28
+ Memory,
29
+ MemoryRetrieval,
30
+ MemoryClassifier,
31
+ MemoryManager,
32
+ AgentMemory,
33
+ WorkflowMemory,
34
+ )
35
+ from agentica.memorydb import MemoryDb, CsvMemoryDb, InMemoryDb, SqliteMemoryDb, PgMemoryDb, MemoryRow
36
+ from agentica.template import PromptTemplate
37
+ # rag
38
+ from agentica.run_response import (
39
+ RunResponse,
40
+ RunEvent,
41
+ RunResponseExtraData,
42
+ pprint_run_response,
43
+ )
44
+ from agentica.knowledge.base import Knowledge
45
+ from agentica.document import Document
46
+ # vectordb
47
+ from agentica.vectordb.base import SearchType, Distance, VectorDb
48
+ from agentica.vectordb.memory_vectordb import MemoryVectorDb
49
+ # emb
50
+ from agentica.emb.base import Emb
51
+ from agentica.emb.openai_emb import OpenAIEmb
52
+ from agentica.emb.azure_openai_emb import AzureOpenAIEmb
53
+ from agentica.emb.hash_emb import HashEmb
54
+ from agentica.emb.ollama_emb import OllamaEmb
55
+ from agentica.emb.together_emb import TogetherEmb
56
+ from agentica.emb.fireworks_emb import FireworksEmb
57
+
58
+ # file
59
+ from agentica.file.base import File
60
+ from agentica.file.csv import CsvFile
61
+ from agentica.file.txt import TextFile
62
+
63
+ # storage
64
+ from agentica.storage.agent.base import AgentStorage
65
+ from agentica.storage.agent.postgres import PgAgentStorage
66
+ from agentica.storage.agent.sqlite import SqlAgentStorage
67
+ from agentica.storage.agent.json_file import JsonFileAgentStorage
68
+ from agentica.storage.agent.yaml_file import YamlFileAgentStorage
69
+ from agentica.storage.workflow.base import WorkflowStorage
70
+ from agentica.storage.workflow.sqlite import SqlWorkflowStorage
71
+ from agentica.storage.workflow.postgres import PgWorkflowStorage
72
+
73
+ # tool
74
+ from agentica.tools.base import Tool, Toolkit, Function, FunctionCall
75
+ from agentica.tools.search_serper_tool import SearchSerperTool
76
+ from agentica.tools.run_python_code_tool import RunPythonCodeTool
77
+ from agentica.tools.analyze_image_tool import AnalyzeImageTool
78
+ from agentica.tools.calculator_tool import CalculatorTool
79
+ from agentica.tools.create_image_tool import CreateImageTool
80
+ from agentica.tools.file_tool import FileTool
81
+ from agentica.tools.hackernews_tool import HackerNewsTool
82
+ from agentica.tools.jina_tool import JinaTool
83
+ from agentica.tools.shell_tool import ShellTool
84
+ from agentica.tools.text_analysis_tool import TextAnalysisTool
85
+
86
+ # agent
87
+ from agentica.agent import Agent
88
+ from agentica.agent_session import AgentSession
89
+ from agentica.python_agent import PythonAgent
90
+ from agentica.workflow import Workflow
91
+ from agentica.workflow_session import WorkflowSession