mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Recognize image content when talking to anthropic (#37)
This commit is contained in:
parent
7326682c94
commit
4ee4f2060d
@ -20,6 +20,22 @@ function convertContentToAnthropic(content: any): ContentBlockParam[] {
|
|||||||
if (content.type === "text" && typeof content.text === "string") {
|
if (content.type === "text" && typeof content.text === "string") {
|
||||||
return [{ type: "text", text: content.text }];
|
return [{ type: "text", text: content.text }];
|
||||||
}
|
}
|
||||||
|
if (content.type == "image" && typeof content.image == "string") {
|
||||||
|
// Parse data URL to extract content type and base64 data
|
||||||
|
const matches = content.image.match(/^data:([^;]+);base64,(.+)$/);
|
||||||
|
if (!matches) {
|
||||||
|
console.log("Invalid image data URL format");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return [{
|
||||||
|
type: "image",
|
||||||
|
source: {
|
||||||
|
type: "base64",
|
||||||
|
data: matches[2],
|
||||||
|
media_type: matches[1]
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
console.log("AnthropicUnknownContent", JSON.stringify(content, null, 2));
|
console.log("AnthropicUnknownContent", JSON.stringify(content, null, 2));
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user