官网上的样例执行出现出下错误信息Exception: 400 - {"request_id":"9109859d-1bb9-9b2b-ab66-bb3100af743a","code":"InvalidParameter","message":"<400> InternalError.Algo.InvalidParameter: The \"function.arguments\" parameter of the code model must be in JSON format."} #4522
Unanswered
renjia-idea
asked this question in
Q&A
Replies: 1 comment
-
|
我也是报这个错,直接用回ChatClient了,有点坑 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
官网的例子
// 初始化 ChatModel
DashScopeApi dashScopeApi = DashScopeApi.builder()
.apiKey(System.getenv("AI_DASHSCOPE_API_KEY"))
.build();
ChatModel chatModel = DashScopeChatModel.builder()
.dashScopeApi(dashScopeApi)
.build();
// 定义天气查询工具
public class WeatherTool implements BiFunction<String, ToolContext, String> {
@OverRide
public String apply(String city, ToolContext toolContext) {
return "It's always sunny in " + city + "!";
}
}
ToolCallback weatherTool = FunctionToolCallback.builder("get_weather", new WeatherTool())
.description("Get weather for a given city")
.inputType(String.class)
.build();
// 创建 agent
ReactAgent agent = ReactAgent.builder()
.name("weather_agent")
.model(chatModel)
.tools(weatherTool)
.systemPrompt("You are a helpful assistant")
.saver(new MemorySaver())
.build();
// 运行 agent
AssistantMessage response = agent.call("what is the weather in San Francisco");
System.out.println(response.getText());
Beta Was this translation helpful? Give feedback.
All reactions