@@ -27,7 +27,6 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
27
27
private readonly IChatClient _client ;
28
28
private readonly ILogger < MicrosoftExtensionsAIChatCompletionProvider > _logger ;
29
29
private readonly IServiceProvider _services ;
30
- private List < string > renderedInstructions = [ ] ;
31
30
private string ? _model ;
32
31
33
32
/// <summary>
@@ -46,7 +45,7 @@ public MicrosoftExtensionsAIChatCompletionProvider(
46
45
47
46
/// <inheritdoc/>
48
47
public string Provider => "microsoft.extensions.ai" ;
49
- public string Model => _model ;
48
+ public string Model => _model ?? "" ;
50
49
51
50
/// <inheritdoc/>
52
51
public void SetModelName ( string model ) => _model = model ;
@@ -56,7 +55,7 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
56
55
{
57
56
// Before chat completion hook
58
57
var hooks = _services . GetServices < IContentGeneratingHook > ( ) . ToArray ( ) ;
59
- renderedInstructions = [ ] ;
58
+ List < string > renderedInstructions = [ ] ;
60
59
await Task . WhenAll ( hooks . Select ( hook => hook . BeforeGenerating ( agent , conversations ) ) ) ;
61
60
62
61
// Configure options
@@ -145,13 +144,13 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
145
144
146
145
var completion = await _client . GetResponseAsync ( messages ) ;
147
146
148
- RoleDialogModel result = new ( AgentRole . Assistant , string . Concat ( completion . Message . Contents . OfType < TextContent > ( ) ) )
147
+ RoleDialogModel result = new ( AgentRole . Assistant , completion . Text )
149
148
{
150
149
CurrentAgentId = agent . Id ,
151
- RenderedInstruction = string . Join ( " \r \n " , renderedInstructions )
150
+ // RenderedInstruction = renderedInstructions,
152
151
} ;
153
152
154
- if ( completion . Message . Contents . OfType < FunctionCallContent > ( ) . FirstOrDefault ( ) is { } fcc )
153
+ if ( completion . Messages . SelectMany ( m => m . Contents ) . OfType < FunctionCallContent > ( ) . FirstOrDefault ( ) is { } fcc )
155
154
{
156
155
result . Role = AgentRole . Function ;
157
156
result . MessageId = conversations . LastOrDefault ( ) ? . MessageId ?? string . Empty ;
0 commit comments