diff --git a/src/Infrastructure/BotSharp.Abstraction/Utilities/StringExtensions.cs b/src/Infrastructure/BotSharp.Abstraction/Utilities/StringExtensions.cs index 8352bcff..0da63437 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Utilities/StringExtensions.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Utilities/StringExtensions.cs @@ -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; + } } diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/AzureOpenAiPlugin.cs b/src/Plugins/BotSharp.Plugin.AzureOpenAI/AzureOpenAiPlugin.cs index dfc3d00b..1232e668 100644 --- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/AzureOpenAiPlugin.cs +++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/AzureOpenAiPlugin.cs @@ -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(); services.AddScoped(); diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Settings/DeploymentModelSetting.cs b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Settings/DeploymentModelSetting.cs index 24618190..9eb5f63e 100644 --- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Settings/DeploymentModelSetting.cs +++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Settings/DeploymentModelSetting.cs @@ -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}"; + } }