Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Latest commit

 

History

History

function

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Function Tool Example

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 ToolChunk values into a ToolResponse.
  • Let DashScope ChatModel request the Greet tool, execute the tool locally, send a ToolResultBlock back, and print the final model response.

Prerequisites

  • Go 1.26.3.
  • AI_DASHSCOPE_API_KEY for the DashScope model -> tool call -> tool result loop.

Run

cd example/tool/function
go run .

Expected Output

Output includes:

function_tool=Greet
chat_tool=Greet