@@ -27,7 +27,6 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
2727 private readonly IChatClient _client ;
2828 private readonly ILogger < MicrosoftExtensionsAIChatCompletionProvider > _logger ;
2929 private readonly IServiceProvider _services ;
30- private List < string > renderedInstructions = [ ] ;
3130 private string ? _model ;
3231
3332 /// <summary>
@@ -46,7 +45,7 @@ public MicrosoftExtensionsAIChatCompletionProvider(
4645
4746 /// <inheritdoc/>
4847 public string Provider => "microsoft.extensions.ai" ;
49- public string Model => _model ;
48+ public string Model => _model ?? "" ;
5049
5150 /// <inheritdoc/>
5251 public void SetModelName ( string model ) => _model = model ;
@@ -56,7 +55,7 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
5655 {
5756 // Before chat completion hook
5857 var hooks = _services . GetServices < IContentGeneratingHook > ( ) . ToArray ( ) ;
59- renderedInstructions = [ ] ;
58+ List < string > renderedInstructions = [ ] ;
6059 await Task . WhenAll ( hooks . Select ( hook => hook . BeforeGenerating ( agent , conversations ) ) ) ;
6160
6261 // Configure options
@@ -145,13 +144,13 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
145144
146145 var completion = await _client . GetResponseAsync ( messages ) ;
147146
148- RoleDialogModel result = new ( AgentRole . Assistant , string . Concat ( completion . Message . Contents . OfType < TextContent > ( ) ) )
147+ RoleDialogModel result = new ( AgentRole . Assistant , completion . Text )
149148 {
150149 CurrentAgentId = agent . Id ,
151- RenderedInstruction = string . Join ( " \r \n " , renderedInstructions )
150+ // RenderedInstruction = renderedInstructions,
152151 } ;
153152
154- if ( completion . Message . Contents . OfType < FunctionCallContent > ( ) . FirstOrDefault ( ) is { } fcc )
153+ if ( completion . Messages . SelectMany ( m => m . Contents ) . OfType < FunctionCallContent > ( ) . FirstOrDefault ( ) is { } fcc )
155154 {
156155 result . Role = AgentRole . Function ;
157156 result . MessageId = conversations . LastOrDefault ( ) ? . MessageId ?? string . Empty ;
0 commit comments