mirror of
https://github.com/sune-org/ORP.git
synced 2026-01-13 16:17:59 +00:00
Fix: Ensure Claude messages and content are non-empty
This commit is contained in:
4
index.js
4
index.js
@@ -228,13 +228,13 @@ export class MyDurableObject {
|
||||
messages: body.messages.filter(m => m.role !== 'system').map(m => ({
|
||||
role: m.role,
|
||||
content: typeof m.content === 'string' ? m.content : (m.content || []).map(p => {
|
||||
if (p.type === 'text') return { type: 'text', text: p.text };
|
||||
if (p.type === 'text' && p.text) return { type: 'text', text: p.text };
|
||||
if (p.type === 'image_url') {
|
||||
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] } };
|
||||
}
|
||||
}).filter(Boolean)
|
||||
})),
|
||||
})).filter(m => m.content.length),
|
||||
max_tokens: body.max_tokens || 64000,
|
||||
stream: true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user