Added official file support
This commit is contained in:
+8
-1
@@ -25,6 +25,13 @@ export class OpenAi extends LLMProvider {
|
||||
return client;
|
||||
}
|
||||
|
||||
private toWireContent(content: any): any {
|
||||
if(!Array.isArray(content)) return content;
|
||||
return content.map(c => c.type === 'image'
|
||||
? {type: 'image_url', image_url: {url: `data:${c.mime};base64,${c.data}`}}
|
||||
: {type: 'text', text: c.text});
|
||||
}
|
||||
|
||||
/** Convert standard history -> OpenAI wire format */
|
||||
private toWire(history: LLMMessage[], system?: string): any[] {
|
||||
const wire: any[] = [];
|
||||
@@ -41,7 +48,7 @@ export class OpenAi extends LLMProvider {
|
||||
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