Repository navigation
fix(ai): accept uppercase image MIME types in the Cohere route - #59010
Closed
kpmgprd101-ops wants to merge 1 commit into
Closed
kpmgprd101-ops wants to merge 1 commit into
kpmgprd101-ops wants to merge 1 commit into
Conversation
Contributor
|
Thanks for the fix and the clear write-up, including the regression test for both inline and URL images! I think this duplicates #58943, which was opened earlier for the same issue (#58937). It changes the same image check in |
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 for this PR
Closes #58937
Type of change
What does this PR do?
The Cohere Chat protocol checked
part.media.mediaType.startsWith("image/")case-sensitively, soMedia.base64(data, "IMAGE/PNG")(or a URL asset declaredImage/Png) fell through to the unsupported-content error: Cohere Chat user messages only support text and media content for now. Every other route that classifies media lowercases the type first (anthropic-messages, mistral-chat), which is why they accepted both spellings. The fix lowercases before the prefix check, one line inpackages/ai/src/protocols/cohere-chat.ts.The data URL itself already comes out lowercase (media.ts normalizes it), so no wire-format change.
How did you verify your code works?
IMAGE/PNGbase64 image and a URL image declaredImage/Png; it asserts both lower toimage_urlblocks. It fails with the exact error from the issue without the fix and passes with it.packages/aisuite: 1920 tests, 0 failures.bun check(no type errors) andbiome checkclean on the touched files.Screenshots / recordings
N/A (protocol compile only).
Checklist