spring-projects / spring-projects/spring-ai
The same code works normally with dashScopeChatModel, but fails to call tools when switching to OllamaChatModel.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:
Bug description
Ollama model prompts "unsupported tool calling" when invoking tools, but the model actually supports this feature.
Environment
spring ai 1.1.0 spring 3.4.5 spring-ai-starter-model-ollama 1.1.0
Steps to reproduce
@Bean
@Qualifier("ollamaChatClient")
ChatClient ollamaChatClient(ChatMemory chatMemory, OllamaChatProperties ollamaChatProperties) {
//这里可以设置温度等参数
OllamaChatOptions ollamaOptions = ollamaChatProperties.getOptions();
ollamaOptions.setTemperature(0.8);
return ChatClient.builder(ollamaChatModel)
//加上这个就会把请求前后的日志打印出来,记得设置logging.level.org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor=DEBUG
.defaultAdvisors(new SimpleLoggerAdvisor()
// 加上这个就会过滤掉一些敏感的问题,又敏感
,new SafeGuardAdvisor(List.of("吃饭"),"你触发了敏感词,这个不能问",1)
// 加上这个自定义的拦截器 就会重写提示词
//,new RewritePromptAdvisor()
//加上这个拦截器 会把history 历史记录 存在内存中,然后每次请求都带上历史记录,起到回话记录的作用
//,PromptChatMemoryAdvisor.builder(chatMemory).build()
)
.defaultSystem("你是一个公司在线客服,请以客服身份对话,不能编造问题,中文回答")
.defaultOptions(ollamaOptions)
.defaultTools(toolsService)// ollma 调用工具有问题 某些支持function的模型 spring ai貌似也不支持
.build();
}
Expected behavior
Minimal Complete Reproducible example
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided ChatClient reproduction and compare tool-calling behavior between dashScopeChatModel and OllamaChatModel under Spring AI 1.1.0. Investigate the Ollama integration's handling of the model's tool support; done means a supported Ollama model invokes the configured tools without an "unsupported tool calling" error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, ollama, spring
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100