command
Version:
v1.11.1
Opens a new window with list of versions in this module.
Published: Apr 17, 2026
License: MIT
Opens a new window with license information.
Imports: 12
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
自定义 Agent (Custom Agent)
展示如何创建多个不同角色的自定义 Agent,每个 Agent 有独立的 PromptBundle 和行为特征。
入口说明:
- 仓库级正式入口仍是
sdk.New(opts).Build(ctx)
- 如果你只在
agent 子模块内装配运行时,正式入口是 agent/runtime.Builder
- 本示例关注
PromptBundle -> AgentConfig 的高级定制方式,不把底层构造器当作默认主入口
功能
- 定义自定义 AgentType(代码审查、数据分析、故事创作、数学辅导、产品经理)
- 为每个 Agent 配置专属的 PromptBundle(身份、策略、输出规则)
- 使用不同 Temperature 控制输出风格(审查 0.3 严谨,创作 0.9 发散)
- 通过
ChatCompletion 调用各 Agent
前置条件
- Go 1.24+
- 环境变量
OPENAI_API_KEY
运行
cd examples/04_custom_agent
go run main.go
代码说明
示例先用 agent.PromptBundle 组装系统提示词,再映射到 types.AgentConfig.Runtime.SystemPrompt,然后通过 agent/runtime.Builder 构建并初始化 Agent。不同 Agent 使用不同的 types.AgentConfig.LLM 参数(如 Temperature、MaxTokens)。
这里保留的是“如何做角色化 Prompt 定制”的思路,而不是推广底层 BaseAgent 构造路径。
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.