File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
packages/internal/src/openai-compatible/chat Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -512,28 +512,24 @@ export class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
512512 const index = toolCallDelta . index ;
513513
514514 if ( toolCalls [ index ] == null ) {
515- if ( toolCallDelta . id == null ) {
516- throw new InvalidResponseDataError ( {
517- data : toolCallDelta ,
518- message : `Expected 'id' to be a string.` ,
519- } ) ;
520- }
521-
522515 if ( toolCallDelta . function ?. name == null ) {
523516 throw new InvalidResponseDataError ( {
524517 data : toolCallDelta ,
525518 message : `Expected 'function.name' to be a string.` ,
526519 } ) ;
527520 }
528521
522+ // UPDATED (James): Generate an ID if the provider doesn't include one (e.g., GLM models)
523+ const toolCallId = toolCallDelta . id ?? generateId ( ) ;
524+
529525 controller . enqueue ( {
530526 type : 'tool-input-start' ,
531- id : toolCallDelta . id ,
527+ id : toolCallId ,
532528 toolName : toolCallDelta . function . name ,
533529 } ) ;
534530
535531 toolCalls [ index ] = {
536- id : toolCallDelta . id ,
532+ id : toolCallId ,
537533 type : 'function' ,
538534 function : {
539535 name : toolCallDelta . function . name ,
You can’t perform that action at this time.
0 commit comments