@@ -47,8 +47,8 @@ public RoleDialogModel GetChatCompletions(Agent agent, List<RoleDialogModel> con
4747
4848 var client = ProviderHelper . GetClient ( _model , _settings ) ;
4949 var ( prompt , chatCompletionsOptions ) = PrepareOptions ( agent , conversations ) ;
50-
51- var response = client . GetChatCompletions ( _model , chatCompletionsOptions ) ;
50+ chatCompletionsOptions . DeploymentName = _model ;
51+ var response = client . GetChatCompletions ( chatCompletionsOptions ) ;
5252 var choice = response . Value . Choices [ 0 ] ;
5353 var message = choice . Message ;
5454
@@ -110,7 +110,8 @@ public async Task<bool> GetChatCompletionsAsync(Agent agent,
110110 var client = ProviderHelper . GetClient ( _model , _settings ) ;
111111 var ( prompt , chatCompletionsOptions ) = PrepareOptions ( agent , conversations ) ;
112112
113- var response = await client . GetChatCompletionsAsync ( _model , chatCompletionsOptions ) ;
113+ chatCompletionsOptions . DeploymentName = _model ;
114+ var response = await client . GetChatCompletionsAsync ( chatCompletionsOptions ) ;
114115 var choice = response . Value . Choices [ 0 ] ;
115116 var message = choice . Message ;
116117
@@ -162,39 +163,27 @@ public async Task<bool> GetChatCompletionsStreamingAsync(Agent agent, List<RoleD
162163 {
163164 var client = ProviderHelper . GetClient ( _model , _settings ) ;
164165 var ( prompt , chatCompletionsOptions ) = PrepareOptions ( agent , conversations ) ;
165-
166- var response = await client . GetChatCompletionsStreamingAsync ( _model , chatCompletionsOptions ) ;
167- using StreamingChatCompletions streaming = response . Value ;
166+ chatCompletionsOptions . DeploymentName = _model ;
167+ var response = await client . GetChatCompletionsStreamingAsync ( chatCompletionsOptions ) ;
168168
169169 string output = "" ;
170- await foreach ( var choice in streaming . GetChoicesStreaming ( ) )
170+ await foreach ( var choice in response )
171171 {
172172 if ( choice . FinishReason == CompletionsFinishReason . FunctionCall )
173173 {
174- var args = "" ;
175- await foreach ( var message in choice . GetMessageStreaming ( ) )
176- {
177- if ( message . FunctionCall == null || message . FunctionCall . Arguments == null )
178- continue ;
179- Console . Write ( message . FunctionCall . Arguments ) ;
180- args += message . FunctionCall . Arguments ;
174+ Console . Write ( choice . FunctionArgumentsUpdate ) ;
181175
182- }
183- await onMessageReceived ( new RoleDialogModel ( ChatRole . Assistant . ToString ( ) , args ) ) ;
176+ await onMessageReceived ( new RoleDialogModel ( ChatRole . Assistant . ToString ( ) , choice . FunctionArgumentsUpdate ) ) ;
184177 continue ;
185178 }
186179
187- await foreach ( var message in choice . GetMessageStreaming ( ) )
188- {
189- if ( message . Content == null )
190- continue ;
191- Console . Write ( message . Content ) ;
192- output += message . Content ;
180+ if ( choice . ContentUpdate == null )
181+ continue ;
182+ Console . Write ( choice . ContentUpdate ) ;
193183
194- _logger . LogInformation ( message . Content ) ;
184+ _logger . LogInformation ( choice . ContentUpdate ) ;
195185
196- await onMessageReceived ( new RoleDialogModel ( message . Role . ToString ( ) , message . Content ) ) ;
197- }
186+ await onMessageReceived ( new RoleDialogModel ( choice . Role . ToString ( ) , choice . ContentUpdate ) ) ;
198187
199188 output = "" ;
200189 }
0 commit comments