@@ -47,8 +47,8 @@ public RoleDialogModel GetChatCompletions(Agent agent, List<RoleDialogModel> con
47
47
48
48
var client = ProviderHelper . GetClient ( _model , _settings ) ;
49
49
var ( prompt , chatCompletionsOptions ) = PrepareOptions ( agent , conversations ) ;
50
-
51
- var response = client . GetChatCompletions ( _model , chatCompletionsOptions ) ;
50
+ chatCompletionsOptions . DeploymentName = _model ;
51
+ var response = client . GetChatCompletions ( chatCompletionsOptions ) ;
52
52
var choice = response . Value . Choices [ 0 ] ;
53
53
var message = choice . Message ;
54
54
@@ -110,7 +110,8 @@ public async Task<bool> GetChatCompletionsAsync(Agent agent,
110
110
var client = ProviderHelper . GetClient ( _model , _settings ) ;
111
111
var ( prompt , chatCompletionsOptions ) = PrepareOptions ( agent , conversations ) ;
112
112
113
- var response = await client . GetChatCompletionsAsync ( _model , chatCompletionsOptions ) ;
113
+ chatCompletionsOptions . DeploymentName = _model ;
114
+ var response = await client . GetChatCompletionsAsync ( chatCompletionsOptions ) ;
114
115
var choice = response . Value . Choices [ 0 ] ;
115
116
var message = choice . Message ;
116
117
@@ -162,39 +163,27 @@ public async Task<bool> GetChatCompletionsStreamingAsync(Agent agent, List<RoleD
162
163
{
163
164
var client = ProviderHelper . GetClient ( _model , _settings ) ;
164
165
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 ) ;
168
168
169
169
string output = "" ;
170
- await foreach ( var choice in streaming . GetChoicesStreaming ( ) )
170
+ await foreach ( var choice in response )
171
171
{
172
172
if ( choice . FinishReason == CompletionsFinishReason . FunctionCall )
173
173
{
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 ) ;
181
175
182
- }
183
- await onMessageReceived ( new RoleDialogModel ( ChatRole . Assistant . ToString ( ) , args ) ) ;
176
+ await onMessageReceived ( new RoleDialogModel ( ChatRole . Assistant . ToString ( ) , choice . FunctionArgumentsUpdate ) ) ;
184
177
continue ;
185
178
}
186
179
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 ) ;
193
183
194
- _logger . LogInformation ( message . Content ) ;
184
+ _logger . LogInformation ( choice . ContentUpdate ) ;
195
185
196
- await onMessageReceived ( new RoleDialogModel ( message . Role . ToString ( ) , message . Content ) ) ;
197
- }
186
+ await onMessageReceived ( new RoleDialogModel ( choice . Role . ToString ( ) , choice . ContentUpdate ) ) ;
198
187
199
188
output = "" ;
200
189
}
0 commit comments