ni.agentkit 0.3.1__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.
- ni_agentkit-0.3.1/LICENSE +21 -0
- ni_agentkit-0.3.1/PKG-INFO +157 -0
- ni_agentkit-0.3.1/README.md +115 -0
- ni_agentkit-0.3.1/__init__.py +57 -0
- ni_agentkit-0.3.1/_cli.py +72 -0
- ni_agentkit-0.3.1/agents/__init__.py +0 -0
- ni_agentkit-0.3.1/agents/agent.py +364 -0
- ni_agentkit-0.3.1/agents/base_agent.py +59 -0
- ni_agentkit-0.3.1/agents/orchestrators.py +62 -0
- ni_agentkit-0.3.1/docs/Architecture.md +536 -0
- ni_agentkit-0.3.1/docs/QuickStart.md +806 -0
- ni_agentkit-0.3.1/docs/README.md +119 -0
- ni_agentkit-0.3.1/docs/Reference.md +576 -0
- ni_agentkit-0.3.1/docs/TestReport.md +80 -0
- ni_agentkit-0.3.1/examples/__init__.py +0 -0
- ni_agentkit-0.3.1/examples/ollama/01_basic_chat.py +34 -0
- ni_agentkit-0.3.1/examples/ollama/02_tool_calling.py +70 -0
- ni_agentkit-0.3.1/examples/ollama/03_skill_usage.py +86 -0
- ni_agentkit-0.3.1/examples/ollama/04_multi_agent.py +84 -0
- ni_agentkit-0.3.1/examples/ollama/05_guardrail.py +101 -0
- ni_agentkit-0.3.1/examples/ollama/06_orchestration.py +123 -0
- ni_agentkit-0.3.1/examples/ollama/07_sync_async_stream.py +180 -0
- ni_agentkit-0.3.1/examples/ollama/08_memory.py +201 -0
- ni_agentkit-0.3.1/examples/ollama/README.md +51 -0
- ni_agentkit-0.3.1/examples/ollama/__init__.py +0 -0
- ni_agentkit-0.3.1/examples/quickstart.py +204 -0
- ni_agentkit-0.3.1/examples/standard/01_basic_chat.py +33 -0
- ni_agentkit-0.3.1/examples/standard/02_tool_calling.py +70 -0
- ni_agentkit-0.3.1/examples/standard/03_skill_usage.py +89 -0
- ni_agentkit-0.3.1/examples/standard/04_multi_agent.py +87 -0
- ni_agentkit-0.3.1/examples/standard/05_guardrail.py +104 -0
- ni_agentkit-0.3.1/examples/standard/06_orchestration.py +122 -0
- ni_agentkit-0.3.1/examples/standard/07_sync_async_stream.py +171 -0
- ni_agentkit-0.3.1/examples/standard/08_memory.py +140 -0
- ni_agentkit-0.3.1/examples/standard/README.md +31 -0
- ni_agentkit-0.3.1/examples/standard/__init__.py +0 -0
- ni_agentkit-0.3.1/examples/test_ollama.py +272 -0
- ni_agentkit-0.3.1/llm/__init__.py +0 -0
- ni_agentkit-0.3.1/llm/adapters/__init__.py +0 -0
- ni_agentkit-0.3.1/llm/adapters/anthropic_adapter.py +192 -0
- ni_agentkit-0.3.1/llm/adapters/google_adapter.py +184 -0
- ni_agentkit-0.3.1/llm/adapters/ollama_adapter.py +250 -0
- ni_agentkit-0.3.1/llm/adapters/openai_adapter.py +183 -0
- ni_agentkit-0.3.1/llm/adapters/openai_compatible.py +35 -0
- ni_agentkit-0.3.1/llm/base.py +66 -0
- ni_agentkit-0.3.1/llm/cache.py +121 -0
- ni_agentkit-0.3.1/llm/middleware.py +133 -0
- ni_agentkit-0.3.1/llm/registry.py +138 -0
- ni_agentkit-0.3.1/llm/types.py +191 -0
- ni_agentkit-0.3.1/memory/__init__.py +0 -0
- ni_agentkit-0.3.1/memory/base.py +47 -0
- ni_agentkit-0.3.1/memory/mem0_provider.py +48 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/PKG-INFO +157 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/SOURCES.txt +141 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/dependency_links.txt +1 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/entry_points.txt +2 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/requires.txt +24 -0
- ni_agentkit-0.3.1/ni.agentkit.egg-info/top_level.txt +1 -0
- ni_agentkit-0.3.1/pyproject.toml +86 -0
- ni_agentkit-0.3.1/runner/__init__.py +0 -0
- ni_agentkit-0.3.1/runner/context.py +47 -0
- ni_agentkit-0.3.1/runner/events.py +36 -0
- ni_agentkit-0.3.1/runner/runner.py +105 -0
- ni_agentkit-0.3.1/safety/__init__.py +0 -0
- ni_agentkit-0.3.1/safety/guardrails.py +55 -0
- ni_agentkit-0.3.1/safety/permissions.py +41 -0
- ni_agentkit-0.3.1/setup.cfg +4 -0
- ni_agentkit-0.3.1/skills/__init__.py +0 -0
- ni_agentkit-0.3.1/skills/loader.py +90 -0
- ni_agentkit-0.3.1/skills/models.py +106 -0
- ni_agentkit-0.3.1/skills/registry.py +48 -0
- ni_agentkit-0.3.1/tools/__init__.py +0 -0
- ni_agentkit-0.3.1/tools/base_tool.py +44 -0
- ni_agentkit-0.3.1/tools/function_tool.py +118 -0
- ni_agentkit-0.3.1/tools/skill_toolset.py +199 -0
- ni_agentkit-0.3.1/utils/__init__.py +0 -0
- ni_agentkit-0.3.1/utils/schema.py +83 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentKit Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ni.agentkit
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Python-native Agent framework with first-class Skill support and multi-LLM adapter
|
|
5
|
+
Author-email: Krix Tam <krix.tam@qq.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Documentation, https://github.com/KrixTam/AgentKit/tree/main/agentkit/docs
|
|
8
|
+
Project-URL: Repository, https://github.com/KrixTam/AgentKit
|
|
9
|
+
Keywords: agent,llm,skill,ai,framework,tool-use,function-calling
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: pydantic>=2.0
|
|
24
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Provides-Extra: openai
|
|
27
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
28
|
+
Provides-Extra: anthropic
|
|
29
|
+
Requires-Dist: anthropic>=0.30.0; extra == "anthropic"
|
|
30
|
+
Provides-Extra: google
|
|
31
|
+
Requires-Dist: google-genai>=1.0.0; extra == "google"
|
|
32
|
+
Provides-Extra: memory
|
|
33
|
+
Requires-Dist: mem0ai>=0.1.0; extra == "memory"
|
|
34
|
+
Provides-Extra: docker
|
|
35
|
+
Requires-Dist: docker>=7.0.0; extra == "docker"
|
|
36
|
+
Provides-Extra: all
|
|
37
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
38
|
+
Requires-Dist: anthropic>=0.30.0; extra == "all"
|
|
39
|
+
Requires-Dist: google-genai>=1.0.0; extra == "all"
|
|
40
|
+
Requires-Dist: mem0ai>=0.1.0; extra == "all"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# AgentKit
|
|
44
|
+
|
|
45
|
+
**Python 原生 Agent 框架,内置一等公民 Skill 支持与多 LLM 适配器。**
|
|
46
|
+
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](LICENSE)
|
|
49
|
+
|
|
50
|
+
## ✨ 特性
|
|
51
|
+
|
|
52
|
+
- 🤖 **声明式 Agent** — 零继承配置,支持 Handoff 转介 + as_tool 委派两种协作模式
|
|
53
|
+
- 📚 **一等公民 Skill** — 三级渐进式加载(L1 元数据 → L2 指令 → L3 资源),按需加载省 token
|
|
54
|
+
- 🔧 **灵活工具系统** — `@function_tool` 装饰器自动推断 JSON Schema
|
|
55
|
+
- 🧠 **多 LLM 适配器** — 自研统一适配层,4 个适配器覆盖所有主流 LLM
|
|
56
|
+
- 🛡️ **内置安全** — Guardrail 护栏 + 权限控制 + 三级沙箱
|
|
57
|
+
- 🎭 **编排 Agent** — Sequential / Parallel / Loop 三种模式
|
|
58
|
+
- 💾 **记忆系统** — 可选集成 Mem0,支持自定义记忆提供者
|
|
59
|
+
|
|
60
|
+
## 🚀 安装
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 基础安装(仅核心 + pydantic)
|
|
64
|
+
pip install agentkit
|
|
65
|
+
|
|
66
|
+
# 按需安装 LLM 适配器
|
|
67
|
+
pip install agentkit[openai] # OpenAI GPT
|
|
68
|
+
pip install agentkit[anthropic] # Anthropic Claude
|
|
69
|
+
pip install agentkit[google] # Google Gemini
|
|
70
|
+
pip install agentkit[all] # 全部
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## ⚡ 30 秒快速开始
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from agentkit import Agent, Runner, function_tool
|
|
77
|
+
|
|
78
|
+
@function_tool
|
|
79
|
+
def get_weather(city: str) -> str:
|
|
80
|
+
"""获取天气"""
|
|
81
|
+
return f"{city}:晴,25°C"
|
|
82
|
+
|
|
83
|
+
agent = Agent(
|
|
84
|
+
name="assistant",
|
|
85
|
+
instructions="你是一个有帮助的中文助手。",
|
|
86
|
+
model="ollama/qwen3.5:cloud",
|
|
87
|
+
tools=[get_weather],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
result = Runner.run_sync(agent, input="北京今天天气如何?")
|
|
91
|
+
print(result.final_output)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 📚 文档
|
|
95
|
+
|
|
96
|
+
安装后查看文档:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# 命令行方式
|
|
100
|
+
agentkit-docs
|
|
101
|
+
|
|
102
|
+
# Python 方式
|
|
103
|
+
import agentkit
|
|
104
|
+
print(agentkit.get_docs_dir()) # 文档目录路径
|
|
105
|
+
print(agentkit.get_examples_dir()) # 示例目录路径
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| 文档 | 说明 |
|
|
109
|
+
|------|------|
|
|
110
|
+
| [README](docs/README.md) | 项目概述与特性 |
|
|
111
|
+
| [QuickStart](docs/QuickStart.md) | 8 个渐进式入门示例 |
|
|
112
|
+
| [Architecture](docs/Architecture.md) | 六层架构设计说明 |
|
|
113
|
+
| [Reference](docs/Reference.md) | 完整 API 参考手册 |
|
|
114
|
+
|
|
115
|
+
## 🧪 示例
|
|
116
|
+
|
|
117
|
+
安装包内含 16 个可运行示例(标准版 × 8 + Ollama 本地版 × 8):
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Ollama 本地版(无需 API Key)
|
|
121
|
+
python -c "import agentkit; print(agentkit.get_examples_dir())"
|
|
122
|
+
# 然后运行对应目录下的示例文件
|
|
123
|
+
|
|
124
|
+
# 或者直接:
|
|
125
|
+
python -m agentkit.examples.ollama.01_basic_chat
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 🔌 支持的 LLM
|
|
129
|
+
|
|
130
|
+
| 模型 | 适配器 | 用法 |
|
|
131
|
+
|------|--------|------|
|
|
132
|
+
| GPT-4o / o1 / o3 / o4 | OpenAIAdapter | `model="gpt-4o"` |
|
|
133
|
+
| Claude Opus/Sonnet/Haiku | AnthropicAdapter | `model="claude-sonnet-4-20250514"` |
|
|
134
|
+
| Gemini 2.5 / 3 | GoogleAdapter | `model="gemini-2.5-pro"` |
|
|
135
|
+
| 通义千问/智谱/DeepSeek/Moonshot/百川/Azure | OpenAICompatibleAdapter | `model="deepseek/deepseek-chat"` |
|
|
136
|
+
| Ollama 本地模型 | OllamaAdapter | `model="ollama/qwen3.5:cloud"` |
|
|
137
|
+
|
|
138
|
+
## 🔨 构建打包
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
./build.sh # 构建 wheel + sdist
|
|
142
|
+
./build.sh clean # 清理构建产物
|
|
143
|
+
./build.sh test # 在隔离环境中安装并验证
|
|
144
|
+
./build.sh all # 清理 + 构建 + 验证(推荐)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
构建产物输出到 `dist/` 目录:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
dist/
|
|
151
|
+
├── agentkit-0.3.1-py3-none-any.whl # pip install 用这个
|
|
152
|
+
└── agentkit-0.3.1.tar.gz # 源码分发
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 📄 License
|
|
156
|
+
|
|
157
|
+
MIT
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# AgentKit
|
|
2
|
+
|
|
3
|
+
**Python 原生 Agent 框架,内置一等公民 Skill 支持与多 LLM 适配器。**
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## ✨ 特性
|
|
9
|
+
|
|
10
|
+
- 🤖 **声明式 Agent** — 零继承配置,支持 Handoff 转介 + as_tool 委派两种协作模式
|
|
11
|
+
- 📚 **一等公民 Skill** — 三级渐进式加载(L1 元数据 → L2 指令 → L3 资源),按需加载省 token
|
|
12
|
+
- 🔧 **灵活工具系统** — `@function_tool` 装饰器自动推断 JSON Schema
|
|
13
|
+
- 🧠 **多 LLM 适配器** — 自研统一适配层,4 个适配器覆盖所有主流 LLM
|
|
14
|
+
- 🛡️ **内置安全** — Guardrail 护栏 + 权限控制 + 三级沙箱
|
|
15
|
+
- 🎭 **编排 Agent** — Sequential / Parallel / Loop 三种模式
|
|
16
|
+
- 💾 **记忆系统** — 可选集成 Mem0,支持自定义记忆提供者
|
|
17
|
+
|
|
18
|
+
## 🚀 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 基础安装(仅核心 + pydantic)
|
|
22
|
+
pip install agentkit
|
|
23
|
+
|
|
24
|
+
# 按需安装 LLM 适配器
|
|
25
|
+
pip install agentkit[openai] # OpenAI GPT
|
|
26
|
+
pip install agentkit[anthropic] # Anthropic Claude
|
|
27
|
+
pip install agentkit[google] # Google Gemini
|
|
28
|
+
pip install agentkit[all] # 全部
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## ⚡ 30 秒快速开始
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from agentkit import Agent, Runner, function_tool
|
|
35
|
+
|
|
36
|
+
@function_tool
|
|
37
|
+
def get_weather(city: str) -> str:
|
|
38
|
+
"""获取天气"""
|
|
39
|
+
return f"{city}:晴,25°C"
|
|
40
|
+
|
|
41
|
+
agent = Agent(
|
|
42
|
+
name="assistant",
|
|
43
|
+
instructions="你是一个有帮助的中文助手。",
|
|
44
|
+
model="ollama/qwen3.5:cloud",
|
|
45
|
+
tools=[get_weather],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
result = Runner.run_sync(agent, input="北京今天天气如何?")
|
|
49
|
+
print(result.final_output)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 📚 文档
|
|
53
|
+
|
|
54
|
+
安装后查看文档:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 命令行方式
|
|
58
|
+
agentkit-docs
|
|
59
|
+
|
|
60
|
+
# Python 方式
|
|
61
|
+
import agentkit
|
|
62
|
+
print(agentkit.get_docs_dir()) # 文档目录路径
|
|
63
|
+
print(agentkit.get_examples_dir()) # 示例目录路径
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| 文档 | 说明 |
|
|
67
|
+
|------|------|
|
|
68
|
+
| [README](docs/README.md) | 项目概述与特性 |
|
|
69
|
+
| [QuickStart](docs/QuickStart.md) | 8 个渐进式入门示例 |
|
|
70
|
+
| [Architecture](docs/Architecture.md) | 六层架构设计说明 |
|
|
71
|
+
| [Reference](docs/Reference.md) | 完整 API 参考手册 |
|
|
72
|
+
|
|
73
|
+
## 🧪 示例
|
|
74
|
+
|
|
75
|
+
安装包内含 16 个可运行示例(标准版 × 8 + Ollama 本地版 × 8):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Ollama 本地版(无需 API Key)
|
|
79
|
+
python -c "import agentkit; print(agentkit.get_examples_dir())"
|
|
80
|
+
# 然后运行对应目录下的示例文件
|
|
81
|
+
|
|
82
|
+
# 或者直接:
|
|
83
|
+
python -m agentkit.examples.ollama.01_basic_chat
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 🔌 支持的 LLM
|
|
87
|
+
|
|
88
|
+
| 模型 | 适配器 | 用法 |
|
|
89
|
+
|------|--------|------|
|
|
90
|
+
| GPT-4o / o1 / o3 / o4 | OpenAIAdapter | `model="gpt-4o"` |
|
|
91
|
+
| Claude Opus/Sonnet/Haiku | AnthropicAdapter | `model="claude-sonnet-4-20250514"` |
|
|
92
|
+
| Gemini 2.5 / 3 | GoogleAdapter | `model="gemini-2.5-pro"` |
|
|
93
|
+
| 通义千问/智谱/DeepSeek/Moonshot/百川/Azure | OpenAICompatibleAdapter | `model="deepseek/deepseek-chat"` |
|
|
94
|
+
| Ollama 本地模型 | OllamaAdapter | `model="ollama/qwen3.5:cloud"` |
|
|
95
|
+
|
|
96
|
+
## 🔨 构建打包
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
./build.sh # 构建 wheel + sdist
|
|
100
|
+
./build.sh clean # 清理构建产物
|
|
101
|
+
./build.sh test # 在隔离环境中安装并验证
|
|
102
|
+
./build.sh all # 清理 + 构建 + 验证(推荐)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
构建产物输出到 `dist/` 目录:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
dist/
|
|
109
|
+
├── agentkit-0.3.1-py3-none-any.whl # pip install 用这个
|
|
110
|
+
└── agentkit-0.3.1.tar.gz # 源码分发
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 📄 License
|
|
114
|
+
|
|
115
|
+
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agentkit — Python 原生 Agent 框架,内置一等公民 Skill 支持
|
|
3
|
+
|
|
4
|
+
用法:
|
|
5
|
+
from agentkit import Agent, Runner, function_tool
|
|
6
|
+
from agentkit import Skill, load_skill_from_dir
|
|
7
|
+
from agentkit import LLMRegistry, LLMConfig
|
|
8
|
+
"""
|
|
9
|
+
from .agents.agent import Agent
|
|
10
|
+
from .agents.base_agent import BaseAgent
|
|
11
|
+
from .agents.orchestrators import LoopAgent, ParallelAgent, SequentialAgent
|
|
12
|
+
from .llm.base import BaseLLM
|
|
13
|
+
from .llm.registry import LLMRegistry
|
|
14
|
+
from .llm.types import LLMConfig, LLMResponse, Message, ToolCall, ToolDefinition
|
|
15
|
+
from .memory.base import BaseMemoryProvider, Memory
|
|
16
|
+
from .runner.events import Event, RunResult
|
|
17
|
+
from .runner.runner import Runner
|
|
18
|
+
from .safety.guardrails import (
|
|
19
|
+
GuardrailResult,
|
|
20
|
+
InputGuardrail,
|
|
21
|
+
OutputGuardrail,
|
|
22
|
+
input_guardrail,
|
|
23
|
+
output_guardrail,
|
|
24
|
+
)
|
|
25
|
+
from .safety.permissions import PermissionPolicy
|
|
26
|
+
from .skills.loader import load_skill_from_dir
|
|
27
|
+
from .skills.models import Skill, SkillFrontmatter, SkillResources
|
|
28
|
+
from .skills.registry import SkillRegistry
|
|
29
|
+
from .tools.base_tool import BaseTool, BaseToolset
|
|
30
|
+
from .tools.function_tool import FunctionTool, function_tool
|
|
31
|
+
|
|
32
|
+
__version__ = "0.3.1"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_docs_dir() -> str:
|
|
36
|
+
"""返回 agentkit 文档目录的绝对路径"""
|
|
37
|
+
import os
|
|
38
|
+
return os.path.join(os.path.dirname(__file__), "docs")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_examples_dir() -> str:
|
|
42
|
+
"""返回 agentkit 示例目录的绝对路径"""
|
|
43
|
+
import os
|
|
44
|
+
return os.path.join(os.path.dirname(__file__), "examples")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"Agent", "BaseAgent", "SequentialAgent", "ParallelAgent", "LoopAgent",
|
|
49
|
+
"Runner", "RunResult", "Event",
|
|
50
|
+
"BaseLLM", "LLMConfig", "LLMRegistry", "LLMResponse", "Message", "ToolCall", "ToolDefinition",
|
|
51
|
+
"BaseTool", "BaseToolset", "FunctionTool", "function_tool",
|
|
52
|
+
"Skill", "SkillFrontmatter", "SkillResources", "SkillRegistry", "load_skill_from_dir",
|
|
53
|
+
"GuardrailResult", "InputGuardrail", "OutputGuardrail", "PermissionPolicy",
|
|
54
|
+
"input_guardrail", "output_guardrail",
|
|
55
|
+
"BaseMemoryProvider", "Memory",
|
|
56
|
+
"get_docs_dir", "get_examples_dir",
|
|
57
|
+
]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AgentKit CLI 工具。
|
|
3
|
+
|
|
4
|
+
安装后提供以下命令:
|
|
5
|
+
agentkit-docs — 显示文档目录位置,或在浏览器中打开
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _get_docs_dir() -> str:
|
|
11
|
+
"""返回 docs 目录的绝对路径"""
|
|
12
|
+
return os.path.join(os.path.dirname(__file__), "docs")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_examples_dir() -> str:
|
|
16
|
+
"""返回 examples 目录的绝对路径"""
|
|
17
|
+
return os.path.join(os.path.dirname(__file__), "examples")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def show_docs():
|
|
21
|
+
"""agentkit-docs 命令入口"""
|
|
22
|
+
docs_dir = _get_docs_dir()
|
|
23
|
+
examples_dir = _get_examples_dir()
|
|
24
|
+
|
|
25
|
+
print("=" * 60)
|
|
26
|
+
print(" AgentKit v0.3.1 — 文档与示例")
|
|
27
|
+
print("=" * 60)
|
|
28
|
+
print()
|
|
29
|
+
|
|
30
|
+
# 文档
|
|
31
|
+
print("📚 文档目录:")
|
|
32
|
+
print(f" {docs_dir}")
|
|
33
|
+
print()
|
|
34
|
+
|
|
35
|
+
if os.path.isdir(docs_dir):
|
|
36
|
+
print(" 文件列表:")
|
|
37
|
+
for f in sorted(os.listdir(docs_dir)):
|
|
38
|
+
fpath = os.path.join(docs_dir, f)
|
|
39
|
+
size = os.path.getsize(fpath) / 1024
|
|
40
|
+
print(f" • {f:30s} ({size:.1f} KB)")
|
|
41
|
+
else:
|
|
42
|
+
print(" ⚠️ 文档目录不存在(包可能未正确安装)")
|
|
43
|
+
|
|
44
|
+
print()
|
|
45
|
+
|
|
46
|
+
# 示例
|
|
47
|
+
print("💡 示例目录:")
|
|
48
|
+
print(f" {examples_dir}")
|
|
49
|
+
print()
|
|
50
|
+
|
|
51
|
+
if os.path.isdir(examples_dir):
|
|
52
|
+
for subdir in ["standard", "ollama"]:
|
|
53
|
+
sub_path = os.path.join(examples_dir, subdir)
|
|
54
|
+
if os.path.isdir(sub_path):
|
|
55
|
+
files = [f for f in sorted(os.listdir(sub_path)) if f.endswith(".py") and f != "__init__.py"]
|
|
56
|
+
print(f" 📁 {subdir}/ ({len(files)} 个示例)")
|
|
57
|
+
for f in files:
|
|
58
|
+
print(f" • {f}")
|
|
59
|
+
print()
|
|
60
|
+
|
|
61
|
+
print("-" * 60)
|
|
62
|
+
print("快速开始:")
|
|
63
|
+
print(" 1. 查看文档: cat $(agentkit-docs-path)/README.md")
|
|
64
|
+
print(" 2. 运行示例: python -m agentkit.examples.ollama.01_basic_chat")
|
|
65
|
+
print(" 3. Python 中获取路径:")
|
|
66
|
+
print(" >>> import agentkit; print(agentkit.get_docs_dir())")
|
|
67
|
+
print(" >>> import agentkit; print(agentkit.get_examples_dir())")
|
|
68
|
+
print()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
show_docs()
|
|
File without changes
|