@@ -35,6 +35,7 @@ import type {
35
35
ChatCompletionChunk ,
36
36
Completions as ChatCompletions ,
37
37
} from 'openai/resources/chat/completions' ;
38
+ // @ts -ignore openai/core not exported in v5, but needed for v4 compatibility
38
39
import type { APIPromise } from 'openai/core' ;
39
40
import type {
40
41
CreateEmbeddingResponse ,
@@ -227,6 +228,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
227
228
228
229
// Non-streaming.
229
230
apiPromise
231
+ // @ts -ignore result type inference fails across OpenAI versions
230
232
. then ( result => {
231
233
self . _onChatCompletionsCreateResult (
232
234
span ,
@@ -372,7 +374,9 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
372
374
id : tc . id ,
373
375
type : tc . type ,
374
376
function : {
377
+ // @ts -ignore function property doesn't exist on ChatCompletionMessageCustomToolCall in v5
375
378
name : tc . function . name ,
379
+ // @ts -ignore function property doesn't exist on ChatCompletionMessageCustomToolCall in v5
376
380
arguments : tc . function . arguments ,
377
381
} ,
378
382
} ;
@@ -382,6 +386,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
382
386
return {
383
387
id : tc . id ,
384
388
type : tc . type ,
389
+ // @ts -ignore function property doesn't exist on ChatCompletionMessageCustomToolCall in v5
385
390
function : { name : tc . function . name } ,
386
391
} ;
387
392
} ) ;
@@ -492,6 +497,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
492
497
} ) ;
493
498
} else if ( toolCalls . length > 0 ) {
494
499
// A tool call chunk with more of the `function.arguments`.
500
+ // @ts -ignore function property doesn't exist on ChatCompletionMessageCustomToolCall in v5
495
501
toolCalls [ toolCalls . length - 1 ] . function . arguments +=
496
502
toolCallPart . function ?. arguments ?? '' ;
497
503
}
@@ -551,8 +557,10 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
551
557
message . content = choice . content ;
552
558
}
553
559
if ( choice . toolCalls && choice . toolCalls . length > 0 ) {
560
+ // @ts -ignore ChatCompletionMessageToolCall union type incompatible with GenAIToolCall in v5
554
561
message . tool_calls = choice . toolCalls ;
555
562
if ( ! config . captureMessageContent ) {
563
+ // @ts -ignore message.tool_calls possibly undefined
556
564
message . tool_calls . forEach ( tc => {
557
565
delete tc . function ?. arguments ;
558
566
} ) ;
@@ -621,6 +629,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
621
629
message . content = choice . message . content ;
622
630
}
623
631
if ( choice . message . tool_calls ) {
632
+ // @ts -ignore ChatCompletionMessageToolCall union type incompatible with GenAIToolCall in v5
624
633
message . tool_calls = choice . message . tool_calls ;
625
634
}
626
635
} else {
@@ -629,6 +638,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<OpenAIInstrumenta
629
638
return {
630
639
id : tc . id ,
631
640
type : tc . type ,
641
+ // @ts -ignore function property doesn't exist on ChatCompletionMessageCustomToolCall in v5
632
642
function : { name : tc . function . name } ,
633
643
} ;
634
644
} ) ;
0 commit comments