Support rich content in UI.
This commit is contained in:
parent
7b7516a2cf
commit
b402aa9e91
|
|
@ -5,4 +5,5 @@ public class ConversationSetting
|
|||
public string DataDir { get; set; }
|
||||
public string ChatCompletion { get; set; }
|
||||
public bool EnableKnowledgeBase { get; set; }
|
||||
public bool ShowVerboseLog { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ using Azure.AI.OpenAI;
|
|||
using BotSharp.Abstraction.Agents.Enums;
|
||||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.Conversations.Settings;
|
||||
using BotSharp.Abstraction.Functions.Models;
|
||||
using BotSharp.Abstraction.MLTasks;
|
||||
using BotSharp.Plugin.AzureOpenAI.Settings;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -18,12 +20,16 @@ namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
|||
public class ChatCompletionProvider : IChatCompletion
|
||||
{
|
||||
private readonly AzureOpenAiSettings _settings;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ChatCompletionProvider(AzureOpenAiSettings settings, ILogger<ChatCompletionProvider> logger)
|
||||
public ChatCompletionProvider(AzureOpenAiSettings settings,
|
||||
ILogger<ChatCompletionProvider> logger,
|
||||
IServiceProvider services)
|
||||
{
|
||||
_settings = settings;
|
||||
_logger = logger;
|
||||
_services = services;
|
||||
}
|
||||
|
||||
private OpenAIClient GetClient()
|
||||
|
|
@ -215,18 +221,18 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
chatCompletionsOptions.Temperature = 0.5f;
|
||||
chatCompletionsOptions.NucleusSamplingFactor = 0.5f;
|
||||
|
||||
var verbose = string.Join("\n", chatCompletionsOptions.Messages.Select(x =>
|
||||
var convSetting = _services.GetRequiredService<ConversationSetting>();
|
||||
if (convSetting.ShowVerboseLog)
|
||||
{
|
||||
if (x.Role == ChatRole.Function)
|
||||
var verbose = string.Join("\n", chatCompletionsOptions.Messages.Select(x =>
|
||||
{
|
||||
return $"{x.Role}: {x.Name} {x.Content}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{x.Role}: {x.Content}";
|
||||
}
|
||||
}));
|
||||
_logger.LogInformation(verbose);
|
||||
return x.Role == ChatRole.Function ?
|
||||
$"{x.Role}: {x.Name} {x.Content}" :
|
||||
$"{x.Role}: {x.Content}";
|
||||
}));
|
||||
_logger.LogInformation(verbose);
|
||||
}
|
||||
|
||||
return chatCompletionsOptions;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue