| 29 | |
| 30 | // Check if a message is a synthetic user msg used to attach an image from a tool call |
| 31 | function imgMsg(msg: any): boolean { |
| 32 | if (msg?.role !== "user") return false |
| 33 | |
| 34 | // Handle the 3 api formats |
| 35 | |
| 36 | const content = msg.content |
| 37 | if (typeof content === "string") return content === MessageV2.SYNTHETIC_ATTACHMENT_PROMPT |
| 38 | if (!Array.isArray(content)) return false |
| 39 | return content.some( |
| 40 | (part: any) => |
| 41 | (part?.type === "text" || part?.type === "input_text") && part.text === MessageV2.SYNTHETIC_ATTACHMENT_PROMPT, |
| 42 | ) |
| 43 | } |
| 44 | |
| 45 | function fix(model: Model, url: string): Model { |
| 46 | return { |