Skip to main content

AgentKit

Python 原生 Agent 框架,内置一等公民 Skill 支持与多 LLM 适配器。

Python 3.11+ License: MIT

✨ 特性

  • 🤖 声明式 Agent — 零继承配置,支持 Handoff 转介 + as_tool 委派两种协作模式
  • 📚 一等公民 Skill — 三级渐进式加载(L1 元数据 → L2 指令 → L3 资源),按需加载省 token
  • 🔧 灵活工具系统 — @function_tool 装饰器自动推断 JSON Schema
  • 🧠 多 LLM 适配器 — 自研统一适配层,4 个适配器覆盖所有主流 LLM
  • 🛡️ 内置安全 — Guardrail 护栏 + 权限控制 + 三级沙箱
  • 🎭 编排 Agent — Sequential / Parallel / Loop 三种模式
  • 💾 记忆系统 — 可选集成 Mem0,支持自定义记忆提供者

🚀 安装

# 基础安装(仅核心 + pydantic)
pip install agentkit

# 按需安装 LLM 适配器
pip install agentkit[openai]      # OpenAI GPT
pip install agentkit[anthropic]   # Anthropic Claude
pip install agentkit[google]      # Google Gemini
pip install agentkit[all]         # 全部

⚡ 30 秒快速开始

from agentkit import Agent, Runner, function_tool

@function_tool
def get_weather(city: str) -> str:
    """获取天气"""
    return f"{city}:晴,25°C"

agent = Agent(
    name="assistant",
    instructions="你是一个有帮助的中文助手。",
    model="ollama/qwen3.5:cloud",
    tools=[get_weather],
)

result = Runner.run_sync(agent, input="北京今天天气如何?")
print(result.final_output)

📚 文档

安装后查看文档:

# 命令行方式
agentkit-docs

# Python 方式
import agentkit
print(agentkit.get_docs_dir())     # 文档目录路径
print(agentkit.get_examples_dir()) # 示例目录路径
文档 说明
README 项目概述与特性
QuickStart 8 个渐进式入门示例
Architecture 六层架构设计说明
Reference 完整 API 参考手册

🧪 示例

安装包内含 16 个可运行示例(标准版 × 8 + Ollama 本地版 × 8):

# Ollama 本地版(无需 API Key)
python -c "import agentkit; print(agentkit.get_examples_dir())"
# 然后运行对应目录下的示例文件

# 或者直接:
python -m agentkit.examples.ollama.01_basic_chat

🔌 支持的 LLM

模型 适配器 用法
GPT-4o / o1 / o3 / o4 OpenAIAdapter model="gpt-4o"
Claude Opus/Sonnet/Haiku AnthropicAdapter model="claude-sonnet-4-20250514"
Gemini 2.5 / 3 GoogleAdapter model="gemini-2.5-pro"
通义千问/智谱/DeepSeek/Moonshot/百川/Azure OpenAICompatibleAdapter model="deepseek/deepseek-chat"
Ollama 本地模型 OllamaAdapter model="ollama/qwen3.5:cloud"

🔨 构建打包

./build.sh          # 构建 wheel + sdist
./build.sh clean    # 清理构建产物
./build.sh test     # 在隔离环境中安装并验证
./build.sh all      # 清理 + 构建 + 验证(推荐)

构建产物输出到 dist/ 目录:

dist/
├── agentkit-0.3.1-py3-none-any.whl   # pip install 用这个
└── agentkit-0.3.1.tar.gz             # 源码分发

📄 License

MIT

Metadata

Release files for ni.agentkit 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ni.agentkit 0.3.1
File Size Uploaded Provenance Actions
ni_agentkit-0.3.1.tar.gz 74.9 kB Without provenance Details for ni_agentkit-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ni.agentkit 0.3.1
File Interpreter ABI Platform Actions
ni_agentkit-0.3.1-py3-none-any.whl Python 3 none any Details for ni_agentkit-0.3.1-py3-none-any.whl

Total release size: 182.1 kB

Release files / ni_agentkit-0.3.1.tar.gz

Download URL ni_agentkit-0.3.1.tar.gz
Size 74.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bfcbe2361724ed6ecf840f1739b059a4b9405b6568aeded2e141632ee6fc5715
BLAKE2b-256 checksum
How to use checksums
34aefdea416f955326d68c4d3df9d56757838786611bbb2d84e97a9985ad8bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / ni_agentkit-0.3.1-py3-none-any.whl

Download URL ni_agentkit-0.3.1-py3-none-any.whl
Size 107.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
828edc6ee6a1d11be67fecf54170a39b51045a75d6c69c6fe0b2fc66c56a0d68
BLAKE2b-256 checksum
How to use checksums
34f2fa972a6ffc5e5c931713c3650e74b661e1fa0f5d28c2566ae2cdf19e5053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for ni.agentkit 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page