Print Azure AI settings.
This commit is contained in:
parent
60ce930d4c
commit
de2587dcb5
|
|
@ -4,4 +4,15 @@ public static class StringExtensions
|
|||
{
|
||||
public static string IfNullOrEmptyAs(this string str, string defaultValue)
|
||||
=> string.IsNullOrEmpty(str) ? defaultValue : str;
|
||||
|
||||
public static string SubstringMax(this string str, int maxLength)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return str;
|
||||
|
||||
if (str.Length > maxLength)
|
||||
return str.Substring(0, maxLength);
|
||||
else
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
using BotSharp.Abstraction.MLTasks;
|
||||
using BotSharp.Abstraction.Plugins;
|
||||
using BotSharp.Abstraction.Utilities;
|
||||
using BotSharp.Plugin.AzureOpenAI.Providers;
|
||||
using BotSharp.Plugin.AzureOpenAI.Settings;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace BotSharp.Platform.AzureAi;
|
||||
|
||||
|
|
@ -13,7 +15,11 @@ public class AzureOpenAiPlugin : IBotSharpPlugin
|
|||
{
|
||||
var settings = new AzureOpenAiSettings();
|
||||
config.Bind("AzureOpenAi", settings);
|
||||
services.AddSingleton(x => settings);
|
||||
services.AddSingleton(x =>
|
||||
{
|
||||
Console.WriteLine($"Loaded AzureOpenAi settings: {settings.DeploymentModel} ({settings.Endpoint}) {settings.ApiKey.SubstringMax(4)}");
|
||||
return settings;
|
||||
});
|
||||
|
||||
services.AddScoped<ITextCompletion, TextCompletionProvider>();
|
||||
services.AddScoped<IChatCompletion, ChatCompletionProvider>();
|
||||
|
|
|
|||
|
|
@ -4,4 +4,9 @@ public class DeploymentModelSetting
|
|||
{
|
||||
public string? ChatCompletionModel { get; set; }
|
||||
public string? TextCompletionModel { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ChatCompletion - {ChatCompletionModel}, TextCompletion - {TextCompletionModel}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue