mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
fix: new edge cases with function calls / tools
This commit is contained in:
parent
1256614ec2
commit
9cbb741a8a
@ -551,6 +551,10 @@ class AIChatService extends BaseService {
|
||||
async moderate ({ messages }) {
|
||||
for ( const msg of messages ) {
|
||||
const texts = [];
|
||||
|
||||
// Function calls have no content
|
||||
if ( msg.content === null ) continue;
|
||||
|
||||
if ( typeof msg.content === 'string' ) texts.push(msg.content);
|
||||
else if ( typeof msg.content === 'object' ) {
|
||||
if ( Array.isArray(msg.content) ) {
|
||||
|
@ -258,6 +258,9 @@ class OpenAICompletionService extends BaseService {
|
||||
throw new Error('each message must be a string or an object');
|
||||
}
|
||||
if ( ! msg.role ) msg.role = 'user';
|
||||
if ( msg.role === 'assistant' && ! msg.content ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! msg.content ) {
|
||||
throw new Error('each message must have a `content` property');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user