@@ -599,6 +599,7 @@ export class RealtimeSession extends multimodal.RealtimeSession {
599
599
temperature = this . #opts. temperature ,
600
600
maxResponseOutputTokens = this . #opts. maxResponseOutputTokens ,
601
601
toolChoice = 'auto' ,
602
+ selectedTools = Object . keys ( this . #fncCtx || { } ) ,
602
603
} : {
603
604
modalities : [ 'text' , 'audio' ] | [ 'text' ] ;
604
605
instructions ?: string ;
@@ -610,6 +611,7 @@ export class RealtimeSession extends multimodal.RealtimeSession {
610
611
temperature ?: number ;
611
612
maxResponseOutputTokens ?: number ;
612
613
toolChoice ?: api_proto . ToolChoice ;
614
+ selectedTools ?: string [ ] ;
613
615
} ) {
614
616
this . #opts = {
615
617
modalities,
@@ -630,16 +632,18 @@ export class RealtimeSession extends multimodal.RealtimeSession {
630
632
} ;
631
633
632
634
const tools = this . #fncCtx
633
- ? Object . entries ( this . #fncCtx) . map ( ( [ name , func ] ) => ( {
634
- type : 'function' as const ,
635
- name,
636
- description : func . description ,
637
- parameters :
638
- // don't format parameters if they are raw openai params
639
- func . parameters . type == ( 'object' as const )
640
- ? func . parameters
641
- : llm . oaiParams ( func . parameters ) ,
642
- } ) )
635
+ ? Object . entries ( this . #fncCtx)
636
+ . filter ( ( [ name ] ) => selectedTools . includes ( name ) )
637
+ . map ( ( [ name , func ] ) => ( {
638
+ type : 'function' as const ,
639
+ name,
640
+ description : func . description ,
641
+ parameters :
642
+ // don't format parameters if they are raw openai params
643
+ func . parameters . type == ( 'object' as const )
644
+ ? func . parameters
645
+ : llm . oaiParams ( func . parameters ) ,
646
+ } ) )
643
647
: [ ] ;
644
648
645
649
const sessionUpdateEvent : api_proto . SessionUpdateEvent = {
0 commit comments