Skip to content

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
@sunyuhan1998
Copy link
Contributor Author

Hi @ilayaperumalg @sobychacko Can you help to review this PR? thanks.

@ilayaperumalg ilayaperumalg self-assigned this Sep 10, 2025
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M2 milestone Sep 10, 2025
@ilayaperumalg
Copy link
Member

@sunyuhan1998 Thanks for the PR! Rebased and merged as 8968df7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OllamaChatModel doesn't respect custom AbstractMessage's implementation
2 participants