Rooted in Origin, Driving All Things
Project description
RootDriver
根源出发,驱动万物
一个轻量级的 Python AI Agent 开发框架,支持单智能体和多智能体应用。
特性
- 简洁易用:装饰器方式定义工具,快速构建 Agent
- 模块化设计:LLM 适配器、工具系统、会话管理解耦
- 工具调用:支持 function calling,自动执行工具并返回结果
- 状态管理:支持内存和数据库持久化检查点
- 异常体系:完整的异常类层次结构
安装
pip install rootdriver
快速开始
定义工具
from rootdriver import tool
@tool
def get_weather(city: str) -> str:
"""获取城市天气"""
return f"{city} 晴天"
创建 Agent
from rootdriver import Agent, AgentLLM, OpenAIAdapter
agent = Agent(
agent_llm=AgentLLM(
adapter=OpenAIAdapter(
api_key="YOUR_API_KEY",
base_url="BASE_URL"
),
model="gpt-4",
),
tools=[get_weather],
system_prompt="你是一个有用的助手",
)
# 单次对话
response = agent.talk("北京天气怎么样?")
print(response)
使用工具
# 完整对话循环(包含工具调用)
response = agent.react("帮我查下上海天气")
print(response)
核心组件
| 组件 | 说明 |
|---|---|
Agent |
智能体入口,整合 LLM、工具、会话 |
Engine |
核心引擎,处理对话循环和工具调用 |
Conversation |
会话管理,维护消息历史 |
LLM |
LLM 调用封装 |
Tool |
工具集合,管理所有可调用工具 |
State |
状态管理,支持检查点和持久化 |
项目结构
rootdriver/
├── agent.py # Agent 智能体
├── engine.py # 引擎核心
├── conversation.py # 对话管理
├── state.py # 状态管理
├── exception.py # 异常定义
├── llm/
│ ├── llm.py # LLM 封装
│ ├── base_adapter.py # 适配器基类
│ └── adapter/
│ └── openai_adapter.py # OpenAI 适配器
├── tool/
│ ├── base_tool.py # 工具基类
│ └── tools.py # 工具集
├── types/ # 类型定义
└── utils/ # 工具函数
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rootdriver-0.2.0.tar.gz
(9.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rootdriver-0.2.0.tar.gz.
File metadata
- Download URL: rootdriver-0.2.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
236e7d2a1479a4f9f4a8fc3e1531a13b37457ee314b1637d05fff52a3c8dde0a
|
|
| MD5 |
d16482444c328b677062505c8aad7bd4
|
|
| BLAKE2b-256 |
761469a40d2477f8aa336fb5c77531a5e7c5c0a235d14775a3d4ecd8f66674fa
|
File details
Details for the file rootdriver-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rootdriver-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33bd84969ce406f230a913582938536698def1d606d06f701279595bc9b72b99
|
|
| MD5 |
56d68647645421d1608f0a3523f4f205
|
|
| BLAKE2b-256 |
f59303e2bab2ab9d1f7aa38678aec635193c37c302d18ff53b1c8458755f0f1d
|