File tree 2 files changed +7
-0
lines changed
src/backend/src/modules/puterai
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -551,6 +551,10 @@ class AIChatService extends BaseService {
551
551
async moderate ( { messages } ) {
552
552
for ( const msg of messages ) {
553
553
const texts = [ ] ;
554
+
555
+ // Function calls have no content
556
+ if ( msg . content === null ) continue ;
557
+
554
558
if ( typeof msg . content === 'string' ) texts . push ( msg . content ) ;
555
559
else if ( typeof msg . content === 'object' ) {
556
560
if ( Array . isArray ( msg . content ) ) {
Original file line number Diff line number Diff line change @@ -258,6 +258,9 @@ class OpenAICompletionService extends BaseService {
258
258
throw new Error ( 'each message must be a string or an object' ) ;
259
259
}
260
260
if ( ! msg . role ) msg . role = 'user' ;
261
+ if ( msg . role === 'assistant' && ! msg . content ) {
262
+ continue ;
263
+ }
261
264
if ( ! msg . content ) {
262
265
throw new Error ( 'each message must have a `content` property' ) ;
263
266
}
You can’t perform that action at this time.
0 commit comments