Project home: README.md.
Chinese documentation: README-zh.md.
This example shows how to wrap a Go function as an AgentScope tool:
- Declare a tool name, description, and JSON Schema.
- Implement a synchronous function handler.
- Execute the tool and accumulate
ToolChunkvalues into aToolResponse. - Let DashScope ChatModel request the
Greettool, execute the tool locally, send aToolResultBlockback, and print the final model response.
- Go 1.26.3.
AI_DASHSCOPE_API_KEYfor the DashScope model -> tool call -> tool result loop.
cd example/tool/function
go run .Output includes:
function_tool=Greet
chat_tool=Greet