From 0958119bba81e3a21ee7dfc266489498fd3fa5e9 Mon Sep 17 00:00:00 2001 From: ufo001sos002 Date: Tue, 28 Jul 2026 21:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E5=BC=80=E5=A7=8B-=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E4=B8=80=E4=B8=AA=E5=9F=BA=E7=A1=80=20Agent-=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E4=BB=A3=E7=A0=81=E8=BF=90=E8=A1=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 参考 https://help.aliyun.com/zh/model-studio/qwen-api-via-dashscope#2a1c410015otp 接口文档,请求体messages->Assistant Message类型tool_calls中function.arguments 【入参信息,为JSON格式字符串】 --- docs/quick-start.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/quick-start.md b/docs/quick-start.md index 033114e5..64557bf1 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -76,17 +76,24 @@ ChatModel chatModel = DashScopeChatModel.builder() .dashScopeApi(dashScopeApi) .build(); +// 定义天气查询请求参数 +record WeatherRequest(String city) { +} +// 定义天气查询响应 +record WeatherResponse(String weather) { +} + // 定义天气查询工具 -public class WeatherTool implements BiFunction { +class WeatherTool implements BiFunction { @Override - public String apply(String city, ToolContext toolContext) { - return "It's always sunny in " + city + "!"; + public WeatherResponse apply(WeatherRequest weatherRequest, ToolContext toolContext) { + return new WeatherResponse("It's always sunny in " + weatherRequest.city + "!"); } } ToolCallback weatherTool = FunctionToolCallback.builder("get_weather", new WeatherTool()) .description("Get weather for a given city") - .inputType(String.class) + .inputType(WeatherRequest.class) .build(); // 创建 agent