From 9ff2b6895e9c69bd6bcd673aaf3457ccd7f43473 Mon Sep 17 00:00:00 2001 From: Gil Zhang Date: Tue, 17 Dec 2024 12:07:15 +0800 Subject: [PATCH] Adding a custom OpenAI endpoint --- .../BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs index b385b380..7ab56b5d 100644 --- a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs +++ b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/ProviderHelper.cs @@ -9,8 +9,10 @@ public class ProviderHelper { var settingsService = services.GetRequiredService(); var settings = settingsService.GetSetting(provider, model); - var client = new OpenAIClient(new ApiKeyCredential(settings.ApiKey)); - return client; + var options = string.IsNullOrEmpty(settings.Endpoint) + ? null + : new OpenAIClientOptions { Endpoint = new Uri(settings.Endpoint) }; + return new OpenAIClient(new ApiKeyCredential(settings.ApiKey), options); } public static List GetChatSamples(List lines)