您好,我目前使用的模型是qwen-turbo-2025-04-28。我想实现他调用Tool的功能。
这是我的tools配置
@Slf4j
public class DateTimeTools {
@Tool(description = "查询当前的系统时间")
public String getCurrentDateTime() {
log.info("DateTimeTools:调用了getCurrentDateTime");
return "2025-05-15";
}
@Tool(description = "Get the time of a specified city.")
public String getCityTimeMethod(@ToolParam(description = "Time zone id, such as Asia/Shanghai") String timeZoneId) {
log.info("The current time zone is {}", timeZoneId);
return String.format("The current time zone is %s and the current time is " + "%s", timeZoneId, "111");
}
}
我为了防止中英文模型的理解能力,我写了一个中文还有一个英文。
这是我注入ChatClient的代码
@Bean
public ChatClient chatClient() {
return ChatClient.builder(dashScopeChatModel)
.defaultSystem("你是我的企业知识库AI客服助手,请帮我解答我提出的相关问题")
.defaultTools(new DateTimeTools())
.defaultAdvisors(
new QuestionAnswerAdvisor(vectorStore, SearchRequest.builder().similarityThreshold(0.7).build()),
new SimpleLoggerAdvisor()
).build();
}
这是我调用chatClient的代码
@GetMapping("/chat")
public RestResult<String> chat(@RequestParam(value = "conversationId") String conversationId,
@RequestParam(value = "message") String message) {
return RestResult.buildSuccessResult(chatClient.prompt()
.user(message)
// .functions("weatherFunction")
.advisors(new ChatMessageAdvisor(dbChatMemory, conversationId))
.call()
.content());
}
不管我怎么问,就是没办法调用我写的tool。
大神帮忙看一下,谢谢啦
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
您好,这里是通义灵码问答区,如果使用通义灵码有问题,欢迎加入我们的钉钉答疑群,第一时间为您服务:钉钉群:53770000738
基于通义系列大模型和开源大模型的一站式大模型服务平台,提供「生成式大模型的全流程应用工具」和「企业大模型的全链路训练工具」。为大模型,也为小应用。 阿里云百炼官网网址:https://www.aliyun.com/product/bailian