22
33using OpenAI . Extensions ;
44using OpenAI . Models ;
5+ using System ;
56using System . Collections . Generic ;
67using System . Linq ;
78using System . Text . Json . Serialization ;
@@ -12,14 +13,46 @@ public class SessionConfiguration
1213 {
1314 public SessionConfiguration ( ) { }
1415
16+ [ Obsolete ( "use new ctor overload" ) ]
17+ public SessionConfiguration (
18+ Model model ,
19+ Modality modalities ,
20+ Voice voice ,
21+ string instructions ,
22+ RealtimeAudioFormat inputAudioFormat ,
23+ RealtimeAudioFormat outputAudioFormat ,
24+ Model transcriptionModel ,
25+ IVoiceActivityDetectionSettings turnDetectionSettings ,
26+ IEnumerable < Tool > tools ,
27+ string toolChoice ,
28+ float ? temperature ,
29+ int ? maxResponseOutputTokens ,
30+ int ? expiresAfter )
31+ : this (
32+ model : model ,
33+ modalities : modalities ,
34+ voice : voice ,
35+ instructions : instructions ,
36+ inputAudioFormat : inputAudioFormat ,
37+ outputAudioFormat : outputAudioFormat ,
38+ inputAudioTranscriptionSettings : new ( transcriptionModel ) ,
39+ turnDetectionSettings : turnDetectionSettings ,
40+ tools : tools ,
41+ toolChoice : toolChoice ,
42+ temperature : temperature ,
43+ maxResponseOutputTokens : maxResponseOutputTokens ,
44+ expiresAfter : expiresAfter )
45+ {
46+ }
47+
1548 public SessionConfiguration (
1649 Model model ,
1750 Modality modalities = Modality . Text | Modality . Audio ,
1851 Voice voice = null ,
1952 string instructions = null ,
2053 RealtimeAudioFormat inputAudioFormat = RealtimeAudioFormat . PCM16 ,
2154 RealtimeAudioFormat outputAudioFormat = RealtimeAudioFormat . PCM16 ,
22- Model transcriptionModel = null ,
55+ InputAudioTranscriptionSettings inputAudioTranscriptionSettings = null ,
2356 IVoiceActivityDetectionSettings turnDetectionSettings = null ,
2457 IEnumerable < Tool > tools = null ,
2558 string toolChoice = null ,
@@ -28,11 +61,9 @@ public SessionConfiguration(
2861 int ? expiresAfter = null )
2962 {
3063 ClientSecret = new ClientSecret ( expiresAfter ) ;
31- Model = string . IsNullOrWhiteSpace ( model . Id )
32- ? Models . Model . GPT4oRealtime
33- : model ;
64+ Model = string . IsNullOrWhiteSpace ( model ? . Id ) ? Models . Model . GPT4oRealtime : model ;
3465 Modalities = modalities ;
35- Voice = voice ?? OpenAI . Voice . Alloy ;
66+ Voice = string . IsNullOrWhiteSpace ( voice ? . Id ) ? OpenAI . Voice . Alloy : voice ;
3667 Instructions = string . IsNullOrWhiteSpace ( instructions )
3768 ? "Your knowledge cutoff is 2023-10. You are a helpful, witty, and friendly AI. Act like a human, " +
3869 "but remember that you aren't a human and that you can't do human things in the real world. " +
@@ -43,9 +74,7 @@ public SessionConfiguration(
4374 : instructions ;
4475 InputAudioFormat = inputAudioFormat ;
4576 OutputAudioFormat = outputAudioFormat ;
46- InputAudioTranscriptionSettings = new ( string . IsNullOrWhiteSpace ( transcriptionModel )
47- ? "whisper-1"
48- : transcriptionModel ) ;
77+ InputAudioTranscriptionSettings = inputAudioTranscriptionSettings ;
4978 VoiceActivityDetectionSettings = turnDetectionSettings ?? new ServerVAD ( ) ;
5079 tools . ProcessTools < Tool > ( toolChoice , out var toolList , out var activeTool ) ;
5180 Tools = toolList ? . Where ( t => t . IsFunction ) . Select ( tool =>
0 commit comments