(messages)
| 82 | } |
| 83 | |
| 84 | function normalizeBinary(messages) { |
| 85 | if (!Array.isArray(messages)) return messages; |
| 86 | return messages.map(m => { |
| 87 | if (!Array.isArray(m.content)) return m; |
| 88 | return { ...m, content: m.content.map(p => { |
| 89 | if (p.type === 'image_url' && typeof p.image_url?.url === 'string' && p.image_url.url.startsWith('data:')) |
| 90 | return { ...p, image_url: { ...p.image_url, url: normalizeDataUrl(p.image_url.url) } }; |
| 91 | if (p.type === 'image' && p.source?.type === 'base64') |
| 92 | return { ...p, source: { ...p.source, data: digestBase64Data(p.source.data, p.source.media_type) } }; |
| 93 | if ((p.type === 'file' || p.type === 'input_file') && typeof p.file?.file_data === 'string' && p.file.file_data.startsWith('data:')) |
| 94 | return { ...p, file: { ...p.file, file_data: normalizeDataUrl(p.file.file_data) } }; |
| 95 | return p; |
| 96 | })}; |
| 97 | }); |
| 98 | } |
| 99 | |
| 100 | function normalize(body) { |
| 101 | return { |
no test coverage detected