Support image media in DeepSeek chat requests - #6980
Open
Lubaoshuai wants to merge 4 commits into
Open
Lubaoshuai wants to merge 4 commits into
Lubaoshuai wants to merge 4 commits into
Conversation
DeepSeekChatModel.createRequest only read message.getText() for USER messages, so Media attached to a UserMessage was silently dropped and vision-capable models such as deepseek-flash received a text-only request. Map user message media to the OpenAI-compatible content array that the DeepSeek vision API documents (text and image_url chunks), mirroring the Mistral AI adapter: ChatCompletionMessage.content is now a polymorphic String-or-ContentChunk-list with custom JSON serialization, text-only messages are unchanged, and byte[] media is inlined as a base64 data URI. Fixes spring-projects#6978 Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
|
In addition, the default model should be changed to DEEPSEEK_FLASH, as DEEPSEEK_V4_FLASH has now been officially replaced by the official release. |
Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
…onIT.java) Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
Lubaoshuai
force-pushed
the
fix/deepseek-vision-media
branch
from
September 15, 2026 13:36
e0441d7 to
47c05a3
Compare
Contributor
Author
|
Thanks @lilingshan — done. Also noticed the DCO check was stuck pending because the three review-follow-up commits were missing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6978
Problem
DeepSeekChatModel.createRequestonly readmessage.getText()for USER messages, so anyMediaattached to aUserMessagewas silently dropped: a vision-capable model such asdeepseek-flashreceived a text-only request, with no error telling the caller the image was discarded.Solution
Map user message media to the OpenAI-compatible multimodal content array that the DeepSeek vision documentation describes (
textandimage_urlblocks), mirroring the approach the Mistral AI adapter already uses:DeepSeekApi.ChatCompletionMessage.contentis now a polymorphicString-or-ContentChunk-list with a custom serializer/deserializer, so text-only messages serialize exactly as before while multimodal user messages serialize as[{"type":"text",...},{"type":"image_url",...}].ContentChunk,TextChunkandImageUrlChunk(whoseImageUrlsupports base64 data URIs forbyte[]media;Stringmedia data is passed through as a URL).DeepSeekChatModelmaps user message media on both the synchronous and streaming paths (both go throughcreateRequest).String.Tests
New tests in
DeepSeekChatCompletionRequestTests:image_urlchunkbyte[]media is inlined as adata:image/png;base64,...URIFull
spring-ai-deepseekmodule run: 48 tests, all passing.