agentica 0.2.1__tar.gz → 0.2.2__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.2/MANIFEST.in +1 -0
- {agentica-0.2.1 → agentica-0.2.2}/PKG-INFO +33 -19
- {agentica-0.2.1 → agentica-0.2.2}/README.md +32 -18
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/jina_tool.py +0 -1
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/url_crawler_tool.py +20 -6
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/file_parser.py +51 -87
- agentica-0.2.2/agentica/version.py +1 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/PKG-INFO +33 -19
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/SOURCES.txt +2 -8
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/top_level.txt +0 -1
- {agentica-0.2.1 → agentica-0.2.2}/setup.py +4 -1
- agentica-0.2.1/agentica/version.py +0 -1
- agentica-0.2.1/tests/__init__.py +0 -5
- agentica-0.2.1/tests/test_create_image.py +0 -43
- agentica-0.2.1/tests/test_file_reader.py +0 -65
- agentica-0.2.1/tests/test_jina_tool.py +0 -80
- agentica-0.2.1/tests/test_llm.py +0 -34
- agentica-0.2.1/tests/test_run_nb_code.py +0 -119
- agentica-0.2.1/tests/test_url_crawler.py +0 -120
- {agentica-0.2.1 → agentica-0.2.2}/LICENSE +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/agent.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/agent_session.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/config.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/document.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/azure_openai_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/fireworks_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/genimi_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/hash_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/huggingface_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/ollama_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/openai_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/sentence_transformer_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/text2vec_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/together_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/emb/word2vec_emb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/file/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/file/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/file/csv.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/file/txt.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/knowledge/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/knowledge/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/knowledge/langchain_knowledge.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/knowledge/llamaindex_knowledge.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/memory.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/memorydb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/anthropic/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/anthropic/claude.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/aws/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/aws/api_client.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/aws/bedrock.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/aws/claude.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/azure/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/azure/openai_chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/cohere/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/cohere/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/content.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/deepseek/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/deepseek/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/doubao/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/doubao/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/fireworks/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/fireworks/fireworks.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/google/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/google/gemini.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/google/gemini_openai.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/groq/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/groq/groq.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/huggingface/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/huggingface/hf.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/internlm/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/internlm/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/message.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/mistral/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/mistral/mistral.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/moonshot/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/moonshot/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/nvidia/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/nvidia/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/ollama/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/ollama/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/ollama/hermes.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/ollama/tools.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/openai/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/openai/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/openai/like.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/openrouter/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/openrouter/openrouter.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/response.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/sambanova/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/sambanova/sambanova.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/together/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/together/togetherchat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/vertexai/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/vertexai/gemini.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/xai/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/xai/grok.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/yi/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/model/yi/chat.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/python_agent.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/reasoning.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/reranker/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/reranker/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/reranker/bge.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/reranker/cohere.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/run_response.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/json_file.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/postgres.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/sqlite.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/agent/yaml_file.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/workflow/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/workflow/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/workflow/postgres.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/storage/workflow/sqlite.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/template.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/airflow_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/analyze_image_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/apify_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/arxiv_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/baidusearch_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/calculator_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/create_image_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/dblp_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/duckduckgo_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/file_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/hackernews_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/newspaper_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/ocr_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/resend_tools.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/run_nb_code_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/run_python_code_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/search_exa_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/search_serper_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/shell_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/sql_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/text_analysis_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/wikipedia_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/tools/yfinance_tool.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/console.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/io.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/json_util.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/log.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/misc.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/shell.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/utils/timer.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/__init__.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/base.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/chromadb_vectordb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/lancedb_vectordb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/memory_vectordb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/pgvectordb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/pineconedb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/vectordb/qdrantdb.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/workflow.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica/workflow_session.py +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/dependency_links.txt +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/entry_points.txt +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/not-zip-safe +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/agentica.egg-info/requires.txt +0 -0
- {agentica-0.2.1 → agentica-0.2.2}/setup.cfg +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
exclude tests/*
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: agentica
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.2
|
4
4
|
Summary: LLM agents
|
5
5
|
Home-page: https://github.com/shibing624/agentica
|
6
6
|
Author: XuMing
|
@@ -53,36 +53,50 @@ Requires-Dist: rich
|
|
53
53
|
|
54
54
|
**Agentica**: 快速打造智能、能反思、协作的AI Agent。
|
55
55
|
|
56
|
-
##
|
56
|
+
## 📖 Introduction
|
57
57
|
|
58
|
-
|
58
|
+
**Agentica** can build AI agent, which have the components of planning, memory, and tool use.
|
59
|
+
|
60
|
+
**Agentica** 可以构建AI Agent,包括规划、记忆和工具使用、执行等组件。
|
61
|
+
|
62
|
+
#### Agent Components
|
59
63
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
|
60
64
|
|
61
65
|
- **规划(Planning)**:任务拆解、生成计划、反思
|
62
66
|
- **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
|
63
67
|
- **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
|
64
68
|
|
65
|
-
#### Agentica
|
69
|
+
#### Agentica Workflow
|
70
|
+
|
71
|
+
**Agentica** can also build multi-agent systems and workflows.
|
72
|
+
|
73
|
+
**Agentica** 还可以构建多Agent系统和工作流。
|
74
|
+
|
66
75
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
|
67
76
|
|
68
77
|
- **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
|
69
78
|
- **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
|
70
79
|
- **Solver**:求解器将所有这些输出整合为最终答案
|
71
80
|
|
81
|
+
## 🔥 News
|
82
|
+
[2024/12/25] v0.2.0版本: 支持了多模态模型,输入可以是文本、图片、音频、视频,升级Assistant为Agent,Workflow支持拆解并实现复杂任务,详见[Release-v0.2.0](https://github.com/shibing624/agentica/releases/tag/0.2.0)
|
83
|
+
|
84
|
+
[2024/07/02] v0.1.0版本:实现了基于LLM的Assistant,可以快速用function call搭建大语言模型助手,详见[Release-v0.1.0](https://github.com/shibing624/agentica/releases/tag/0.1.0)
|
85
|
+
|
72
86
|
|
73
|
-
## Features
|
87
|
+
## 😊 Features
|
74
88
|
`Agentica`是一个用于构建Agent的工具,具有以下功能:
|
75
89
|
|
76
|
-
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、
|
90
|
+
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Team、Workflow等功能
|
77
91
|
- **自定义prompt**:Agent支持自定义prompt和多种工具调用(tool_calls)
|
78
92
|
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、Claude、Ollama、Together等多方大模型厂商的API
|
79
93
|
- **记忆功能**:包括短期记忆和长期记忆功能
|
80
|
-
- **Multi-Agent协作**:支持多Agent
|
94
|
+
- **Multi-Agent协作**:支持多Agent和任务委托(Team)的团队协作。
|
81
95
|
- **Workflow工作流**:拆解复杂任务为多个Agent,基于工作流自动化串行逐步完成任务,如投资研究、新闻文章撰写和技术教程创建
|
82
96
|
- **自我进化Agent**:具有反思和增强记忆能力的自我进化Agent
|
83
97
|
- **Web UI**:兼容ChatPilot,可以基于Web页面交互,支持主流的open-webui、streamlit、gradio等前端交互框架
|
84
98
|
|
85
|
-
##
|
99
|
+
## 💾 Install
|
86
100
|
|
87
101
|
```bash
|
88
102
|
pip install -U agentica
|
@@ -96,7 +110,7 @@ cd agentica
|
|
96
110
|
pip install .
|
97
111
|
```
|
98
112
|
|
99
|
-
## Getting Started
|
113
|
+
## 🚀 Getting Started
|
100
114
|
|
101
115
|
#### Run the example
|
102
116
|
```shell
|
@@ -127,7 +141,7 @@ print(r)
|
|
127
141
|
```
|
128
142
|
|
129
143
|
|
130
|
-
## Web UI
|
144
|
+
## ▶️ Web UI
|
131
145
|
|
132
146
|
[shibing624/ChatPilot](https://github.com/shibing624/ChatPilot) 兼容`agentica`,可以通过Web UI进行交互。
|
133
147
|
|
@@ -146,7 +160,7 @@ bash start.sh
|
|
146
160
|
```
|
147
161
|
|
148
162
|
|
149
|
-
## Examples
|
163
|
+
## 😀 Examples
|
150
164
|
|
151
165
|
|
152
166
|
| 示例 | 描述 |
|
@@ -230,7 +244,7 @@ streamlit run 34_llm_os_demo.py
|
|
230
244
|
|
231
245
|
<img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
|
232
246
|
|
233
|
-
## Contact
|
247
|
+
## ☎️ Contact
|
234
248
|
|
235
249
|
- Issue(建议)
|
236
250
|
:[](https://github.com/shibing624/agentica/issues)
|
@@ -239,7 +253,7 @@ streamlit run 34_llm_os_demo.py
|
|
239
253
|
|
240
254
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
|
241
255
|
|
242
|
-
## Citation
|
256
|
+
## 😇 Citation
|
243
257
|
|
244
258
|
如果你在研究中使用了`agentica`,请按如下格式引用:
|
245
259
|
|
@@ -260,10 +274,10 @@ BibTeX:
|
|
260
274
|
}
|
261
275
|
```
|
262
276
|
|
263
|
-
## License
|
277
|
+
## ⚠️ License
|
264
278
|
|
265
279
|
授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
|
266
|
-
## Contribute
|
280
|
+
## 😍 Contribute
|
267
281
|
|
268
282
|
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
|
269
283
|
|
@@ -272,11 +286,11 @@ BibTeX:
|
|
272
286
|
|
273
287
|
之后即可提交PR。
|
274
288
|
|
275
|
-
## Acknowledgements
|
289
|
+
## 💕 Acknowledgements
|
276
290
|
|
277
|
-
- [
|
278
|
-
- [
|
279
|
-
- [
|
291
|
+
- [langchain-ai/langchain](https://github.com/langchain-ai/langchain)
|
292
|
+
- [simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
|
293
|
+
- [phidatahq/phidata](https://github.com/phidatahq/phidata)
|
280
294
|
|
281
295
|
|
282
296
|
Thanks for their great work!
|
@@ -22,36 +22,50 @@
|
|
22
22
|
|
23
23
|
**Agentica**: 快速打造智能、能反思、协作的AI Agent。
|
24
24
|
|
25
|
-
##
|
25
|
+
## 📖 Introduction
|
26
26
|
|
27
|
-
|
27
|
+
**Agentica** can build AI agent, which have the components of planning, memory, and tool use.
|
28
|
+
|
29
|
+
**Agentica** 可以构建AI Agent,包括规划、记忆和工具使用、执行等组件。
|
30
|
+
|
31
|
+
#### Agent Components
|
28
32
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/llm_agentv2.png" width="800" />
|
29
33
|
|
30
34
|
- **规划(Planning)**:任务拆解、生成计划、反思
|
31
35
|
- **记忆(Memory)**:短期记忆(prompt实现)、长期记忆(RAG实现)
|
32
36
|
- **工具使用(Tool use)**:function call能力,调用外部API,以获取外部信息,包括当前日期、日历、代码执行能力、对专用信息源的访问等
|
33
37
|
|
34
|
-
#### Agentica
|
38
|
+
#### Agentica Workflow
|
39
|
+
|
40
|
+
**Agentica** can also build multi-agent systems and workflows.
|
41
|
+
|
42
|
+
**Agentica** 还可以构建多Agent系统和工作流。
|
43
|
+
|
35
44
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/agent_arch.png" width="800" />
|
36
45
|
|
37
46
|
- **Planner**:负责让LLM生成一个多步计划来完成复杂任务,生成相互依赖的“链式计划”,定义每一步所依赖的上一步的输出
|
38
47
|
- **Worker**:接受“链式计划”,循环遍历计划中的每个子任务,并调用工具完成任务,可以自动反思纠错以完成任务
|
39
48
|
- **Solver**:求解器将所有这些输出整合为最终答案
|
40
49
|
|
50
|
+
## 🔥 News
|
51
|
+
[2024/12/25] v0.2.0版本: 支持了多模态模型,输入可以是文本、图片、音频、视频,升级Assistant为Agent,Workflow支持拆解并实现复杂任务,详见[Release-v0.2.0](https://github.com/shibing624/agentica/releases/tag/0.2.0)
|
52
|
+
|
53
|
+
[2024/07/02] v0.1.0版本:实现了基于LLM的Assistant,可以快速用function call搭建大语言模型助手,详见[Release-v0.1.0](https://github.com/shibing624/agentica/releases/tag/0.1.0)
|
54
|
+
|
41
55
|
|
42
|
-
## Features
|
56
|
+
## 😊 Features
|
43
57
|
`Agentica`是一个用于构建Agent的工具,具有以下功能:
|
44
58
|
|
45
|
-
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、
|
59
|
+
- **Agent编排**:通过简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Team、Workflow等功能
|
46
60
|
- **自定义prompt**:Agent支持自定义prompt和多种工具调用(tool_calls)
|
47
61
|
- **LLM集成**:支持OpenAI、Azure、Deepseek、Moonshot、Claude、Ollama、Together等多方大模型厂商的API
|
48
62
|
- **记忆功能**:包括短期记忆和长期记忆功能
|
49
|
-
- **Multi-Agent协作**:支持多Agent
|
63
|
+
- **Multi-Agent协作**:支持多Agent和任务委托(Team)的团队协作。
|
50
64
|
- **Workflow工作流**:拆解复杂任务为多个Agent,基于工作流自动化串行逐步完成任务,如投资研究、新闻文章撰写和技术教程创建
|
51
65
|
- **自我进化Agent**:具有反思和增强记忆能力的自我进化Agent
|
52
66
|
- **Web UI**:兼容ChatPilot,可以基于Web页面交互,支持主流的open-webui、streamlit、gradio等前端交互框架
|
53
67
|
|
54
|
-
##
|
68
|
+
## 💾 Install
|
55
69
|
|
56
70
|
```bash
|
57
71
|
pip install -U agentica
|
@@ -65,7 +79,7 @@ cd agentica
|
|
65
79
|
pip install .
|
66
80
|
```
|
67
81
|
|
68
|
-
## Getting Started
|
82
|
+
## 🚀 Getting Started
|
69
83
|
|
70
84
|
#### Run the example
|
71
85
|
```shell
|
@@ -96,7 +110,7 @@ print(r)
|
|
96
110
|
```
|
97
111
|
|
98
112
|
|
99
|
-
## Web UI
|
113
|
+
## ▶️ Web UI
|
100
114
|
|
101
115
|
[shibing624/ChatPilot](https://github.com/shibing624/ChatPilot) 兼容`agentica`,可以通过Web UI进行交互。
|
102
116
|
|
@@ -115,7 +129,7 @@ bash start.sh
|
|
115
129
|
```
|
116
130
|
|
117
131
|
|
118
|
-
## Examples
|
132
|
+
## 😀 Examples
|
119
133
|
|
120
134
|
|
121
135
|
| 示例 | 描述 |
|
@@ -199,7 +213,7 @@ streamlit run 34_llm_os_demo.py
|
|
199
213
|
|
200
214
|
<img alt="LLM OS" src="https://github.com/shibing624/agentica/blob/main/docs/llm_os_snap.png" width="800" />
|
201
215
|
|
202
|
-
## Contact
|
216
|
+
## ☎️ Contact
|
203
217
|
|
204
218
|
- Issue(建议)
|
205
219
|
:[](https://github.com/shibing624/agentica/issues)
|
@@ -208,7 +222,7 @@ streamlit run 34_llm_os_demo.py
|
|
208
222
|
|
209
223
|
<img src="https://github.com/shibing624/agentica/blob/main/docs/wechat.jpeg" width="200" />
|
210
224
|
|
211
|
-
## Citation
|
225
|
+
## 😇 Citation
|
212
226
|
|
213
227
|
如果你在研究中使用了`agentica`,请按如下格式引用:
|
214
228
|
|
@@ -229,10 +243,10 @@ BibTeX:
|
|
229
243
|
}
|
230
244
|
```
|
231
245
|
|
232
|
-
## License
|
246
|
+
## ⚠️ License
|
233
247
|
|
234
248
|
授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加`agentica`的链接和授权协议。
|
235
|
-
## Contribute
|
249
|
+
## 😍 Contribute
|
236
250
|
|
237
251
|
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
|
238
252
|
|
@@ -241,11 +255,11 @@ BibTeX:
|
|
241
255
|
|
242
256
|
之后即可提交PR。
|
243
257
|
|
244
|
-
## Acknowledgements
|
258
|
+
## 💕 Acknowledgements
|
245
259
|
|
246
|
-
- [
|
247
|
-
- [
|
248
|
-
- [
|
260
|
+
- [langchain-ai/langchain](https://github.com/langchain-ai/langchain)
|
261
|
+
- [simonmesmith/agentflow](https://github.com/simonmesmith/agentflow)
|
262
|
+
- [phidatahq/phidata](https://github.com/phidatahq/phidata)
|
249
263
|
|
250
264
|
|
251
265
|
Thanks for their great work!
|
@@ -6,6 +6,7 @@
|
|
6
6
|
import hashlib
|
7
7
|
import os
|
8
8
|
import re
|
9
|
+
import json
|
9
10
|
from urllib.parse import urlparse
|
10
11
|
|
11
12
|
import markdownify
|
@@ -17,9 +18,14 @@ from agentica.utils.log import logger
|
|
17
18
|
|
18
19
|
|
19
20
|
class UrlCrawlerTool(Toolkit):
|
20
|
-
def __init__(
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
base_dir: str = os.path.curdir,
|
24
|
+
max_content_length: int = 8000,
|
25
|
+
):
|
21
26
|
super().__init__(name="url_crawler_tool")
|
22
27
|
self.base_dir = base_dir
|
28
|
+
self.max_content_length = max_content_length
|
23
29
|
self.register(self.url_crawl)
|
24
30
|
|
25
31
|
@staticmethod
|
@@ -67,7 +73,14 @@ class UrlCrawlerTool(Toolkit):
|
|
67
73
|
webpage_text = "# " + title + "\n\n" + webpage_text
|
68
74
|
return webpage_text
|
69
75
|
|
70
|
-
def
|
76
|
+
def _trim_content(self, content: str) -> str:
|
77
|
+
"""Trim to the maximum allowed length."""
|
78
|
+
if len(content) > self.max_content_length:
|
79
|
+
truncated = content[: self.max_content_length]
|
80
|
+
return truncated + "... (content truncated)"
|
81
|
+
return content
|
82
|
+
|
83
|
+
def url_crawl(self, url: str) -> str:
|
71
84
|
"""Crawl a website and return the content of the website as a json string.
|
72
85
|
|
73
86
|
Args:
|
@@ -81,7 +94,7 @@ class UrlCrawlerTool(Toolkit):
|
|
81
94
|
print(url, '\n\n', r)
|
82
95
|
|
83
96
|
Returns:
|
84
|
-
|
97
|
+
str: The content of the website as a json string.
|
85
98
|
"""
|
86
99
|
filename = self._generate_file_name_from_url(url)
|
87
100
|
save_path = os.path.realpath(os.path.join(self.base_dir, filename))
|
@@ -92,7 +105,7 @@ class UrlCrawlerTool(Toolkit):
|
|
92
105
|
headers = {
|
93
106
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
|
94
107
|
}
|
95
|
-
response = requests.get(url, stream=True, headers=headers, timeout=
|
108
|
+
response = requests.get(url, stream=True, headers=headers, timeout=60, verify=False)
|
96
109
|
response.raise_for_status()
|
97
110
|
|
98
111
|
content_type = response.headers.get("content-type", "")
|
@@ -113,10 +126,11 @@ class UrlCrawlerTool(Toolkit):
|
|
113
126
|
logger.debug(f"Failed to crawl: {url}: {e}")
|
114
127
|
crawler_result = {
|
115
128
|
"url": url,
|
116
|
-
"content": content,
|
129
|
+
"content": self._trim_content(content),
|
117
130
|
"save_path": save_path,
|
118
131
|
}
|
119
|
-
|
132
|
+
result = json.dumps(crawler_result, ensure_ascii=False)
|
133
|
+
return result
|
120
134
|
|
121
135
|
|
122
136
|
if __name__ == '__main__':
|
@@ -17,6 +17,7 @@ from agentica.utils.log import logger
|
|
17
17
|
|
18
18
|
|
19
19
|
def read_json_file(path: Path) -> str:
|
20
|
+
"""Read JSON file."""
|
20
21
|
try:
|
21
22
|
if path.suffix == ".jsonl":
|
22
23
|
with path.open("r", encoding="utf-8") as f:
|
@@ -35,6 +36,7 @@ def read_json_file(path: Path) -> str:
|
|
35
36
|
|
36
37
|
|
37
38
|
def read_csv_file(path: Path, row_limit: Optional[int] = None) -> str:
|
39
|
+
"""Read CSV file."""
|
38
40
|
try:
|
39
41
|
with open(path, newline="") as csvfile:
|
40
42
|
reader = csv.DictReader(csvfile)
|
@@ -49,6 +51,7 @@ def read_csv_file(path: Path, row_limit: Optional[int] = None) -> str:
|
|
49
51
|
|
50
52
|
|
51
53
|
def read_txt_file(path: Path) -> str:
|
54
|
+
"""Read text file."""
|
52
55
|
try:
|
53
56
|
return path.read_text("utf-8")
|
54
57
|
except Exception as e:
|
@@ -56,85 +59,59 @@ def read_txt_file(path: Path) -> str:
|
|
56
59
|
return ""
|
57
60
|
|
58
61
|
|
59
|
-
def read_pdf_file(path: Path
|
62
|
+
def read_pdf_file(path: Path) -> str:
|
63
|
+
"""Read PDF file."""
|
60
64
|
try:
|
61
|
-
import
|
62
|
-
except ImportError:
|
63
|
-
raise ImportError("
|
64
|
-
|
65
|
-
if enable_image_ocr:
|
66
|
-
try:
|
67
|
-
import imgocr
|
68
|
-
except ImportError:
|
69
|
-
raise ImportError("use `pip install imgocr`")
|
70
|
-
|
65
|
+
from docling.document_converter import DocumentConverter
|
66
|
+
except (ImportError, ModuleNotFoundError):
|
67
|
+
raise ImportError("`docling` not installed, please install using `pip install docling`")
|
71
68
|
text = ""
|
72
69
|
try:
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if enable_image_ocr:
|
79
|
-
# Read images and perform OCR
|
80
|
-
ocr = imgocr.ImgOcr()
|
81
|
-
for page in reader.pages:
|
82
|
-
for image in page.images:
|
83
|
-
if image is None or not image: # Check if the image data is valid
|
84
|
-
logger.warning(f"Invalid image data: {image}")
|
85
|
-
continue
|
86
|
-
img_array = np.array(image)
|
87
|
-
if img_array.ndim == 3 and img_array.shape[-1] == 4: # Check if the image has an alpha channel
|
88
|
-
img_array = img_array[:, :, :3] # Remove the alpha channel
|
89
|
-
elif img_array.ndim != 3 or img_array.shape[-1] not in [3, 4]:
|
90
|
-
logger.warning(f"Unexpected image shape: {img_array.shape}")
|
91
|
-
continue
|
92
|
-
ocr_result = ocr.ocr(img_array)
|
93
|
-
for result in ocr_result:
|
94
|
-
text += result["text"] + "\n"
|
70
|
+
logger.info(f"Reading: {path}")
|
71
|
+
converter = DocumentConverter()
|
72
|
+
res = converter.convert(path)
|
73
|
+
text = res.document.export_to_markdown()
|
95
74
|
except Exception as e:
|
96
75
|
logger.error(f"Error reading: {path}: {e}")
|
97
76
|
return text
|
98
77
|
|
99
78
|
|
100
|
-
def read_pdf_url(url: str
|
79
|
+
def read_pdf_url(url: str) -> str:
|
80
|
+
"""Read PDF file from URL."""
|
81
|
+
text = ""
|
101
82
|
try:
|
102
|
-
from
|
103
|
-
except ImportError:
|
104
|
-
raise ImportError("`
|
105
|
-
if enable_image_ocr:
|
106
|
-
try:
|
107
|
-
import imgocr
|
108
|
-
except ImportError:
|
109
|
-
raise ImportError("use `pip install imgocr`")
|
83
|
+
from docling.document_converter import DocumentConverter
|
84
|
+
except (ImportError, ModuleNotFoundError):
|
85
|
+
raise ImportError("`docling` not installed, please install using `pip install docling`")
|
110
86
|
try:
|
111
87
|
logger.info(f"Reading: {url}")
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
doc_reader = PdfReader(BytesIO(response.content))
|
116
|
-
ocr_model = imgocr.ImgOcr() if enable_image_ocr else None
|
117
|
-
text_content = ""
|
118
|
-
for num, page in enumerate(doc_reader.pages):
|
119
|
-
page_text = page.extract_text() or ""
|
120
|
-
image_text_list = []
|
121
|
-
if enable_image_ocr:
|
122
|
-
for img_obj in page.images:
|
123
|
-
img_data = img_obj.data
|
124
|
-
# Perform OCR
|
125
|
-
ocr_result = ocr_model.ocr(img_data)
|
126
|
-
if ocr_result:
|
127
|
-
image_text_list += [i.get('text') for i in ocr_result]
|
128
|
-
images_text = "\n".join(image_text_list)
|
129
|
-
content = page_text + "\n" + images_text
|
130
|
-
text_content += content
|
131
|
-
return text_content
|
88
|
+
converter = DocumentConverter()
|
89
|
+
res = converter.convert(url)
|
90
|
+
text = res.document.export_to_markdown()
|
132
91
|
except Exception as e:
|
133
92
|
logger.error(f"Error reading: {url}: {e}")
|
134
|
-
|
93
|
+
return text
|
94
|
+
|
95
|
+
|
96
|
+
def read_docx_file_by_docling(path: Path) -> str:
|
97
|
+
"""Read DOCX file using docling."""
|
98
|
+
text = ""
|
99
|
+
try:
|
100
|
+
from docling.document_converter import DocumentConverter
|
101
|
+
except (ImportError, ModuleNotFoundError):
|
102
|
+
raise ImportError("`docling` not installed, please install using `pip install docling`")
|
103
|
+
try:
|
104
|
+
logger.info(f"Reading: {path}")
|
105
|
+
converter = DocumentConverter()
|
106
|
+
res = converter.convert(path)
|
107
|
+
text = res.document.export_to_markdown()
|
108
|
+
except Exception as e:
|
109
|
+
logger.error(f"Error reading: {path}: {e}")
|
110
|
+
return text
|
135
111
|
|
136
112
|
|
137
113
|
def read_docx_file(path: Path) -> str:
|
114
|
+
"""Read DOCX file."""
|
138
115
|
try:
|
139
116
|
from docx import Document as DocxDocument
|
140
117
|
from docx.oxml.ns import qn
|
@@ -237,36 +214,23 @@ def read_docx_file(path: Path) -> str:
|
|
237
214
|
|
238
215
|
|
239
216
|
def read_excel_file(path: Path) -> str:
|
217
|
+
"""Read excel file."""
|
218
|
+
text = ""
|
240
219
|
try:
|
241
|
-
from
|
242
|
-
except ImportError:
|
243
|
-
raise ImportError("`
|
244
|
-
|
220
|
+
from docling.document_converter import DocumentConverter
|
221
|
+
except (ImportError, ModuleNotFoundError):
|
222
|
+
raise ImportError("`docling` not installed, please install using `pip install docling`")
|
245
223
|
try:
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
data = []
|
252
|
-
for row in sheet.iter_rows(values_only=False):
|
253
|
-
row_data = {}
|
254
|
-
for idx, cell in enumerate(row):
|
255
|
-
cell_name = sheet.cell(row=1, column=idx + 1).value
|
256
|
-
if hasattr(cell, 'hyperlink') and cell.hyperlink:
|
257
|
-
row_val = f"[{cell.value}]({cell.hyperlink.target})"
|
258
|
-
row_data[cell_name] = row_val
|
259
|
-
else:
|
260
|
-
row_data[cell_name] = cell.value
|
261
|
-
data.append(row_data)
|
262
|
-
|
263
|
-
return json.dumps(data, ensure_ascii=False)
|
224
|
+
logger.info(f"Reading: {path}")
|
225
|
+
converter = DocumentConverter()
|
226
|
+
res = converter.convert(path)
|
227
|
+
text = res.document.export_to_markdown()
|
264
228
|
except Exception as e:
|
265
229
|
logger.error(f"Error reading: {path}: {e}")
|
266
|
-
|
230
|
+
return text
|
267
231
|
|
268
232
|
|
269
233
|
if __name__ == '__main__':
|
270
234
|
url = "https://arxiv.org/pdf/2412.15166"
|
271
235
|
result = read_pdf_url(url)
|
272
|
-
print(result
|
236
|
+
print(result)
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.2.2"
|