Repository navigation
fix: forward image detailLevel in Azure OpenAI chat requests - #6220
Open
Lubaoshuai wants to merge 1 commit into
Open
Lubaoshuai wants to merge 1 commit into
Lubaoshuai wants to merge 1 commit into
Conversation
InternalAzureOpenAiHelper.toOpenAiMessage() built ChatMessageImageUrl from the URL only and never called setDetail(...), so the user-specified image detail level (LOW/HIGH/AUTO) was silently dropped and Azure always applied its server default. This also disagreed with AzureOpenAiTokenCountEstimator, which is detail-aware, and with the langchain4j-open-ai module, which forwards the detail level. Mapped ImageContent.DetailLevel to the Azure SDK ChatMessageImageDetailLevel following the same approach as OpenAiUtils.toDetail(): null stays null and unsupported values (MEDIUM, ULTRA_HIGH) throw UnsupportedFeatureException instead of being silently lost. Fixes langchain4j#5508
This branch has not been deployed
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.
Issue
Closes #5508
Change
InternalAzureOpenAiHelper.toOpenAiMessage()builtChatMessageImageUrlfrom the URL only and never calledsetDetail(...), so the user-specified image detail level was silently dropped and Azure always applied its server default.This PR maps
ImageContent.DetailLevelto the Azure SDKChatMessageImageDetailLeveland forwards it in the request:LOW/HIGH/AUTOare forwarded as-is.nulldetail level is not sent.MEDIUM,ULTRA_HIGH) now throwUnsupportedFeatureExceptioninstead of being silently lost — the same approach the siblinglangchain4j-open-aimodule uses inOpenAiUtils.toDetail(...).This also makes the request consistent with
AzureOpenAiTokenCountEstimator.estimateImageTokens(), which is already detail-aware (so token estimation and the actual request no longer disagree).General checklist
mvn -pl langchain4j-azure-open-ai test: 72 tests, 0 failures)DetailLevelsemantics)