Remove sharp processing and use original images in requests

This commit is contained in:
Saoud Rizwan
2024-08-08 07:15:14 -04:00
parent 77cbbbfe49
commit b6a8c03317
9 changed files with 49 additions and 606 deletions

View File

@@ -311,10 +311,15 @@ export class ClaudeDev {
private formatImagesIntoBlocks(images?: string[]): Anthropic.ImageBlockParam[] {
return images
? images.map((base64) => ({
type: "image",
source: { type: "base64", media_type: "image/webp", data: base64 },
}))
? images.map((dataUrl) => {
// data:image/png;base64,base64string
const [rest, base64] = dataUrl.split(",")
const mimeType = rest.split(":")[1].split(";")[0]
return {
type: "image",
source: { type: "base64", media_type: mimeType, data: base64 },
} as Anthropic.ImageBlockParam
})
: []
}