Bug description
When using the ChatClient
implementation for Ollama, any Message
included in the Prompt
with a SYSTEM
message type is explicitly excluded when building the ChatRequest
for calling Ollama.
Code where the System messages are excluded: https://github.com/spring-projects/spring-ai/blob/08fa0e393c4df5331aa0cd7bdb7e0b66e2782a4a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java#L125-L126
Environment Spring AI: 0.8.0-SNAPSHOT (as of today, January 22nd) Java: 21 Ollama
Expected behavior
I would expect SYSTEM
messages to be included in the requests sent to Ollama, similar to how OpenAI works. Ollama supports system messages as described in the documentation,
Minimal Complete Reproducible example Sample project reproducing the error is available here: https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/02-prompts/prompts-messages-ollama. It's a self-contained example with no external dependency other than Java 21 and Docker (no need to install Ollama, the application takes care of that).
Comment From: tzolov
@ThomasVitale thank you for raising this issue. It is a but indeed and the fix is under way.