Skip to content

fix: GH-3998 Refactor the ollamaChatRequest method of OllamaChatModel #3999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sunyuhan1998
Copy link
Contributor

As mentioned in the issue #3998 , when OllamaChatModel constructs the OllamaApi.ChatRequest, it directly uses instanceof to identify the Message type. This approach restricts users from customizing their own implementations of AbstractMessage and is also inconsistent with the implementation of other ChatModels (e.g., org.springframework.ai.openai.OpenAiChatModel#createRequest and org.springframework.ai.deepseek.DeepSeekChatModel#createRequest).

This PR resolves the issue by unifying the implementation: message type identification is now performed using MessageType.

Fixes #3998

…ama.OllamaChatModel#ollamaChatRequest` to support custom implementations of `AbstractMessage` and align with other `ChatModel` implementations.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998 sunyuhan1998 changed the title refactor: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… fix: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… Aug 5, 2025
@sunyuhan1998 sunyuhan1998 changed the title fix: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… fix: GH-3998 Refactor the ollamaChatRequest method of OllamaChatModel Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OllamaChatModel doesn't respect custom AbstractMessage's implementation
1 participant