
Veadk Go Skills
- 52 installs
- 411 repo stars
- Updated August 4, 2026
- bytedance/agentkit-samples
VeADK-Go Skills is a Claude skill (ByteDance AgentKit sample) that generates VeADK-Go agent code from a feature description or converts existing Enio agent code into VeADK-Go.
About
VeADK-Go Skills is a ByteDance AgentKit skill that generates VeADK-Go Agent code from a user's feature description, or converts existing Enio agent code into VeADK-Go. It references the framework's common docs for code structure, features and examples, and saves the produced agent code to agent_name/agent.py. Developers use it to scaffold or migrate Go-based VeADK agents.
- Generates VeADK-Go Agent code from a feature description
- Converts existing Enio agent code to VeADK-Go
- References common docs for framework structure and examples
Veadk Go Skills by the numbers
- 52 all-time installs (skills.sh)
- Ranked #7,086 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
veadk-go-skills capabilities & compatibility
- Capabilities
- agent scaffolding · code generation · code conversion
- Use cases
- orchestration
- Pricing
- Free
What veadk-go-skills says it does
本技能可以根据用户的需求,生成符合要求的 VeADK-Go Agent 代码,或完成 VeADK-Go 相关功能。
将原有代码改为 VeADK-Go Agent。代码特性对应关系参考 `references/converter/enio_rules.md`
`agent_name/agent.py`:包含所有智能体的代码
npx skills add https://github.com/bytedance/agentkit-samples --skill veadk-go-skillsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 52 |
|---|---|
| repo stars | ★ 411 |
| Last updated | August 4, 2026 |
| Repository | bytedance/agentkit-samples ↗ |
What it does
Generate VeADK-Go agent code from a description or convert Enio code to VeADK-Go.
Who is it for?
Scaffolding a VeADK-Go agent or migrating Enio agent code to VeADK-Go.
Skip if: Non-Go VeADK work (use veadk-skills for the Python VeADK path).
When should I use this skill?
You want to build a VeADK-Go agent or convert existing Enio code to VeADK-Go.
What you get
Generated or converted VeADK-Go agent code saved to agent_name/agent.py.
- VeADK-Go agent code in agent_name/agent.py
By the numbers
- 2 supported modes (generate from need; convert from Enio)
Files
VeADK Agent 生成
本技能可以根据用户的需求,生成符合要求的 VeADK-Go Agent 代码,或完成 VeADK-Go 相关功能。
触发条件
1. 用户简要描述了其功能需求,并希望构建一个 Agent 来完成; 2. 用户希望可以将已有的 Enio 代码转化为 VeADK-Go Agent 代码
具体步骤
下面是本技能不同的组件能力。
直接根据需求生成 Agent
请你遵循以下步骤:
1. 了解VeADK-Go开发框架的代码结构、功能特性以及代码示例,可以参考 /references/common/ 目录下文档 2. 分析用户需求,生成 Agent 代码。
Enio 代码转换为 VeADK-Go Agent
请你遵循以下步骤:
1. 了解VeADK-Go开发框架的代码结构、功能特性以及代码示例,可以参考 /references/common/ 目录下文档 2. 分析原有 Enio 代码 3. 将原有代码改为 VeADK-Go Agent。代码特性对应关系参考 references/converter/enio_rules.md 4. 确保 llmagent.Config Name 字段 不包含空格和-等特殊字符。
后续工作
在完成 Agent 代码编写后,调用脚本保存代码产物:
agent_name/agent.py:包含所有智能体的代码
其中,agent_name 是你认为合适的 Agent 的名称。
Agent 定义方法
导入方法
- LLM Agent:
import veagent "github.com/volcengine/veadk-go/agent/llmagent" - Sequential Agent:
import "github.com/volcengine/veadk-go/agent/workflowagents/sequentialagent" - Loop Agent:
import "github.com/volcengine/veadk-go/agent/workflowagents/loopagent" - Parallel Agent:
import "github.com/volcengine/veadk-go/agent/workflowagents/parallelagent"
其中,LLM Agent 是最基础的智能体(由 LLM 启动进行自主决策),Sequential Agent 是按顺序执行的智能体,Loop Agent 是循环执行的智能体,Parallel Agent 是并行执行的智能体。
代码规范
1、你可以通过如下方式定义智能体:
import (
"context"
"fmt"
veagent "github.com/volcengine/veadk-go/agent/llmagent"
"github.com/volcengine/veadk-go/apps"
"github.com/volcengine/veadk-go/apps/agentkit_server_app"
vetool "github.com/volcengine/veadk-go/tool"
"google.golang.org/adk/agent"
"google.golang.org/adk/agent/llmagent"
"google.golang.org/adk/tool"
)
func main() {
ctx := context.Background()
subAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: `...`,
},
ModelName: "...",
})
if err != nil {
fmt.Printf("NewLLMAgent subAgent failed: %v", err)
return
}
rootAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: `...`,
SubAgents: []agent.Agent{subAgent},
},
ModelName: "...",
})
if err != nil {
fmt.Printf("NewLLMAgent rootAgent failed: %v", err)
return
}
app := agentkit_server_app.NewAgentkitServerApp(apps.DefaultApiConfig())
err = app.Run(ctx, &apps.RunConfig{
AgentLoader: agent.NewSingleLoader(rootAgent),
})
if err != nil {
fmt.Printf("Run failed: %v", err)
}
}
2、可以生成一个强制按顺序执行的智能体:
import (
"context"
"fmt"
veagent "github.com/volcengine/veadk-go/agent/llmagent"
"github.com/volcengine/veadk-go/agent/workflowagents/sequentialagent"
"github.com/volcengine/veadk-go/apps"
"github.com/volcengine/veadk-go/apps/agentkit_server_app"
"google.golang.org/adk/agent"
"google.golang.org/adk/agent/llmagent"
)
func main() {
ctx := context.Background()
agent1, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: "...",
},
})
if err != nil {
fmt.Printf("NewLLMAgent agent1 failed: %v", err)
return
}
agent2, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: "...",
},
})
if err != nil {
fmt.Printf("NewLLMAgent agent failed: %v", err)
return
}
rootAgent, err := sequentialagent.New(sequentialagent.Config{
AgentConfig: agent.Config{
Name: "...",
SubAgents: []agent.Agent{agent1, agent2},
Description: "...",
},
})
if err != nil {
fmt.Printf("NewSequentialAgent failed: %v", err)
return
}
app := agentkit_server_app.NewAgentkitServerApp(apps.DefaultApiConfig())
err = app.Run(ctx, &apps.RunConfig{
AgentLoader: agent.NewSingleLoader(rootAgent),
})
if err != nil {
fmt.Printf("Run failed: %v", err)
}
}agent1 与 agent2 将会严格按顺序执行
注意,根智能体的命名必须为 rootAgent。
让 Agent 结构化输出
为保证更高的准确率和 Agent 执行时的可控性,使用结构化输出是一种有效的手段。
在定义 Agent 时,通过 model_extra_config={"response_format": ...} 可以让 Agent 结构化输出。其中,... 是你定义的 Pydantic 模型,用于描述 Agent 的输出格式。
from pydantic import BaseModel
from veadk import Agent, Runner
# 定义分步解析模型(对应业务场景的结构化响应)
class Step(BaseModel):
explanation: str # 步骤说明
output: str # 步骤计算结果
# 定义最终响应模型(包含分步过程和最终答案)
class MathResponse(BaseModel):
steps: list[Step] # 解题步骤列表
final_answer: str # 最终答案
agent = Agent(
instruction="你是一位数学辅导老师,需详细展示解题步骤",
model_extra_config={"response_format": MathResponse},
)CallBack 定义方法
方法说明
1、BeforeModelCallBack
type BeforeModelCallback func(ctx agent.CallbackContext, llmRequest model.LLMRequest) (model.LLMResponse, error)
BeforeModelCallback that is called before sending a request to the model. If it returns non-nil LLMResponse or error, the actual model call is skipped and the returned response/error is used.
2、AfterModelCallback
type AfterModelCallback func(ctx agent.CallbackContext, llmResponse model.LLMResponse, llmResponseError error) (model.LLMResponse, error)
AfterModelCallback that is called after receiving a response from the model. If it returns non-nil LLMResponse or error, the actual model response/error is replaced with the returned response/error.
3、BeforeToolCallback
type BeforeToolCallback func(ctx tool.Context, tool tool.Tool, args map[string]any) (map[string]any, error)
BeforeToolCallback is executed before a tool's Run method. Callbacks are executed in the order they are provided. If a callback returns a non-nil result or an error:
- execution of remaining callbacks stops
- the actual tool call is skipped
- the returned result is used as the tool result
To modify tool arguments and still run the tool, update args in place and return (nil, nil).
4、AfterToolCallback
type AfterToolCallback func(ctx tool.Context, tool tool.Tool, args, result map[string]any, err error) (map[string]any, error) AfterToolCallback is a function type executed after a tool's Run method has completed, regardless of whether the tool returned a result or an error.
Callbacks are executed in the order they are provided. If a callback returns a non-nil result or an error:
- execution of remaining callbacks stops
- the returned result and/or error is used as the final tool output
callback方法示例
1、BeforeModelCallBack 代码示例
何时触发: 在LlmAgent流程中向 LLM 发送请求之前调用。 用途: 允许检查和修改发送给 LLM 的请求。用例包括添加动态指令、基于状态注入少量示例、修改模型配置、实现防护机制 (如亵渎过滤器) 或实现请求级缓存。 返回值效果: 如果回调返回 nil,LLM 继续其正常工作流程。如果回调返回 LlmResponse 对象,则跳过对 LLM 的调用。返回的 LlmResponse 直接使用,就像它来自模型一样。这对于实现防护栏或缓存非常强大。
func onBeforeModel(ctx agent.CallbackContext, req *model.LLMRequest) (*model.LLMResponse, error) {
log.Printf("[Callback] BeforeModel triggered for agent %q.", ctx.AgentName())
// Modification Example: Add a prefix to the system instruction.
if req.Config.SystemInstruction != nil {
prefix := "[Modified by Callback] "
// This is a simplified example; production code might need deeper checks.
if len(req.Config.SystemInstruction.Parts) > 0 {
req.Config.SystemInstruction.Parts[0].Text = prefix + req.Config.SystemInstruction.Parts[0].Text
} else {
req.Config.SystemInstruction.Parts = append(req.Config.SystemInstruction.Parts, &genai.Part{Text: prefix})
}
log.Printf("[Callback] Modified system instruction.")
}
// Skip Example: Check for "BLOCK" in the user's prompt.
for _, content := range req.Contents {
for _, part := range content.Parts {
if strings.Contains(strings.ToUpper(part.Text), "BLOCK") {
log.Println("[Callback] 'BLOCK' keyword found. Skipping LLM call.")
return &model.LLMResponse{
Content: &genai.Content{
Parts: []*genai.Part{{Text: "LLM call was blocked by before_model_callback."}},
Role: "model",
},
}, nil
}
}
}
log.Println("[Callback] Proceeding with LLM call.")
return nil, nil
}
rootAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: "...",
BeforeModelCallbacks:[]llmagent.BeforeModelCallback{
onBeforeModel,
},
},
})2、AfterModelCallBack 代码示例
何时触发: 在从 LLM 接收到响应 (LlmResponse) 之后,在调用智能体进一步处理之前调用。 用途: 允许检查或修改原始 LLM 响应。用例包括: 记录模型输出, 重新格式化响应, 审查模型生成的敏感信息, 从 LLM 响应中解析结构化数据并将其存储在callback_context.state中 或处理特定错误代码。
func onAfterModel(ctx agent.CallbackContext, resp *model.LLMResponse, respErr error) (*model.LLMResponse, error) {
log.Printf("[Callback] AfterModel triggered for agent %q.", ctx.AgentName())
if respErr != nil {
log.Printf("[Callback] Model returned an error: %v. Passing it through.", respErr)
return nil, respErr
}
if resp == nil || resp.Content == nil || len(resp.Content.Parts) == 0 {
log.Println("[Callback] Response is nil or has no parts, nothing to process.")
return nil, nil
}
// Check for function calls and pass them through without modification.
if resp.Content.Parts[0].FunctionCall != nil {
log.Println("[Callback] Response is a function call. No modification.")
return nil, nil
}
originalText := resp.Content.Parts[0].Text
// Use a case-insensitive regex with word boundaries to find "joke".
re := regexp.MustCompile(`(?i)\bjoke\b`)
if !re.MatchString(originalText) {
log.Println("[Callback] 'joke' not found. Passing original response through.")
return nil, nil
}
log.Println("[Callback] 'joke' found. Modifying response.")
// Use a replacer function to handle capitalization.
modifiedText := re.ReplaceAllStringFunc(originalText, func(s string) string {
if strings.ToUpper(s) == "JOKE" {
if s == "Joke" {
return "Funny story"
}
return "funny story"
}
return s // Should not be reached with this regex, but it's safe.
})
resp.Content.Parts[0].Text = modifiedText
return resp, nil
}3、BeforeToolCallback 代码示例
何时触发: 在调用特定工具的run_async方法之前,在 LLM 为其生成函数调用之后调用。
用途: 允许检查和修改工具参数,在执行前执行授权检查,记录工具使用尝试,或实现工具级缓存。
返回值效果:
如果回调返回 nil,工具方法将使用(可能修改的)args 执行。 如果返回map,工具方法将被跳过。返回的字典直接用作工具调用的结果。这对于缓存或覆盖工具行为很有用。
func onBeforeTool(ctx tool.Context, t tool.Tool, args map[string]any) (map[string]any, error) {
log.Printf("[Callback] BeforeTool triggered for tool %q in agent %q.", t.Name(), ctx.AgentName())
log.Printf("[Callback] Original args: %v", args)
if t.Name() == "getCapitalCity" {
if country, ok := args["country"].(string); ok {
if strings.ToLower(country) == "canada" {
log.Println("[Callback] Detected 'Canada'. Modifying args to 'France'.")
args["country"] = "France"
return args, nil // Proceed with modified args
} else if strings.ToUpper(country) == "BLOCK" {
log.Println("[Callback] Detected 'BLOCK'. Skipping tool execution.")
// Skip tool and return a custom result.
return map[string]any{"result": "Tool execution was blocked by before_tool_callback."}, nil
}
}
}
log.Println("[Callback] Proceeding with original or previously modified args.")
return nil, nil // Proceed with original args
}4、AfterToolCallback 代码示例
何时触发: 在工具的执行方法成功完成后立即调用。 用途: 允许在将工具结果发送回 LLM(可能在摘要后) 之前对其进行检查和修改。适用于记录工具结果、后处理或格式化结果,或将结果的特定部分保存到会话状态。
返回值效果: 如果回调返回 nil,使用原始的 tool_response。 如果返回新map,它替换原始的 tool_response。这允许修改或过滤 LLM 看到的结果。
func onAfterTool(ctx tool.Context, t tool.Tool, args map[string]any, result map[string]any, err error) (map[string]any, error) {
log.Printf("[Callback] AfterTool triggered for tool %q in agent %q.", t.Name(), ctx.AgentName())
log.Printf("[Callback] Original result: %v", result)
if err != nil {
log.Printf("[Callback] Tool run produced an error: %v. Passing through.", err)
return nil, err
}
if t.Name() == "getCapitalCity" {
if originalResult, ok := result["result"].(string); ok && originalResult == "Washington, D.C." {
log.Println("[Callback] Detected 'Washington, D.C.'. Modifying tool response.")
modifiedResult := make(map[string]any)
for k, v := range result {
modifiedResult[k] = v
}
modifiedResult["result"] = fmt.Sprintf("%s (Note: This is the capital of the USA).", originalResult)
modifiedResult["note_added_by_callback"] = true
return modifiedResult, nil
}
}
log.Println("[Callback] Passing original tool response through.")
return nil, nil
}知识库
本文档介绍如何在 VeADK-Go 中使用知识库。
导入
import (
"context"
"fmt"
"log"
veagent "github.com/volcengine/veadk-go/agent/llmagent"
"github.com/volcengine/veadk-go/apps"
"github.com/volcengine/veadk-go/apps/agentkit_server_app"
"github.com/volcengine/veadk-go/integrations/ve_tos"
"github.com/volcengine/veadk-go/knowledgebase"
"github.com/volcengine/veadk-go/knowledgebase/backend/viking_knowledge_backend"
"github.com/volcengine/veadk-go/knowledgebase/ktypes"
"google.golang.org/adk/agent"
"google.golang.org/adk/agent/llmagent"
"google.golang.org/adk/session"
)定义
通过 KnowledgeBase 类可以定义一个知识库,并挂载到智能体上。
func main() {
ctx := context.Background()
knowledgeBase, err := knowledgebase.NewKnowledgeBase(
ktypes.VikingBackend,
knowledgebase.WithBackendConfig(
&viking_knowledge_backend.Config{
Index: "...",
CreateIfNotExist: true, // 当 Index 不存在时会自动创建
TosConfig: &ve_tos.Config{
Bucket: "...",
},
}),
)
if err != nil {
log.Fatal("NewVikingKnowledgeBackend error: ", err)
}
veAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Name: "...",
Description: "...",
Instruction: `...`,
},
ModelName: "...",
KnowledgeBase: knowledgeBase,
})
if err != nil {
fmt.Printf("NewLLMAgent failed: %v", err)
return
}
}Tools 定义方法
自定义 Tool
你可以通过撰写一个 Go 函数来定义一个自定义 Tool(你必须清晰的定义好 Docstring):
import (
"context"
"fmt"
"log"
veagent "github.com/volcengine/veadk-go/agent/llmagent"
"github.com/volcengine/veadk-go/apps"
"github.com/volcengine/veadk-go/apps/agentkit_server_app"
"github.com/volcengine/veadk-go/utils"
"google.golang.org/adk/agent"
"google.golang.org/adk/agent/llmagent"
"google.golang.org/adk/tool"
"google.golang.org/adk/tool/functiontool"
)
// CalculatorAddArgs 定义加法工具的入参。使用静态类型,便于 LLM 以 JSON 方式调用。
type CalculatorAddArgs struct {
A float64 `json:"a" jsonschema:"第一个加数,支持整数或小数"`
B float64 `json:"b" jsonschema:"第二个加数,支持整数或小数"`
}
// CalculatorAddTool 返回一个符合 ADK functiontool 规范的工具。
// 该工具用于执行两数相加,并返回 result 字段。
func CalculatorAddTool() (tool.Tool, error) {
handler := func(ctx tool.Context, args CalculatorAddArgs) (map[string]any, error) {
result := args.A + args.B
return map[string]any{
"result": result,
"explain": fmt.Sprintf("%g + %g = %g", args.A, args.B, result),
}, nil
}
return functiontool.New(
functiontool.Config{
Name: "calculator_add",
Description: "一个简单的计算器工具,执行两数相加。参数: a, b; 返回: result(浮点数)",
},
handler,
)
}
func main() {
ctx := context.Background()
rootAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Tools: []tool.Tool{utils.Must(CalculatorAddTool())},
},
})
if err != nil {
log.Fatalf("Failed to create agent: %v", err)
}
app := agentkit_server_app.NewAgentkitServerApp(apps.DefaultApiConfig())
err = app.Run(ctx, &apps.RunConfig{
AgentLoader: agent.NewSingleLoader(rootAgent),
})
if err != nil {
fmt.Printf("Run failed: %v", err)
}
}使用内置工具
你可以通过如下方式将某个工具挂载到智能体上,例如 web_search 网络搜索工具:
import (
"context"
"fmt"
"log"
"os"
veagent "github.com/volcengine/veadk-go/agent/llmagent"
"github.com/volcengine/veadk-go/common"
"github.com/volcengine/veadk-go/tool/builtin_tools/web_search"
"google.golang.org/adk/agent"
"google.golang.org/adk/cmd/launcher"
"google.golang.org/adk/cmd/launcher/full"
"google.golang.org/adk/session"
"google.golang.org/adk/tool"
)
func main() {
ctx := context.Background()
cfg := veagent.Config{
ModelName: "...",
ModelAPIBase: "...",
ModelAPIKey: "...",
}
webSearch, err := web_search.NewWebSearchTool(&web_search.Config{})
if err != nil {
fmt.Printf("NewWebSearchTool failed: %v", err)
return
}
cfg.Tools = []tool.Tool{webSearch}
a, err := veagent.New(&cfg)
if err != nil {
fmt.Printf("NewLLMAgent failed: %v", err)
return
}
config := &launcher.Config{
AgentLoader: agent.NewSingleLoader(a),
SessionService: session.InMemoryService(),
}
l := full.NewLauncher()
if err = l.Execute(ctx, config, os.Args[1:]); err != nil {
log.Fatalf("Run failed: %v\n\n%s", err, l.CommandLineSyntax())
}
}
Enio 与 VeADK-Go 对应规则
你可以通过下面的介绍,来了解 Enio 与 VeADK-Go 对应规则。具体的 VeADK-Go 定义方法可以参照 references/samples/ 目录中的内容。
Enio 常用类型
- ReAct Agent 和 ChatModel 节点:对应 VeADK-Go的 LLM Agent,请参照
references/common/agent.md - RetrieverNode: 对应VeADK-Go的KnowledgeBase,请参照
references/common/knowledgebase.md中的知识库定义和使用方法 - 工具节点/ToolsNode:对应VeADK-Go的工具,请参照
references/common/tools.md - Chain和Graph的固定流程编排:直接用 Go 代码实现。
- 其中不包含大模型的逻辑节点,按照该节点与模型调用以及工具调用的相对位置,封装于 callBack
函数中,VeADK-Go的callBack函数,请参照 references/common/callback.md
Enio 与 VeADK-Go 代码映射示例
1、Agent
Enio 代码实现
React Agent 代码实现
func main() {
// 先初始化所需的 chatModel
toolableChatModel, err := openai.NewChatModel(...)
// 初始化所需的 tools
tools := compose.ToolsNodeConfig{
InvokableTools: []tool.InvokableTool{mytool},
StreamableTools: []tool.StreamableTool{myStreamTool},
}
// 创建 agent
agent, err := react.NewAgent(ctx, &react.AgentConfig{
ToolCallingModel: toolableChatModel,
ToolsConfig: tools,
...
}
}基于chain编排的Agent实现
func main() {
// 初始化 tools
todoTools := []tool.BaseTool{
getAddTodoTool(), // NewTool 构建
}
// 创建并配置 ChatModel
chatModel, err := openai.NewChatModel(context.Background(), &openai.ChatModelConfig{
Model: "...",
APIKey: os.Getenv("OPENAI_API_KEY"),
})
if err != nil {
log.Fatal(err)
}
// 获取工具信息并绑定到 ChatModel
toolInfos := make([]*schema.ToolInfo, 0, len(todoTools))
for _, tool := range todoTools {
info, err := tool.Info(ctx)
if err != nil {
log.Fatal(err)
}
toolInfos = append(toolInfos, info)
}
err = chatModel.BindTools(toolInfos)
if err != nil {
log.Fatal(err)
}
// 创建 tools 节点
todoToolsNode, err := compose.NewToolNode(context.Background(), &compose.ToolsNodeConfig{
Tools: todoTools,
})
if err != nil {
log.Fatal(err)
}
// 构建完整的处理链
chain := compose.NewChain[[]*schema.Message, []*schema.Message]()
chain.
AppendChatModel(chatModel, compose.WithNodeName("chat_model")).
AppendToolsNode(todoToolsNode, compose.WithNodeName("tools"))
// 编译并生成 agent
agent, err := chain.Compile(ctx)
if err != nil {
log.Fatal(err)
}
}
VeADK-Go 代码实现
func main() {
ctx := context.Background()
rootAgent, err := veagent.New(&veagent.Config{
Config: llmagent.Config{
Tools: []tool.Tool{utils.Must(AddTodoTool())},
},
ModelName: "...",
ModelAPIKey: os.Getenv("OPENAI_API_KEY"),
})
if err != nil {
log.Fatalf("Failed to create agent: %v", err)
}
}
2、Tool
Enio 代码实现
- 请注意:VeADK-Go的函数工具参数中,jsonschema标签下的说明,禁止包含'describr=' 或者任何 '***=' 的说明样式。
// 处理函数
func AddTodoFunc(_ context.Context, params *TodoAddParams) (string, error) {
// Mock处理逻辑
return `{"msg": "add todo success"}`, nil
}
func getAddTodoTool() tool.InvokableTool {
// 工具信息
info := &schema.ToolInfo{
Name: "add_todo",
Desc: "Add a todo item",
ParamsOneOf: schema.NewParamsOneOfByParams(map[string]*schema.ParameterInfo{
"content": {
Desc: "The content of the todo item",
Type: schema.String,
Required: true,
},
"started_at": {
Desc: "The started time of the todo item, in unix timestamp",
Type: schema.Integer,
},
"deadline": {
Desc: "The deadline of the todo item, in unix timestamp",
Type: schema.Integer,
},
}),
}
// 使用NewTool创建工具
return utils.NewTool(info, AddTodoFunc)
}VeADK-Go 代码实现
// AddTodoParams 定义加法工具的入参。使用静态类型,便于 LLM 以 JSON 方式调用。
type AddTodoParams struct {
Content string `json:"content" jsonschema:"The content of the todo item"`
StartedAt int64 `json:"started_at" jsonschema:"The started time of the todo item, in unix timestamp"`
Deadline int64 `json:"deadline" jsonschema:"The deadline of the todo item, in unix timestamp"`
}
// AddTodoTool 返回一个符合 ADK functiontool 规范的工具。
func AddTodoTool() (tool.Tool, error) {
handler := func(ctx tool.Context, args AddTodoParams) (map[string]any, error) {
return map[string]any{
"msg": "add todo success",
}, nil
}
return functiontool.New(
functiontool.Config{
Name: "add_todo",
Description: "Add a todo item",
},
handler,
)
}Related skills
FAQ
What conversion does it support?
It converts existing Enio agent code into VeADK-Go agent code using the enio_rule reference.
Where is the generated code saved?
To agent_name/agent.py, where agent_name is a name you choose.