Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ai/src/protocols/cohere-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const fromRequest = Effect.fn("CohereChat.fromRequest")(function* (request: LLMR
calls.push({ id: part.id, type: "function", function: { name: part.name, arguments: args } })
continue
}
if (message.role === "user" && part.type === "media" && part.media.mediaType.startsWith("image/")) {
if (message.role === "user" && part.type === "media" && part.media.mediaType.toLowerCase().startsWith("image/")) {
const url =
ProviderShared.mediaUrl(part.media) ??
(yield* ProviderShared.requireInlineMedia("Cohere Chat", part.media)).dataUrl
Expand Down
25 changes: 25 additions & 0 deletions packages/ai/test/provider/cohere.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,31 @@ it.effect("Cohere rejects unsupported media instead of silently dropping it", ()
}),
)

it.effect("Cohere accepts image media regardless of MIME type casing", () =>
Effect.gen(function* () {
const prepared = yield* compileRequest(
LLM.request({
model: cohere.model("command-a-03-2025"),
messages: [
Message.user([
{ type: "media", media: Media.base64("aGVsbG8=", "IMAGE/PNG") },
{ type: "media", media: Media.url("https://files.example/pic.png", { mediaType: "Image/Png" }) },
]),
],
}),
)
expect(prepared.body.messages).toMatchObject([
{
role: "user",
content: [
{ type: "image_url", image_url: { url: "data:image/png;base64,aGVsbG8=" } },
{ type: "image_url", image_url: { url: "https://files.example/pic.png" } },
],
},
])
}),
)

it.effect("Cohere thinking budgets must be positive integers", () =>
Effect.gen(function* () {
const error = yield* compileRequest(
Expand Down
Loading