Skip to content

SDK 概览 ​

AgentProc SDK 封装了从 stdin 读取 turn 对象、向 stdout 写 NDJSON 事件的样板代码,让你专注于 agent 逻辑。

可用 SDK ​

语言包名安装
Pythonagentprocpip install agentproc
Node.jsagentprocnpm install agentproc
Rustagentproccargo add agentproc
Gogithub.com/jeffkit/agentproc/sdk/gogo get github.com/jeffkit/agentproc/sdk/go

不用 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(())
}
go
package main

import (
	"context"
	"fmt"

	agentproc "github.com/jeffkit/agentproc/sdk/go"
)

func main() {
	result, err := agentproc.Run(context.Background(),
		map[string]any{"command": "python3", "args": []string{"{{PROFILE_DIR}}/bridge.py"}},
		&agentproc.RunOptions{Message: "hello"})
	if err != nil {
		panic(err)
	}
	fmt.Println(result.Reply)
}

Released under the MIT License.