Skip to content

Commit 173c81d

Browse files
authored
Merge pull request #932 from stephentoub/updatemeai
Update to M.E.AI 9.3.0-preview.1.25161.3
2 parents 4b86790 + 23baf70 commit 173c81d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<PackageVersion Include="LLamaSharp" Version="0.20.0" />
5555
<PackageVersion Include="FaissMask" Version="0.2.0" />
5656
<PackageVersion Include="FastText.NetWrapper" Version="1.3.0" />
57-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.3.0-preview.1.25114.11" />
57+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.3.0-preview.1.25161.3" />
5858
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
5959
<PackageVersion Include="MongoDB.Driver" Version="3.1.0" />
6060
<PackageVersion Include="Docnet.Core" Version="2.7.0-alpha.1" />

src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAIChatCompletionProvider.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAITextCompletionProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task<string> GetCompletion(string text, string agentId, string mess
5151

5252
_tokenStatistics.StartTimer();
5353
var completion = await _chatClient.GetResponseAsync(text);
54-
var result = string.Concat(completion.Message.Contents.OfType<TextContent>());
54+
var result = completion.Text;
5555
_tokenStatistics.StopTimer();
5656

5757
// After chat completion hook

0 commit comments

Comments
 (0)