Added official file support
This commit is contained in:
+8
-1
@@ -24,6 +24,13 @@ export class Anthropic extends LLMProvider {
|
||||
return client;
|
||||
}
|
||||
|
||||
private toWireContent(content: any): any {
|
||||
if(!Array.isArray(content)) return content;
|
||||
return content.map(c => c.type === 'image'
|
||||
? {type: 'image', source: {type: 'base64', media_type: c.mime, data: c.data}}
|
||||
: {type: 'text', text: c.text});
|
||||
}
|
||||
|
||||
/** Convert standard history -> Anthropic wire format */
|
||||
private toWire(history: LLMMessage[]): any[] {
|
||||
const wire: any[] = [];
|
||||
@@ -34,7 +41,7 @@ export class Anthropic extends LLMProvider {
|
||||
{role: 'user', content: [{type: 'tool_result', tool_use_id: h.id, is_error: !!h.error, content: h.error || h.content || ''}]}
|
||||
);
|
||||
} else {
|
||||
wire.push({role: h.role, content: h.content});
|
||||
wire.push({role: h.role, content: this.toWireContent(h.content)});
|
||||
}
|
||||
}
|
||||
return wire;
|
||||
|
||||
Reference in New Issue
Block a user