agentica 0.2.3__tar.gz → 1.0.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.
- {agentica-0.2.3 → agentica-1.0.0}/PKG-INFO +101 -33
- agentica-0.2.3/agentica.egg-info/PKG-INFO → agentica-1.0.0/README.md +83 -61
- {agentica-0.2.3 → agentica-1.0.0}/agentica/__init__.py +24 -7
- {agentica-0.2.3 → agentica-1.0.0}/agentica/agent.py +26 -52
- agentica-1.0.0/agentica/cli.py +151 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/config.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/azure_openai_emb.py +4 -3
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/base.py +3 -5
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/fireworks_emb.py +2 -0
- agentica-1.0.0/agentica/emb/genimi_emb.py +88 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/hash_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/huggingface_emb.py +9 -8
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/ollama_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/openai_emb.py +4 -1
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/sentence_transformer_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/text2vec_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/together_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/word2vec_emb.py +7 -5
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/zhipuai_emb.py +2 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/file/base.py +5 -4
- {agentica-0.2.3 → agentica-1.0.0}/agentica/file/csv.py +4 -2
- {agentica-0.2.3 → agentica-1.0.0}/agentica/file/txt.py +4 -2
- agentica-1.0.0/agentica/mcp/__init__.py +20 -0
- agentica-1.0.0/agentica/mcp/client.py +160 -0
- agentica-1.0.0/agentica/mcp/server.py +293 -0
- agentica-1.0.0/agentica/media.py +259 -0
- agentica-1.0.0/agentica/model/cohere/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/cohere/chat.py +1 -1
- agentica-1.0.0/agentica/model/deepseek/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/deepseek/chat.py +2 -2
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/doubao/chat.py +2 -2
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/fireworks/fireworks.py +0 -17
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/message.py +39 -3
- agentica-1.0.0/agentica/model/moonshot/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/moonshot/chat.py +2 -2
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/nvidia/chat.py +1 -1
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/openai/chat.py +18 -2
- agentica-1.0.0/agentica/model/qwen/chat.py +24 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/response.py +2 -0
- agentica-1.0.0/agentica/model/together/__init__.py +1 -0
- agentica-0.2.3/agentica/model/together/togetherchat.py → agentica-1.0.0/agentica/model/together/together.py +1 -1
- agentica-1.0.0/agentica/model/xai/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/xai/grok.py +2 -2
- agentica-1.0.0/agentica/model/yi/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/yi/chat.py +2 -2
- agentica-1.0.0/agentica/model/zhipuai/__init__.py +1 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/zhipuai/chat.py +2 -2
- {agentica-0.2.3 → agentica-1.0.0}/agentica/react_agent.py +1 -1
- agentica-1.0.0/agentica/storage/__init__.py +0 -0
- agentica-1.0.0/agentica/tools/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/base.py +9 -4
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/jina_tool.py +1 -9
- agentica-1.0.0/agentica/tools/mcp_tool.py +375 -0
- agentica-1.0.0/agentica/tools/weather_tool.py +47 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/json_util.py +3 -3
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/log.py +19 -0
- agentica-1.0.0/agentica/utils/message.py +43 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/misc.py +11 -42
- agentica-1.0.0/agentica/utils/string.py +73 -0
- agentica-1.0.0/agentica/version.py +1 -0
- agentica-0.2.3/README.md → agentica-1.0.0/agentica.egg-info/PKG-INFO +129 -30
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/SOURCES.txt +12 -1
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/requires.txt +4 -1
- {agentica-0.2.3 → agentica-1.0.0}/setup.py +4 -1
- agentica-0.2.3/agentica/emb/genimi_emb.py +0 -60
- agentica-0.2.3/agentica/model/cohere/__init__.py +0 -1
- agentica-0.2.3/agentica/model/deepseek/__init__.py +0 -1
- agentica-0.2.3/agentica/model/doubao/__init__.py +0 -1
- agentica-0.2.3/agentica/model/moonshot/__init__.py +0 -1
- agentica-0.2.3/agentica/model/together/__init__.py +0 -1
- agentica-0.2.3/agentica/model/xai/__init__.py +0 -1
- agentica-0.2.3/agentica/model/yi/__init__.py +0 -1
- agentica-0.2.3/agentica/model/zhipuai/__init__.py +0 -1
- agentica-0.2.3/agentica/version.py +0 -1
- {agentica-0.2.3 → agentica-1.0.0}/LICENSE +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/MANIFEST.in +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/agent_session.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/document.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/emb/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/file/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/knowledge/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/knowledge/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/knowledge/langchain_knowledge.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/knowledge/llamaindex_knowledge.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/memory.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/memorydb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/anthropic/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/anthropic/claude.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/aws/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/aws/api_client.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/aws/bedrock.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/aws/claude.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/azure/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/azure/openai_chat.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/content.py +0 -0
- {agentica-0.2.3/agentica/reranker → agentica-1.0.0/agentica/model/doubao}/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/fireworks/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/google/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/google/gemini.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/google/gemini_openai.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/groq/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/groq/groq.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/huggingface/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/huggingface/hf.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/internlm/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/internlm/chat.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/mistral/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/mistral/mistral.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/nvidia/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/ollama/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/ollama/chat.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/ollama/hermes.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/ollama/tools.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/openai/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/openai/like.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/openrouter/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/openrouter/openrouter.py +0 -0
- {agentica-0.2.3/agentica/storage → agentica-1.0.0/agentica/model/qwen}/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/sambanova/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/sambanova/sambanova.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/vertexai/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/model/vertexai/gemini.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/python_agent.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/reasoning.py +0 -0
- {agentica-0.2.3/agentica/tools → agentica-1.0.0/agentica/reranker}/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/reranker/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/reranker/bge.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/reranker/cohere.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/run_response.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/json_file.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/postgres.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/sqlite.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/agent/yaml_file.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/workflow/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/workflow/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/workflow/postgres.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/storage/workflow/sqlite.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/template.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/airflow_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/analyze_image_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/apify_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/arxiv_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/baidusearch_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/calculator_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/cogvideo_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/cogview_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/dalle_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/dblp_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/duckduckgo_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/file_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/hackernews_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/newspaper_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/ocr_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/resend_tools.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/run_nb_code_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/run_python_code_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/search_exa_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/search_serper_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/shell_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/sql_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/string_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/text_analysis_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/url_crawler_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/web_search_pro_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/wikipedia_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/tools/yfinance_tool.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/console.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/file_parser.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/io.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/shell.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/utils/timer.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/__init__.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/base.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/chromadb_vectordb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/lancedb_vectordb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/memory_vectordb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/pgvectordb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/pineconedb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/vectordb/qdrantdb.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/workflow.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica/workflow_session.py +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/dependency_links.txt +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/entry_points.txt +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/not-zip-safe +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/agentica.egg-info/top_level.txt +0 -0
- {agentica-0.2.3 → agentica-1.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: agentica
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: LLM agents
|
5
5
|
Home-page: https://github.com/shibing624/agentica
|
6
6
|
Author: XuMing
|
@@ -18,16 +18,31 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
18
|
Requires-Python: >=3.8.0
|
19
19
|
Description-Content-Type: text/markdown
|
20
20
|
License-File: LICENSE
|
21
|
+
Requires-Dist: httpx
|
21
22
|
Requires-Dist: loguru
|
22
|
-
Requires-Dist:
|
23
|
+
Requires-Dist: beautifulsoup4
|
23
24
|
Requires-Dist: openai
|
24
25
|
Requires-Dist: python-dotenv
|
25
26
|
Requires-Dist: pydantic
|
26
27
|
Requires-Dist: requests
|
27
28
|
Requires-Dist: sqlalchemy
|
28
29
|
Requires-Dist: scikit-learn
|
30
|
+
Requires-Dist: markdownify
|
29
31
|
Requires-Dist: tqdm
|
30
32
|
Requires-Dist: rich
|
33
|
+
Requires-Dist: pyyaml
|
34
|
+
Dynamic: author
|
35
|
+
Dynamic: author-email
|
36
|
+
Dynamic: classifier
|
37
|
+
Dynamic: description
|
38
|
+
Dynamic: description-content-type
|
39
|
+
Dynamic: home-page
|
40
|
+
Dynamic: keywords
|
41
|
+
Dynamic: license
|
42
|
+
Dynamic: license-file
|
43
|
+
Dynamic: requires-dist
|
44
|
+
Dynamic: requires-python
|
45
|
+
Dynamic: summary
|
31
46
|
|
32
47
|
[**🇨🇳中文**](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
48
|
|
@@ -56,26 +71,9 @@ Requires-Dist: rich
|
|
56
71
|
|
57
72
|
**Agentica** 可以构建AI Agent,包括规划、记忆和工具使用、执行等组件。
|
58
73
|
|
59
|
-
#### Agent Components
|
60
|
-
<img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
|
61
|
-
|
62
|
-
- **规划(Planning)**:任务拆解、生成计划、反思
|
63
|
-
- **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
|
64
|
-
- **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
|
65
|
-
|
66
|
-
#### Agentica Workflow
|
67
|
-
|
68
|
-
**Agentica** can also build multi-agent systems and workflows.
|
69
|
-
|
70
|
-
**Agentica** 还可以构建多Agent系统和工作流。
|
71
|
-
|
72
|
-
<img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
|
73
|
-
|
74
|
-
- **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
|
75
|
-
- **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
|
76
|
-
- **Solver**:求解器将所有这些输出整合为最终答案
|
77
|
-
|
78
74
|
## 🔥 News
|
75
|
+
[2025/04/21] v1.0.0版本:支持了`MCP`的工具调用,兼容SSE和Stdio两种MCP Server,详见[Release-v1.0.0](https://github.com/shibing624/agentica/releases/tag/1.0.0)
|
76
|
+
|
79
77
|
[2024/12/29] v0.2.3版本: 支持了`ZhipuAI`的api调用,包括免费模型和工具使用,详见[Release-v0.2.3](https://github.com/shibing624/agentica/releases/tag/0.2.3)
|
80
78
|
|
81
79
|
[2024/12/25] v0.2.0版本: 支持了多模态模型,输入可以是文本、图片、音频、视频,升级Assistant为Agent,Workflow支持拆解并实现复杂任务,详见[Release-v0.2.0](https://github.com/shibing624/agentica/releases/tag/0.2.0)
|
@@ -87,10 +85,10 @@ Requires-Dist: rich
|
|
87
85
|
`Agentica`是一个用于构建Agent的工具,具有以下功能:
|
88
86
|
|
89
87
|
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Team、Workflow等功能
|
90
|
-
-
|
91
|
-
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、
|
92
|
-
-
|
93
|
-
- **Multi-Agent协作**:支持多Agent和任务委托(Team
|
88
|
+
- **工具调用**:支持自定义工具OpenAI的function call,支持MCP Server的工具调用
|
89
|
+
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、Anthropic、ZhipuAI、Ollama、Together等多方大模型厂商的API
|
90
|
+
- **记忆功能**:支持短期记忆和长期记忆功能
|
91
|
+
- **Multi-Agent协作**:支持多Agent和任务委托(Team)的团队协作
|
94
92
|
- **Workflow工作流**:拆解复杂任务为多个Agent,基于工作流自动化串行逐步完成任务,如投资研究、新闻文章撰写和技术教程创建
|
95
93
|
- **自我进化Agent**:具有反思和增强记忆能力的自我进化Agent
|
96
94
|
- **Web UI**:兼容ChatPilot,可以基于Web页面交互,支持主流的open-webui、streamlit、gradio等前端交互框架
|
@@ -117,13 +115,13 @@ pip install .
|
|
117
115
|
cp .env.example ~/.agentica/.env
|
118
116
|
|
119
117
|
cd examples
|
120
|
-
python
|
118
|
+
python 12_web_search_moonshot_demo.py
|
121
119
|
```
|
122
120
|
|
123
|
-
1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填
|
121
|
+
1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填OPENAI_API_KEY、ZHIPUAI_API_KEY 等任一个)。或者使用`export`命令设置环境变量:
|
124
122
|
|
125
123
|
```shell
|
126
|
-
export
|
124
|
+
export ZHIPUAI_API_KEY=your_api_key
|
127
125
|
export SERPER_API_KEY=your_serper_api_key
|
128
126
|
```
|
129
127
|
|
@@ -132,13 +130,23 @@ python web_search_moonshot_demo.py
|
|
132
130
|
自动调用google搜索工具,示例[examples/12_web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/12_web_search_moonshot_demo.py)
|
133
131
|
|
134
132
|
```python
|
135
|
-
from agentica import Agent,
|
133
|
+
from agentica import Agent, Moonshot, WeatherTool
|
136
134
|
|
137
|
-
m = Agent(model=
|
138
|
-
|
139
|
-
print(r)
|
135
|
+
m = Agent(model=Moonshot(), tools=[WeatherTool()], add_datetime_to_instructions=True)
|
136
|
+
m.print_response("明天北京天气咋样")
|
140
137
|
```
|
141
138
|
|
139
|
+
output:
|
140
|
+
```markdown
|
141
|
+
明天北京的天气预报如下:
|
142
|
+
|
143
|
+
- 早晨:晴朗,气温约18°C,风速较小,约为3 km/h。
|
144
|
+
- 中午:晴朗,气温升至23°C,风速6-7 km/h。
|
145
|
+
- 傍晚:晴朗,气温略降至21°C,风速较大,为35-44 km/h。
|
146
|
+
- 夜晚:晴朗转晴,气温下降至15°C,风速32-39 km/h。
|
147
|
+
|
148
|
+
全天无降水,能见度良好。请注意傍晚时分的风速较大,外出时需注意安全。
|
149
|
+
```
|
142
150
|
|
143
151
|
## ▶️ Web UI
|
144
152
|
|
@@ -203,6 +211,9 @@ bash start.sh
|
|
203
211
|
| [examples/37_workflow_write_novel_demo.py](https://github.com/shibing624/agentica/blob/main/examples/37_workflow_write_novel_demo.py) | 实现了写小说的工作流:定小说提纲 - 搜索谷歌反思提纲 - 撰写小说内容 - 保存为md文件 |
|
204
212
|
| [examples/38_workflow_write_tutorial_demo.py](https://github.com/shibing624/agentica/blob/main/examples/38_workflow_write_tutorial_demo.py) | 实现了写技术教程的工作流:定教程目录 - 反思目录内容 - 撰写教程内容 - 保存为md文件 |
|
205
213
|
| [examples/39_audio_multi_turn_demo.py](https://github.com/shibing624/agentica/blob/main/examples/39_audio_multi_turn_demo.py) | 基于openai的语音api做多轮音频对话的Demo |
|
214
|
+
| [examples/40_weather_zhipuai_demo.py](https://github.com/shibing624/agentica/blob/main/examples/40_web_search_zhipuai_demo.py) | 基于智谱AI的api做天气查询的Demo |
|
215
|
+
| [examples/41_mcp_stdio_demo.py](https://github.com/shibing624/agentica/blob/main/examples/41_mcp_stdio_demo.py) | Stdio的MCP Server调用的Demo |
|
216
|
+
| [examples/42_mcp_sse_client.py](https://github.com/shibing624/agentica/blob/main/examples/42_mcp_sse_client.py) | SSE的MCP Server调用的Demo |
|
206
217
|
|
207
218
|
|
208
219
|
### Self-evolving Agent
|
@@ -243,6 +254,63 @@ streamlit run 34_llm_os_demo.py
|
|
243
254
|
|
244
255
|
<img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
|
245
256
|
|
257
|
+
|
258
|
+
### 命令行模式(CLI)
|
259
|
+
|
260
|
+
支持终端命令行快速搭建并体验Agent
|
261
|
+
|
262
|
+
code: [cli.py](https://github.com/shibing624/agentica/blob/main/agentica/cli.py)
|
263
|
+
|
264
|
+
```
|
265
|
+
> agentica -h
|
266
|
+
usage: cli.py [-h] [--query QUERY]
|
267
|
+
[--model_provider {openai,azure,moonshot,zhipuai,deepseek,yi}]
|
268
|
+
[--model_name MODEL_NAME] [--api_base API_BASE]
|
269
|
+
[--api_key API_KEY] [--max_tokens MAX_TOKENS]
|
270
|
+
[--temperature TEMPERATURE] [--verbose VERBOSE]
|
271
|
+
[--tools [{search_serper,file_tool,shell_tool,yfinance_tool,web_search_pro,cogview,cogvideo,jina,wikipedia} ...]]
|
272
|
+
|
273
|
+
CLI for agentica
|
274
|
+
|
275
|
+
options:
|
276
|
+
-h, --help show this help message and exit
|
277
|
+
--query QUERY Question to ask the LLM
|
278
|
+
--model_provider {openai,azure,moonshot,zhipuai,deepseek,yi}
|
279
|
+
LLM model provider
|
280
|
+
--model_name MODEL_NAME
|
281
|
+
LLM model name to use, can be
|
282
|
+
gpt-4o/glm-4-flash/deepseek-chat/yi-lightning/...
|
283
|
+
--api_base API_BASE API base URL for the LLM
|
284
|
+
--api_key API_KEY API key for the LLM
|
285
|
+
--max_tokens MAX_TOKENS
|
286
|
+
Maximum number of tokens for the LLM
|
287
|
+
--temperature TEMPERATURE
|
288
|
+
Temperature for the LLM
|
289
|
+
--verbose VERBOSE enable verbose mode
|
290
|
+
--tools [{search_serper,file_tool,shell_tool,yfinance_tool,web_search_pro,cogview,cogvideo,jina,wikipedia} ...]
|
291
|
+
Tools to enable
|
292
|
+
```
|
293
|
+
|
294
|
+
run:
|
295
|
+
|
296
|
+
```shell
|
297
|
+
pip install agentica -U
|
298
|
+
# 单次调用,填入`--query`参数
|
299
|
+
agentica --query "下一届奥运会在哪里举办" --model_provider zhipuai --model_name glm-4-flash --tools web_search_pro
|
300
|
+
# 多次调用,多轮对话,不填`--query`参数
|
301
|
+
agentica --model_provider zhipuai --model_name glm-4-flash --tools web_search_pro cogview --verbose 1
|
302
|
+
```
|
303
|
+
|
304
|
+
output:
|
305
|
+
```shell
|
306
|
+
2024-12-30 21:59:15,000 - agentica - INFO - Agentica CLI
|
307
|
+
>>> 帮我画个大象在月球上的图
|
308
|
+
|
309
|
+
> 我帮你画了一张大象在月球上的图,它看起来既滑稽又可爱。大象穿着宇航服,站在月球表面,背景是广阔的星空和地球。这张图色彩明亮,细节丰富,具有卡通风格。你可以点击下面的链接查看和下载这张图片:
|
310
|
+
|
311
|
+

|
312
|
+
```
|
313
|
+
|
246
314
|
## ☎️ Contact
|
247
315
|
|
248
316
|
- Issue(建议)
|
@@ -1,34 +1,3 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: agentica
|
3
|
-
Version: 0.2.3
|
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
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)
|
33
2
|
|
34
3
|
<div align="center">
|
@@ -56,26 +25,9 @@ Requires-Dist: rich
|
|
56
25
|
|
57
26
|
**Agentica** 可以构建AI Agent,包括规划、记忆和工具使用、执行等组件。
|
58
27
|
|
59
|
-
#### Agent Components
|
60
|
-
<img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
|
61
|
-
|
62
|
-
- **规划(Planning)**:任务拆解、生成计划、反思
|
63
|
-
- **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
|
64
|
-
- **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
|
65
|
-
|
66
|
-
#### Agentica Workflow
|
67
|
-
|
68
|
-
**Agentica** can also build multi-agent systems and workflows.
|
69
|
-
|
70
|
-
**Agentica** 还可以构建多Agent系统和工作流。
|
71
|
-
|
72
|
-
<img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
|
73
|
-
|
74
|
-
- **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
|
75
|
-
- **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
|
76
|
-
- **Solver**:求解器将所有这些输出整合为最终答案
|
77
|
-
|
78
28
|
## 🔥 News
|
29
|
+
[2025/04/21] v1.0.0版本:支持了`MCP`的工具调用,兼容SSE和Stdio两种MCP Server,详见[Release-v1.0.0](https://github.com/shibing624/agentica/releases/tag/1.0.0)
|
30
|
+
|
79
31
|
[2024/12/29] v0.2.3版本: 支持了`ZhipuAI`的api调用,包括免费模型和工具使用,详见[Release-v0.2.3](https://github.com/shibing624/agentica/releases/tag/0.2.3)
|
80
32
|
|
81
33
|
[2024/12/25] v0.2.0版本: 支持了多模态模型,输入可以是文本、图片、音频、视频,升级Assistant为Agent,Workflow支持拆解并实现复杂任务,详见[Release-v0.2.0](https://github.com/shibing624/agentica/releases/tag/0.2.0)
|
@@ -87,10 +39,10 @@ Requires-Dist: rich
|
|
87
39
|
`Agentica`是一个用于构建Agent的工具,具有以下功能:
|
88
40
|
|
89
41
|
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Team、Workflow等功能
|
90
|
-
-
|
91
|
-
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、
|
92
|
-
-
|
93
|
-
- **Multi-Agent协作**:支持多Agent和任务委托(Team
|
42
|
+
- **工具调用**:支持自定义工具OpenAI的function call,支持MCP Server的工具调用
|
43
|
+
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、Anthropic、ZhipuAI、Ollama、Together等多方大模型厂商的API
|
44
|
+
- **记忆功能**:支持短期记忆和长期记忆功能
|
45
|
+
- **Multi-Agent协作**:支持多Agent和任务委托(Team)的团队协作
|
94
46
|
- **Workflow工作流**:拆解复杂任务为多个Agent,基于工作流自动化串行逐步完成任务,如投资研究、新闻文章撰写和技术教程创建
|
95
47
|
- **自我进化Agent**:具有反思和增强记忆能力的自我进化Agent
|
96
48
|
- **Web UI**:兼容ChatPilot,可以基于Web页面交互,支持主流的open-webui、streamlit、gradio等前端交互框架
|
@@ -117,13 +69,13 @@ pip install .
|
|
117
69
|
cp .env.example ~/.agentica/.env
|
118
70
|
|
119
71
|
cd examples
|
120
|
-
python
|
72
|
+
python 12_web_search_moonshot_demo.py
|
121
73
|
```
|
122
74
|
|
123
|
-
1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填
|
75
|
+
1. 复制[.env.example](https://github.com/shibing624/agentica/blob/main/.env.example)文件为`~/.agentica/.env`,并填写LLM api key(选填OPENAI_API_KEY、ZHIPUAI_API_KEY 等任一个)。或者使用`export`命令设置环境变量:
|
124
76
|
|
125
77
|
```shell
|
126
|
-
export
|
78
|
+
export ZHIPUAI_API_KEY=your_api_key
|
127
79
|
export SERPER_API_KEY=your_serper_api_key
|
128
80
|
```
|
129
81
|
|
@@ -132,13 +84,23 @@ python web_search_moonshot_demo.py
|
|
132
84
|
自动调用google搜索工具,示例[examples/12_web_search_moonshot_demo.py](https://github.com/shibing624/agentica/blob/main/examples/12_web_search_moonshot_demo.py)
|
133
85
|
|
134
86
|
```python
|
135
|
-
from agentica import Agent,
|
87
|
+
from agentica import Agent, Moonshot, WeatherTool
|
136
88
|
|
137
|
-
m = Agent(model=
|
138
|
-
|
139
|
-
print(r)
|
89
|
+
m = Agent(model=Moonshot(), tools=[WeatherTool()], add_datetime_to_instructions=True)
|
90
|
+
m.print_response("明天北京天气咋样")
|
140
91
|
```
|
141
92
|
|
93
|
+
output:
|
94
|
+
```markdown
|
95
|
+
明天北京的天气预报如下:
|
96
|
+
|
97
|
+
- 早晨:晴朗,气温约18°C,风速较小,约为3 km/h。
|
98
|
+
- 中午:晴朗,气温升至23°C,风速6-7 km/h。
|
99
|
+
- 傍晚:晴朗,气温略降至21°C,风速较大,为35-44 km/h。
|
100
|
+
- 夜晚:晴朗转晴,气温下降至15°C,风速32-39 km/h。
|
101
|
+
|
102
|
+
全天无降水,能见度良好。请注意傍晚时分的风速较大,外出时需注意安全。
|
103
|
+
```
|
142
104
|
|
143
105
|
## ▶️ Web UI
|
144
106
|
|
@@ -203,6 +165,9 @@ bash start.sh
|
|
203
165
|
| [examples/37_workflow_write_novel_demo.py](https://github.com/shibing624/agentica/blob/main/examples/37_workflow_write_novel_demo.py) | 实现了写小说的工作流:定小说提纲 - 搜索谷歌反思提纲 - 撰写小说内容 - 保存为md文件 |
|
204
166
|
| [examples/38_workflow_write_tutorial_demo.py](https://github.com/shibing624/agentica/blob/main/examples/38_workflow_write_tutorial_demo.py) | 实现了写技术教程的工作流:定教程目录 - 反思目录内容 - 撰写教程内容 - 保存为md文件 |
|
205
167
|
| [examples/39_audio_multi_turn_demo.py](https://github.com/shibing624/agentica/blob/main/examples/39_audio_multi_turn_demo.py) | 基于openai的语音api做多轮音频对话的Demo |
|
168
|
+
| [examples/40_weather_zhipuai_demo.py](https://github.com/shibing624/agentica/blob/main/examples/40_web_search_zhipuai_demo.py) | 基于智谱AI的api做天气查询的Demo |
|
169
|
+
| [examples/41_mcp_stdio_demo.py](https://github.com/shibing624/agentica/blob/main/examples/41_mcp_stdio_demo.py) | Stdio的MCP Server调用的Demo |
|
170
|
+
| [examples/42_mcp_sse_client.py](https://github.com/shibing624/agentica/blob/main/examples/42_mcp_sse_client.py) | SSE的MCP Server调用的Demo |
|
206
171
|
|
207
172
|
|
208
173
|
### Self-evolving Agent
|
@@ -243,6 +208,63 @@ streamlit run 34_llm_os_demo.py
|
|
243
208
|
|
244
209
|
<img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
|
245
210
|
|
211
|
+
|
212
|
+
### 命令行模式(CLI)
|
213
|
+
|
214
|
+
支持终端命令行快速搭建并体验Agent
|
215
|
+
|
216
|
+
code: [cli.py](https://github.com/shibing624/agentica/blob/main/agentica/cli.py)
|
217
|
+
|
218
|
+
```
|
219
|
+
> agentica -h
|
220
|
+
usage: cli.py [-h] [--query QUERY]
|
221
|
+
[--model_provider {openai,azure,moonshot,zhipuai,deepseek,yi}]
|
222
|
+
[--model_name MODEL_NAME] [--api_base API_BASE]
|
223
|
+
[--api_key API_KEY] [--max_tokens MAX_TOKENS]
|
224
|
+
[--temperature TEMPERATURE] [--verbose VERBOSE]
|
225
|
+
[--tools [{search_serper,file_tool,shell_tool,yfinance_tool,web_search_pro,cogview,cogvideo,jina,wikipedia} ...]]
|
226
|
+
|
227
|
+
CLI for agentica
|
228
|
+
|
229
|
+
options:
|
230
|
+
-h, --help show this help message and exit
|
231
|
+
--query QUERY Question to ask the LLM
|
232
|
+
--model_provider {openai,azure,moonshot,zhipuai,deepseek,yi}
|
233
|
+
LLM model provider
|
234
|
+
--model_name MODEL_NAME
|
235
|
+
LLM model name to use, can be
|
236
|
+
gpt-4o/glm-4-flash/deepseek-chat/yi-lightning/...
|
237
|
+
--api_base API_BASE API base URL for the LLM
|
238
|
+
--api_key API_KEY API key for the LLM
|
239
|
+
--max_tokens MAX_TOKENS
|
240
|
+
Maximum number of tokens for the LLM
|
241
|
+
--temperature TEMPERATURE
|
242
|
+
Temperature for the LLM
|
243
|
+
--verbose VERBOSE enable verbose mode
|
244
|
+
--tools [{search_serper,file_tool,shell_tool,yfinance_tool,web_search_pro,cogview,cogvideo,jina,wikipedia} ...]
|
245
|
+
Tools to enable
|
246
|
+
```
|
247
|
+
|
248
|
+
run:
|
249
|
+
|
250
|
+
```shell
|
251
|
+
pip install agentica -U
|
252
|
+
# 单次调用,填入`--query`参数
|
253
|
+
agentica --query "下一届奥运会在哪里举办" --model_provider zhipuai --model_name glm-4-flash --tools web_search_pro
|
254
|
+
# 多次调用,多轮对话,不填`--query`参数
|
255
|
+
agentica --model_provider zhipuai --model_name glm-4-flash --tools web_search_pro cogview --verbose 1
|
256
|
+
```
|
257
|
+
|
258
|
+
output:
|
259
|
+
```shell
|
260
|
+
2024-12-30 21:59:15,000 - agentica - INFO - Agentica CLI
|
261
|
+
>>> 帮我画个大象在月球上的图
|
262
|
+
|
263
|
+
> 我帮你画了一张大象在月球上的图,它看起来既滑稽又可爱。大象穿着宇航服,站在月球表面,背景是广阔的星空和地球。这张图色彩明亮,细节丰富,具有卡通风格。你可以点击下面的链接查看和下载这张图片:
|
264
|
+
|
265
|
+

|
266
|
+
```
|
267
|
+
|
246
268
|
## ☎️ Contact
|
247
269
|
|
248
270
|
- Issue(建议)
|
@@ -14,14 +14,30 @@ from agentica.utils.log import set_log_level_to_debug, logger
|
|
14
14
|
from agentica.utils.io import write_audio_to_file
|
15
15
|
# model
|
16
16
|
from agentica.model.openai.chat import OpenAIChat
|
17
|
+
from agentica.model.openai.chat import OpenAIChat as OpenAILLM
|
18
|
+
from agentica.model.openai.like import OpenAILike
|
17
19
|
from agentica.model.azure.openai_chat import AzureOpenAIChat
|
18
|
-
from agentica.model.
|
19
|
-
from agentica.model.
|
20
|
-
from agentica.model.
|
21
|
-
from agentica.model.
|
22
|
-
from agentica.model.
|
23
|
-
from agentica.model.
|
24
|
-
from agentica.model.
|
20
|
+
from agentica.model.azure.openai_chat import AzureOpenAIChat as AzureOpenAILLM
|
21
|
+
from agentica.model.moonshot import Moonshot
|
22
|
+
from agentica.model.moonshot import Moonshot as MoonshotChat
|
23
|
+
from agentica.model.moonshot import Moonshot as MoonshotLLM
|
24
|
+
from agentica.model.deepseek.chat import DeepSeek
|
25
|
+
from agentica.model.deepseek.chat import DeepSeek as DeepSeekChat
|
26
|
+
from agentica.model.deepseek.chat import DeepSeek as DeepSeekLLM
|
27
|
+
from agentica.model.doubao.chat import Doubao
|
28
|
+
from agentica.model.doubao.chat import Doubao as DoubaoChat
|
29
|
+
from agentica.model.together.together import Together
|
30
|
+
from agentica.model.together.together import Together as TogetherChat
|
31
|
+
from agentica.model.together.together import Together as TogetherLLM
|
32
|
+
from agentica.model.xai.grok import Grok
|
33
|
+
from agentica.model.xai.grok import Grok as GrokChat
|
34
|
+
from agentica.model.yi.chat import Yi
|
35
|
+
from agentica.model.yi.chat import Yi as YiChat
|
36
|
+
from agentica.model.yi.chat import Yi as YiLLM
|
37
|
+
from agentica.model.qwen.chat import Qwen
|
38
|
+
from agentica.model.zhipuai.chat import ZhipuAI
|
39
|
+
from agentica.model.zhipuai.chat import ZhipuAI as ZhipuAIChat
|
40
|
+
from agentica.model.zhipuai.chat import ZhipuAI as ZhipuAILLM
|
25
41
|
|
26
42
|
# memory
|
27
43
|
from agentica.model.base import Model
|
@@ -102,6 +118,7 @@ from agentica.tools.hackernews_tool import HackerNewsTool
|
|
102
118
|
from agentica.tools.jina_tool import JinaTool
|
103
119
|
from agentica.tools.shell_tool import ShellTool
|
104
120
|
from agentica.tools.text_analysis_tool import TextAnalysisTool
|
121
|
+
from agentica.tools.weather_tool import WeatherTool
|
105
122
|
|
106
123
|
# agent
|
107
124
|
from agentica.agent import Agent
|
@@ -7,6 +7,7 @@ part of the code from https://github.com/phidatahq/phidata
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
9
|
import json
|
10
|
+
import os
|
10
11
|
from datetime import datetime
|
11
12
|
from textwrap import dedent
|
12
13
|
from collections import defaultdict, deque
|
@@ -30,6 +31,7 @@ from uuid import uuid4
|
|
30
31
|
from pathlib import Path
|
31
32
|
from pydantic import BaseModel, ConfigDict, field_validator, Field, ValidationError
|
32
33
|
|
34
|
+
from agentica.utils.log import logger, set_log_level_to_debug, set_log_level_to_info
|
33
35
|
from agentica.document import Document
|
34
36
|
from agentica.knowledge.base import Knowledge
|
35
37
|
from agentica.model.openai import OpenAIChat
|
@@ -44,10 +46,11 @@ from agentica.reasoning import ReasoningStep, ReasoningSteps, NextAction
|
|
44
46
|
from agentica.run_response import RunEvent, RunResponse, RunResponseExtraData
|
45
47
|
from agentica.memory import AgentMemory, Memory, AgentRun, SessionSummary
|
46
48
|
from agentica.storage.agent.base import AgentStorage
|
47
|
-
from agentica.utils.
|
48
|
-
from agentica.utils.misc import get_text_from_message
|
49
|
+
from agentica.utils.message import get_text_from_message
|
49
50
|
from agentica.utils.timer import Timer
|
50
51
|
from agentica.agent_session import AgentSession
|
52
|
+
from agentica.media import AudioResponse
|
53
|
+
from agentica.utils.string import parse_structured_output
|
51
54
|
|
52
55
|
|
53
56
|
class Agent(BaseModel):
|
@@ -200,9 +203,6 @@ class Agent(BaseModel):
|
|
200
203
|
add_datetime_to_instructions: bool = False
|
201
204
|
|
202
205
|
# -*- User Prompt Settings
|
203
|
-
# User prompt: provide the user prompt as a string
|
204
|
-
# Note: this will ignore the message sent to the run function
|
205
|
-
user_prompt: Optional[Union[List, Dict, str, Callable]] = None
|
206
206
|
# User prompt template: provide the user prompt as a PromptTemplate
|
207
207
|
user_prompt_template: Optional[PromptTemplate] = None
|
208
208
|
# If True, build a default user prompt using references and chat history
|
@@ -234,7 +234,7 @@ class Agent(BaseModel):
|
|
234
234
|
team_response_separator: str = "\n"
|
235
235
|
|
236
236
|
# debug_mode=True enables debug logs
|
237
|
-
debug_mode: bool = Field(False, validate_default=True)
|
237
|
+
debug_mode: bool = Field(False, validate_default=True, alias="debug")
|
238
238
|
# monitoring=True logs Agent information
|
239
239
|
monitoring: bool = False
|
240
240
|
|
@@ -252,6 +252,15 @@ class Agent(BaseModel):
|
|
252
252
|
|
253
253
|
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="allow")
|
254
254
|
|
255
|
+
@field_validator("debug_mode", mode="before")
|
256
|
+
def set_log_level(cls, v: bool) -> bool:
|
257
|
+
if v:
|
258
|
+
set_log_level_to_debug()
|
259
|
+
logger.debug("Debug logs enabled")
|
260
|
+
elif v is False:
|
261
|
+
set_log_level_to_info()
|
262
|
+
return v
|
263
|
+
|
255
264
|
@field_validator("agent_id", mode="before")
|
256
265
|
def set_agent_id(cls, v: Optional[str]) -> str:
|
257
266
|
agent_id = v or str(uuid4())
|
@@ -264,13 +273,6 @@ class Agent(BaseModel):
|
|
264
273
|
logger.debug(f"*********** Session ID: {session_id} ***********")
|
265
274
|
return session_id
|
266
275
|
|
267
|
-
@field_validator("debug_mode", mode="before")
|
268
|
-
def set_log_level(cls, v: bool) -> bool:
|
269
|
-
if v:
|
270
|
-
set_log_level_to_debug()
|
271
|
-
logger.debug("Debug logs enabled")
|
272
|
-
return v
|
273
|
-
|
274
276
|
@property
|
275
277
|
def is_streamable(self) -> bool:
|
276
278
|
"""Determines if the response from the Model is streamable
|
@@ -1126,14 +1128,14 @@ class Agent(BaseModel):
|
|
1126
1128
|
) -> Optional[Message]:
|
1127
1129
|
"""Return the user message for the Agent.
|
1128
1130
|
|
1129
|
-
1.
|
1131
|
+
1. Get references.
|
1130
1132
|
2. If the user_prompt_template is provided, build the user_message using the template.
|
1131
1133
|
3. If the message is None, return None.
|
1132
1134
|
4. 4. If use_default_user_message is False or If the message is not a string, return the message as is.
|
1133
1135
|
5. If add_references is False or references is None, return the message as is.
|
1134
1136
|
6. Build the default user message for the Agent
|
1135
1137
|
"""
|
1136
|
-
# Get references from the knowledge base to use in the user message
|
1138
|
+
# 1. Get references from the knowledge base to use in the user message
|
1137
1139
|
references = None
|
1138
1140
|
if self.add_references and message and isinstance(message, str):
|
1139
1141
|
retrieval_timer = Timer()
|
@@ -1152,23 +1154,6 @@ class Agent(BaseModel):
|
|
1152
1154
|
retrieval_timer.stop()
|
1153
1155
|
logger.debug(f"Time to get references: {retrieval_timer.elapsed:.4f}s")
|
1154
1156
|
|
1155
|
-
# 1. If the user_prompt is provided, use that.
|
1156
|
-
if self.user_prompt is not None:
|
1157
|
-
user_prompt_content = self.user_prompt
|
1158
|
-
if callable(self.user_prompt):
|
1159
|
-
user_prompt_kwargs = {"agent": self, "message": message, "references": references}
|
1160
|
-
user_prompt_content = self.user_prompt(**user_prompt_kwargs)
|
1161
|
-
if not isinstance(user_prompt_content, str):
|
1162
|
-
raise Exception("User prompt must return a string")
|
1163
|
-
return Message(
|
1164
|
-
role=self.user_message_role,
|
1165
|
-
content=user_prompt_content,
|
1166
|
-
audio=audio,
|
1167
|
-
images=images,
|
1168
|
-
videos=videos,
|
1169
|
-
**kwargs,
|
1170
|
-
)
|
1171
|
-
|
1172
1157
|
# 2. If the user_prompt_template is provided, build the user_message using the template.
|
1173
1158
|
if self.user_prompt_template is not None:
|
1174
1159
|
user_prompt_kwargs = {"agent": self, "message": message, "references": references}
|
@@ -1784,6 +1769,11 @@ class Agent(BaseModel):
|
|
1784
1769
|
model_response = ModelResponse(content="")
|
1785
1770
|
for model_response_chunk in self.model.response_stream(messages=messages_for_model):
|
1786
1771
|
if model_response_chunk.event == ModelResponseEvent.assistant_response.value:
|
1772
|
+
if model_response_chunk.reasoning_content is not None:
|
1773
|
+
model_response.content += model_response_chunk.reasoning_content
|
1774
|
+
self.run_response.content = model_response_chunk.reasoning_content
|
1775
|
+
self.run_response.created_at = model_response_chunk.created_at
|
1776
|
+
yield self.run_response
|
1787
1777
|
if model_response_chunk.content is not None and model_response.content is not None:
|
1788
1778
|
model_response.content += model_response_chunk.content
|
1789
1779
|
self.run_response.content = model_response_chunk.content
|
@@ -1991,21 +1981,9 @@ class Agent(BaseModel):
|
|
1991
1981
|
# Otherwise convert the response to the structured format
|
1992
1982
|
if isinstance(run_response.content, str):
|
1993
1983
|
try:
|
1994
|
-
structured_output =
|
1995
|
-
try:
|
1996
|
-
structured_output = self.response_model.model_validate_json(run_response.content)
|
1997
|
-
except ValidationError as exc:
|
1998
|
-
logger.warning(f"Failed to convert response to pydantic model: {exc}")
|
1999
|
-
# Check if response starts with ```json
|
2000
|
-
if run_response.content.startswith("```json"):
|
2001
|
-
run_response.content = run_response.content.replace(
|
2002
|
-
"```json\n", "").replace("\n```", "")
|
2003
|
-
try:
|
2004
|
-
structured_output = self.response_model.model_validate_json(run_response.content)
|
2005
|
-
except ValidationError as exc:
|
2006
|
-
logger.warning(f"Failed to convert response to pydantic model: {exc}")
|
1984
|
+
structured_output = parse_structured_output(run_response.content, self.response_model)
|
2007
1985
|
|
2008
|
-
#
|
1986
|
+
# Update RunResponse
|
2009
1987
|
if structured_output is not None:
|
2010
1988
|
run_response.content = structured_output
|
2011
1989
|
run_response.content_type = self.response_model.__name__
|
@@ -2077,7 +2055,7 @@ class Agent(BaseModel):
|
|
2077
2055
|
self.run_id = str(uuid4())
|
2078
2056
|
self.run_response = RunResponse(run_id=self.run_id, session_id=self.session_id, agent_id=self.agent_id)
|
2079
2057
|
|
2080
|
-
logger.debug(f"***********
|
2058
|
+
logger.debug(f"*********** Agent Run Start: {self.run_response.run_id} ***********")
|
2081
2059
|
|
2082
2060
|
# 1. Update the Model (set defaults, add tools, etc.)
|
2083
2061
|
self.update_model()
|
@@ -2249,10 +2227,7 @@ class Agent(BaseModel):
|
|
2249
2227
|
elif messages is not None:
|
2250
2228
|
self.run_input = [m.to_dict() if isinstance(m, Message) else m for m in messages]
|
2251
2229
|
|
2252
|
-
|
2253
|
-
await self.alog_agent_run()
|
2254
|
-
|
2255
|
-
logger.debug(f"*********** Async Agent Run End: {self.run_response.run_id} ***********")
|
2230
|
+
logger.debug(f"*********** Agent Run End: {self.run_response.run_id} ***********")
|
2256
2231
|
if self.stream_intermediate_steps:
|
2257
2232
|
yield self.generic_run_response(
|
2258
2233
|
content=self.run_response.content,
|
@@ -3091,4 +3066,3 @@ class Agent(BaseModel):
|
|
3091
3066
|
break
|
3092
3067
|
|
3093
3068
|
self.print_response(message=message, stream=stream, markdown=markdown, **kwargs)
|
3094
|
-
|