微小环路
Rust中的最小AI代理框架。
⚠️ 早期发展:该项目处于早期阶段,API将频繁更改。
特性
- [
#[tool]](https://docs.rs/tiny-loop/latest/tiny_loop/tool/attr.tool.html) 宏for 函数 和 方法 创建自定义工具。 - 注册MCP工具
- 历史管理
- 流媒体
- 自定义循环控制
- 并行工具执行
- 通过以下方式观察
tracing
安装
添加到您的 Cargo.toml:
[dependencies]
tiny-loop = "0.5"
serde = { version = "1", features = ["derive"] }
schemars = "1"快速开始
use tiny_loop::{Agent, llm::OpenAIProvider, tool::tool};
#[tool]
async fn search(
/// Search query
query: String
) -> String {
format!("Results for: {}", query)
}
#[tokio::main]
async fn main() {
let mut agent = Agent::new(OpenAIProvider::new())
.system("You are a helpful assistant")
.tool(search);
let response = agent.chat("Search for Rust tutorials").await.unwrap();
println!("{}", response);
}