| 203 | |
| 204 | // to avoid circular dependency |
| 205 | const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[] => { |
| 206 | return images |
| 207 | ? images.map((dataUrl) => { |
| 208 | // data:image/png;base64,base64string |
| 209 | const [rest, base64] = dataUrl.split(",") |
| 210 | const mimeType = rest.split(":")[1].split(";")[0] |
| 211 | return { |
| 212 | type: "image", |
| 213 | source: { type: "base64", media_type: mimeType, data: base64 }, |
| 214 | } as Anthropic.ImageBlockParam |
| 215 | }) |
| 216 | : [] |
| 217 | } |
| 218 | |
| 219 | const toolUseInstructionsReminderNative = `# Reminder: Instructions for Tool Use |
| 220 | |