此时如果上下文中有多个模型则会运行报错: Caused by: dev.langchain4j.service.IllegalConfigurationException: Conflict: multiple beans of type dev.langchain4j.model.chat.ChatLanguageModel are found: [ollamaChatModel, openAiChatModel]. Please specify which one you wish to wire in the @AiService annotation like this: @AiService(wiringMode = EXPLICIT, chatModel = "<beanName>").,需要在@AiService中明确执行使用哪一个模型,修改接口如下:
@AiService(wiringMode = EXPLICIT, chatModel = "openAiChatModel") public interface Assistent {
String chat(String prompt);
}
再次重新运行则正常输出相应内容
2025-12-11T16:01:08.799+08:00 DEBUG 50574 --- [Http TaskRunner] okhttp3.internal.concurrent.TaskRunner : Q10005 finished run in 189 µs: OkHttp ConnectionPool AI Response: 你好!不过我还不太了解你,所以无法准确地介绍你。如果你愿意告诉我一些关于你的信息——比如你的兴趣爱好、职业、学习背景、所在地区,或者你希望别人怎么看待你——我很乐意根据你提供的内容,帮你写一段个性化的自我介绍!😊