✨ add image support to Cohere

This commit is contained in:
Maxime Brunet 2025-06-14 17:10:23 -03:00
parent c0174b6074
commit 6cf992e03b
No known key found for this signature in database
GPG key ID: 437962FF87ECFE2B
2 changed files with 20 additions and 1 deletions

View file

@ -66,6 +66,7 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [
const PROVIDER_SUPPORTS_IMAGES: string[] = [
"openai",
"ollama",
"cohere",
"gemini",
"msty",
"anthropic",
@ -90,6 +91,8 @@ const MODEL_SUPPORTS_IMAGES: string[] = [
"gpt-4o-mini",
"gpt-4-vision",
"claude-3",
"c4ai-aya-vision-8b",
"c4ai-aya-vision-32b",
"gemini-ultra",
"gemini-1.5-pro",
"gemini-1.5-flash",

View file

@ -26,9 +26,25 @@ class Cohere extends BaseLLM {
}
switch (m.role) {
case "user":
if (typeof m.content === "string") {
messages.push({
role: m.role,
content: m.content,
});
break;
}
messages.push({
role: m.role,
content: m.content,
content: m.content.map((part) => {
if (part.type === "imageUrl") {
return {
type: "image_url",
image_url: { url: part.imageUrl.url },
};
}
return part;
}),
});
break;
case "thinking":