Update to M.E.AI 9.3.0-preview.1.25161.3
This commit is contained in:
parent
4b867909a1
commit
23baf70088
|
|
@ -54,7 +54,7 @@
|
|||
<PackageVersion Include="LLamaSharp" Version="0.20.0" />
|
||||
<PackageVersion Include="FaissMask" Version="0.2.0" />
|
||||
<PackageVersion Include="FastText.NetWrapper" Version="1.3.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.3.0-preview.1.25114.11" />
|
||||
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.3.0-preview.1.25161.3" />
|
||||
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
|
||||
<PackageVersion Include="MongoDB.Driver" Version="3.1.0" />
|
||||
<PackageVersion Include="Docnet.Core" Version="2.7.0-alpha.1" />
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
|
|||
private readonly IChatClient _client;
|
||||
private readonly ILogger<MicrosoftExtensionsAIChatCompletionProvider> _logger;
|
||||
private readonly IServiceProvider _services;
|
||||
private List<string> renderedInstructions = [];
|
||||
private string? _model;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -46,7 +45,7 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
|
|||
|
||||
/// <inheritdoc/>
|
||||
public string Provider => "microsoft.extensions.ai";
|
||||
public string Model => _model;
|
||||
public string Model => _model ?? "";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetModelName(string model) => _model = model;
|
||||
|
|
@ -56,7 +55,7 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
|
|||
{
|
||||
// Before chat completion hook
|
||||
var hooks = _services.GetServices<IContentGeneratingHook>().ToArray();
|
||||
renderedInstructions = [];
|
||||
List<string> renderedInstructions = [];
|
||||
await Task.WhenAll(hooks.Select(hook => hook.BeforeGenerating(agent, conversations)));
|
||||
|
||||
// Configure options
|
||||
|
|
@ -145,13 +144,13 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
|
|||
|
||||
var completion = await _client.GetResponseAsync(messages);
|
||||
|
||||
RoleDialogModel result = new(AgentRole.Assistant, string.Concat(completion.Message.Contents.OfType<TextContent>()))
|
||||
RoleDialogModel result = new(AgentRole.Assistant, completion.Text)
|
||||
{
|
||||
CurrentAgentId = agent.Id,
|
||||
RenderedInstruction = string.Join("\r\n", renderedInstructions)
|
||||
//RenderedInstruction = renderedInstructions,
|
||||
};
|
||||
|
||||
if (completion.Message.Contents.OfType<FunctionCallContent>().FirstOrDefault() is { } fcc)
|
||||
if (completion.Messages.SelectMany(m => m.Contents).OfType<FunctionCallContent>().FirstOrDefault() is { } fcc)
|
||||
{
|
||||
result.Role = AgentRole.Function;
|
||||
result.MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public sealed class MicrosoftExtensionsAITextCompletionProvider : ITextCompletio
|
|||
|
||||
_tokenStatistics.StartTimer();
|
||||
var completion = await _chatClient.GetResponseAsync(text);
|
||||
var result = string.Concat(completion.Message.Contents.OfType<TextContent>());
|
||||
var result = completion.Text;
|
||||
_tokenStatistics.StopTimer();
|
||||
|
||||
// After chat completion hook
|
||||
|
|
|
|||
Loading…
Reference in a new issue