SDK 概览
AgentProc SDK 封装了从 stdin 读取 turn 对象、向 stdout 写 NDJSON 事件的样板代码,让你专注于 agent 逻辑。
可用 SDK
| 语言 | 包名 | 安装 |
|---|---|---|
| Python | agentproc | pip install agentproc |
| Node.js | agentproc | npm install agentproc |
| Rust | agentproc | cargo add agentproc |
不用 SDK
你不需要 SDK。任何从 stdin 读取 {"type":"turn",...} 对象、向 stdout 写 NDJSON 事件的脚本都可以工作。参见裸脚本示例。
用 SDK
写一个异步函数,SDK 处理其余的一切。
python
from agentproc import create_profile
async def handler(ctx):
reply = await my_llm(ctx.message)
return reply
create_profile(handler)js
const { createProfile } = require('agentproc');
createProfile(async ({ message }) => {
const reply = await myLLM(message);
return { response: reply };
});rust
use agentproc::{run, Profile, RunOptions};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let profile = Profile::from_path("profile.yaml")?;
let result = run(&profile, RunOptions::new("hello")).await?;
println!("{}", result.reply);
Ok(())
}