Fix: Add PDF document support for Claude streaming

Co-authored-by: gemini-3.6-flash <noreply@google.com>
This commit is contained in:
2026-07-23 11:04:51 -07:00
parent 25dc642db8
commit 2ce2838895

View File

@@ -158,6 +158,17 @@ export async function streamClaude({ apiKey, body, signal, onDelta, isRunning })
const match = String(p.image_url?.url || p.image_url || '').match(/^data:(image\/\w+);base64,(.*)$/) const match = String(p.image_url?.url || p.image_url || '').match(/^data:(image\/\w+);base64,(.*)$/)
if (match) return { type: 'image', source: { type: 'base64', media_type: match[1], data: match[2] } } if (match) return { type: 'image', source: { type: 'base64', media_type: match[1], data: match[2] } }
} }
if (p.type === 'document' && p.source) return p
if (p.type === 'file' && p.file?.file_data) {
return {
type: 'document',
source: {
type: 'base64',
media_type: 'application/pdf',
data: p.file.file_data,
},
}
}
return null return null
}).filter(Boolean), }).filter(Boolean),
})).filter(m => m.content.length), })).filter(m => m.content.length),