spring-projects / spring-projects/spring-ai
OllamaApi.ChatResponse.model field is not correctly merged in OllamaApiHelper.merge(ChatResponse, ChatResponse)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description
OllamaApi.ChatResponse.model field is not correctly merged in OllamaApiHelper.merge(ChatResponse, ChatResponse).
Ollama returns the full model name in each part of a streamed result. As the parts are merged the model names are concatenated, which results in an invalid value.
Environment
Spring AI 1.1
Steps to reproduce
Create two OllamaApi.ChatResonse objects with the model value set. Run them through OllamaApiHelper.merge. In the result the model values are concatenated.
Expected behavior
The value for field model should be taken from one of the parts where it is not null in the same way as the field done is handled.
Minimal Complete Reproducible example
The OllamaApiHelperTests class contans a unittest for this. However, the expected result for the model value is wrong in this test and should be adjusted in accordance with what is described under "Expected behavior" above.
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 OllamaApiHelper.merge(ChatResponse, ChatResponse) in models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApiHelper.java and inspect the existing OllamaApiHelperTests case around line 152. Update the merge behavior and the test expectation so the model value is selected from a non-null part rather than concatenated, then run the relevant test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100