diff --git a/src/Infrastructure/BotSharp.Abstraction/Models/Gpt4xModelConstants.cs b/src/Infrastructure/BotSharp.Abstraction/Models/Gpt4xModelConstants.cs index 2de7a7e68..31c0f3267 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Models/Gpt4xModelConstants.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Models/Gpt4xModelConstants.cs @@ -10,4 +10,9 @@ public static class Gpt4xModelConstants public const string GPT_4_1_Nano = "gpt-4.1-nano"; public const string GPT_4o_Mini_Realtime_Preview = "gpt-4o-mini-realtime-preview"; public const string GPT_4o_Realtime_Preview = "gpt-4o-realtime-preview"; + public const string GPT_4o_Mini_Search_Preview = "gpt-4o-mini-search-preview"; + public const string GPT_4o_Mini_Transcribe = "gpt-4o-mini-transcribe"; + public const string GPT_4o_Transcribe = "gpt-4o-transcribe"; + public const string GPT_4o_Mini_Tts = "gpt-4o-mini-tts"; + public const string GPT_4o_Search_Preview = "gpt-4o-search-preview"; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Realtime/Models/ModelTurnDetection.cs b/src/Infrastructure/BotSharp.Abstraction/Realtime/Models/ModelTurnDetection.cs index 3a57791e6..0fa48cdaa 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Realtime/Models/ModelTurnDetection.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Realtime/Models/ModelTurnDetection.cs @@ -11,6 +11,6 @@ public class ModelTurnDetection public class AudioTranscription { - public string Model { get; set; } = "gpt-4o-mini-transcribe"; + public string Model { get; set; } = Gpt4xModelConstants.GPT_4o_Mini_Transcribe; public string? Language { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Realtime/Settings/RealtimeModelSettings.cs b/src/Infrastructure/BotSharp.Abstraction/Realtime/Settings/RealtimeModelSettings.cs index b66616fc7..6149de092 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Realtime/Settings/RealtimeModelSettings.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Realtime/Settings/RealtimeModelSettings.cs @@ -5,7 +5,7 @@ namespace BotSharp.Abstraction.Realtime.Settings; public class RealtimeModelSettings { public string Provider { get; set; } = "openai"; - public string Model { get; set; } = "gpt-4o-mini-realtime-preview"; + public string Model { get; set; } = Gpt4xModelConstants.GPT_4o_Mini_Realtime_Preview; public string[] Modalities { get; set; } = ["text", "audio"]; public bool InterruptResponse { get; set; } = true; public string InputAudioFormat { get; set; } = "g711_ulaw"; diff --git a/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs b/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs index d847e21b4..1292a0214 100644 --- a/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs +++ b/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs @@ -6,6 +6,7 @@ using BotSharp.Abstraction.Realtime.Options; using BotSharp.Abstraction.Realtime.Settings; using BotSharp.Abstraction.Routing.Enums; +using BotSharp.Abstraction.Settings; using BotSharp.Core.Infrastructures; namespace BotSharp.Core.Realtime.Services; @@ -192,6 +193,7 @@ public RealtimeHubConnection SetHubConnection(string conversationId) { var provider = agent?.LlmConfig?.Realtime?.Provider; var model = agent?.LlmConfig?.Realtime?.Model; + var settingService = _services.GetRequiredService(); if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(model)) { @@ -199,7 +201,7 @@ public RealtimeHubConnection SetHubConnection(string conversationId) } provider = _settings.Provider; - model = _settings.Model; + model = settingService.GetUpgradeModel(_settings.Model); if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(model)) { diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs index c02187ecf..e2c06c609 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs @@ -1,6 +1,7 @@ using BotSharp.Abstraction.Conversations.Enums; using BotSharp.Abstraction.MLTasks; using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; using BotSharp.Abstraction.Templating; namespace BotSharp.Core.Conversations.Services; @@ -62,8 +63,10 @@ private async Task Summarize(Agent agent, string prompt) string? model; var providerService = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); var modelSettings = providerService.GetProviderModels(provider); - var modelSetting = modelSettings.FirstOrDefault(x => x.Name.IsEqualTo("gpt4-turbo") || x.Name.IsEqualTo("gpt-4o")); + var defaultModel = settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o); + var modelSetting = modelSettings.FirstOrDefault(x => x.Name.IsEqualTo(defaultModel)); if (modelSetting != null) { diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs index 50e912565..d1a0ca689 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs @@ -1,6 +1,8 @@ using BotSharp.Abstraction.Instructs; using BotSharp.Abstraction.Instructs.Models; using BotSharp.Abstraction.Instructs.Options; +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; using System.IO; namespace BotSharp.Core.Files.Services; @@ -9,11 +11,12 @@ public partial class FileInstructService { public async Task ReadImages(string text, IEnumerable images, InstructOptions? options = null) { + var settingService = _services.GetRequiredService(); var innerAgentId = options?.AgentId ?? Guid.Empty.ToString(); var instruction = await RenderAgentTemplate(innerAgentId, options?.TemplateName, options?.Data); text = RenderText(text, options?.Data); - var completion = CompletionProvider.GetChatCompletion(_services, provider: options?.Provider ?? "openai", model: options?.Model ?? "gpt-4o", multiModal: true); + var completion = CompletionProvider.GetChatCompletion(_services, provider: options?.Provider ?? "openai", model: options?.Model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o), multiModal: true); var message = await completion.GetChatCompletions(new Agent() { Id = innerAgentId, diff --git a/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs b/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs index b5d989298..a2b73b33d 100644 --- a/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs +++ b/src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs @@ -1,5 +1,7 @@ using BotSharp.Abstraction.MLTasks; using BotSharp.Abstraction.MLTasks.Settings; +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; namespace BotSharp.Core.Infrastructures; @@ -140,6 +142,7 @@ public static IAudioTranscription GetAudioTranscriber( string? provider = null, string? model = null) { + var settingService = services.GetRequiredService(); var completions = services.GetServices(); var completer = completions.FirstOrDefault(x => x.Provider == (provider ?? "openai")); if (completer == null) @@ -149,7 +152,7 @@ public static IAudioTranscription GetAudioTranscriber( return default!; } - completer.SetModelName(model ?? "gpt-4o-mini-transcribe"); + completer.SetModelName(model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini_Transcribe)); return completer; } @@ -158,6 +161,7 @@ public static IAudioSynthesis GetAudioSynthesizer( string? provider = null, string? model = null) { + var settingService = services.GetRequiredService(); var completions = services.GetServices(); var completer = completions.FirstOrDefault(x => x.Provider == (provider ?? "openai")); if (completer == null) @@ -167,7 +171,7 @@ public static IAudioSynthesis GetAudioSynthesizer( return default!; } - completer.SetModelName(model ?? "gpt-4o-mini-tts"); + completer.SetModelName(model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini_Tts)); return completer; } diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs index 07ca2cf11..f75707605 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs @@ -1,5 +1,7 @@ using BotSharp.Abstraction.Instructs.Options; +using BotSharp.Abstraction.Models; using BotSharp.Abstraction.Options; +using BotSharp.Abstraction.Settings; using BotSharp.Abstraction.Templating; using System.Collections; using System.Reflection; @@ -86,9 +88,10 @@ private string BuildInstruction(string instruction, Dictionary d private async Task GetAiResponse(string text, Agent agent, InstructOptions? options) { + var settingService = _services.GetRequiredService(); var dialogs = await BuildDialogs(text, options); var provider = options?.Provider ?? agent?.LlmConfig?.Provider ?? "openai"; - var model = options?.Model ?? agent?.LlmConfig?.Model ?? "gpt-4o"; + var model = options?.Model ?? agent?.LlmConfig?.Model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o); var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model); return await completion.GetChatCompletions(agent, dialogs); } diff --git a/src/Infrastructure/BotSharp.Core/Shared/JsonRepairService.cs b/src/Infrastructure/BotSharp.Core/Shared/JsonRepairService.cs index 8185893e8..281df8ee2 100644 --- a/src/Infrastructure/BotSharp.Core/Shared/JsonRepairService.cs +++ b/src/Infrastructure/BotSharp.Core/Shared/JsonRepairService.cs @@ -1,3 +1,5 @@ +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; using BotSharp.Abstraction.Shared; using BotSharp.Abstraction.Shared.Options; using BotSharp.Abstraction.Templating; @@ -93,12 +95,13 @@ private async Task RepairByLLMAsync(string malformedJson, JsonRepairOpti var data = options?.Data ?? new Dictionary(); data["input"] = malformedJson; var prompt = render.Render(template, data); + var settingService = _services.GetRequiredService(); try { var completion = CompletionProvider.GetChatCompletion(_services, provider: options?.Provider ?? agent?.LlmConfig?.Provider ?? "openai", - model: options?.Model ?? agent?.LlmConfig?.Model ?? "gpt-4o-mini"); + model: options?.Model ?? agent?.LlmConfig?.Model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini)); var innerAgent = new Agent { diff --git a/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs b/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs index 18cf6542f..1a7ae06e9 100644 --- a/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs +++ b/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs @@ -1,5 +1,7 @@ using BotSharp.Abstraction.Functions; using BotSharp.Abstraction.MLTasks; +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; namespace BotSharp.Core.WebSearch.Functions; @@ -70,7 +72,8 @@ private async Task GetChatCompletion(Agent agent, List { var state = _services.GetRequiredService(); var llmProviderService = _services.GetRequiredService(); - + var settingService = _services.GetRequiredService(); + var provider = state.GetState("web_search_llm_provider"); var model = state.GetState("web_search_llm_model"); @@ -80,7 +83,7 @@ private async Task GetChatCompletion(Agent agent, List } provider = "openai"; - model = "gpt-4o-mini-search-preview"; + model = settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini_Search_Preview); var models = llmProviderService.GetProviderModels(provider); var foundModel = models.FirstOrDefault(x => x.WebSearch?.IsDefault == true) diff --git a/src/Plugins/BotSharp.Plugin.AudioHandler/Functions/ReadAudioFn.cs b/src/Plugins/BotSharp.Plugin.AudioHandler/Functions/ReadAudioFn.cs index 244262ffb..c172c7c40 100644 --- a/src/Plugins/BotSharp.Plugin.AudioHandler/Functions/ReadAudioFn.cs +++ b/src/Plugins/BotSharp.Plugin.AudioHandler/Functions/ReadAudioFn.cs @@ -1,3 +1,6 @@ +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; + namespace BotSharp.Plugin.AudioHandler.Functions; public class ReadAudioFn : IFunctionCallback @@ -149,6 +152,7 @@ private bool VerifyAudioFileType(string fileName) { var provider = agent?.LlmConfig?.AudioTranscription?.Provider; var model = agent?.LlmConfig?.AudioTranscription?.Model; + var settingService = _services.GetRequiredService(); if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(model)) { @@ -164,7 +168,7 @@ private bool VerifyAudioFileType(string fileName) } provider = "openai"; - model = "gpt-4o-mini-transcribe"; + model = settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini_Transcribe); return (provider, model); } diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs index d778db17c..f1404390a 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailReaderFn.cs @@ -1,4 +1,6 @@ using BotSharp.Abstraction.Messaging.Models.RichContent.Template; +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; using BotSharp.Plugin.EmailHandler.Models; using BotSharp.Plugin.EmailHandler.Providers; using MailKit; @@ -66,8 +68,9 @@ public async Task Execute(RoleDialogModel message) }; var llmProviderService = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); var provider = llmProviderService.GetProviders().FirstOrDefault(x => x == "openai"); - var model = llmProviderService.GetProviderModel(provider: provider ?? "openai", id: "gpt-4o"); + var model = llmProviderService.GetProviderModel(provider: provider ?? "openai", id: settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o)); var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model?.Name); var convService = _services.GetRequiredService(); var conversationId = convService.ConversationId; diff --git a/src/Plugins/BotSharp.Plugin.GoogleAI/Providers/Realtime/RealTimeCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.GoogleAI/Providers/Realtime/RealTimeCompletionProvider.cs index 51d2232fb..a99bbe4e3 100644 --- a/src/Plugins/BotSharp.Plugin.GoogleAI/Providers/Realtime/RealTimeCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.GoogleAI/Providers/Realtime/RealTimeCompletionProvider.cs @@ -2,6 +2,7 @@ using BotSharp.Abstraction.Realtime.Options; using BotSharp.Abstraction.Realtime.Sessions; using BotSharp.Abstraction.Realtime.Settings; +using BotSharp.Abstraction.Settings; using BotSharp.Core.Infrastructures.Streams; using BotSharp.Core.Session; using BotSharp.Plugin.GoogleAI.Models.Realtime; @@ -87,8 +88,9 @@ public async Task Connect( var settingsService = _services.GetRequiredService(); var realtimeModelSettings = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); - _model ??= realtimeModelSettings.Model; + _model ??= settingService.GetUpgradeModel(realtimeModelSettings.Model); var modelSettings = settingsService.GetSetting(Provider, _model); Reset(); diff --git a/src/Plugins/BotSharp.Plugin.ImageHandler/Helpers/AiResponseHelper.cs b/src/Plugins/BotSharp.Plugin.ImageHandler/Helpers/AiResponseHelper.cs index ce999e753..058c6f715 100644 --- a/src/Plugins/BotSharp.Plugin.ImageHandler/Helpers/AiResponseHelper.cs +++ b/src/Plugins/BotSharp.Plugin.ImageHandler/Helpers/AiResponseHelper.cs @@ -1,3 +1,5 @@ +using BotSharp.Abstraction.Models; + namespace BotSharp.Plugin.ImageHandler.Helpers; internal static class AiResponseHelper @@ -7,8 +9,9 @@ internal static async Task GetImageGenerationResponse(IServiceProvider s var text = $"Please generate a user-friendly response from the following description to " + $"inform user that you have completed the required image: {description}"; + var settingService = services.GetRequiredService(); var provider = agent?.LlmConfig?.Provider ?? "openai"; - var model = agent?.LlmConfig?.Model ?? "gpt-4o-mini"; + var model = agent?.LlmConfig?.Model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o_Mini); var completion = CompletionProvider.GetChatCompletion(services, provider: provider, model: model); var response = await completion.GetChatCompletions(agent, [new RoleDialogModel(AgentRole.User, text)]); return response.Content.IfNullOrEmptyAs(GetDefaultResponse(files)) ?? string.Empty; diff --git a/src/Plugins/BotSharp.Plugin.OpenAI/Models/Realtime/RealtimeSessionBody.cs b/src/Plugins/BotSharp.Plugin.OpenAI/Models/Realtime/RealtimeSessionBody.cs index f767a6f16..90171ae0e 100644 --- a/src/Plugins/BotSharp.Plugin.OpenAI/Models/Realtime/RealtimeSessionBody.cs +++ b/src/Plugins/BotSharp.Plugin.OpenAI/Models/Realtime/RealtimeSessionBody.cs @@ -1,3 +1,5 @@ +using BotSharp.Abstraction.Models; + namespace BotSharp.Plugin.OpenAI.Models.Realtime; public class RealtimeSessionBody @@ -82,7 +84,7 @@ public class RealtimeSessionTurnDetection public class InputAudioTranscription { [JsonPropertyName("model")] - public string Model { get; set; } = "gpt-4o-transcribe"; + public string Model { get; set; } = Gpt4xModelConstants.GPT_4o_Transcribe; [JsonPropertyName("language")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] diff --git a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs index b023f94d5..658cf3ca5 100644 --- a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs @@ -1,6 +1,8 @@ using BotSharp.Abstraction.Hooks; +using BotSharp.Abstraction.Models; using BotSharp.Abstraction.Realtime.Options; using BotSharp.Abstraction.Realtime.Settings; +using BotSharp.Abstraction.Settings; using OpenAI.Chat; namespace BotSharp.Plugin.OpenAI.Providers.Realtime; @@ -17,7 +19,7 @@ public class RealTimeCompletionProvider : IRealTimeCompletion private readonly ILogger _logger; private readonly BotSharpOptions _botsharpOptions; - private string _model = "gpt-4o-mini-realtime-preview"; + private string _model = Gpt4xModelConstants.GPT_4o_Mini_Realtime_Preview; private LlmRealtimeSession _session; private RealtimeOptions? _realtimeOptions; private bool _isBlocking = false; @@ -40,6 +42,9 @@ public RealTimeCompletionProvider( _logger = logger; _services = services; _botsharpOptions = botsharpOptions; + + var settingService = _services.GetRequiredService(); + _model = settingService.GetUpgradeModel(_model); } public async Task Connect( @@ -67,8 +72,9 @@ public async Task Connect( var settingsService = _services.GetRequiredService(); var realtimeSettings = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); - _model ??= realtimeSettings.Model; + _model ??= settingService.GetUpgradeModel(realtimeSettings.Model); var settings = settingsService.GetSetting(Provider, _model); _session = new LlmRealtimeSession(_services, new ChatSessionOptions @@ -321,6 +327,7 @@ public async Task UpdateSession(RealtimeHubConnection conn, bool isInit { var convService = _services.GetRequiredService(); var agentService = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); var conv = await convService.GetConversation(conn.ConversationId); var agent = await agentService.LoadAgent(conn.CurrentAgentId); @@ -370,7 +377,7 @@ public async Task UpdateSession(RealtimeHubConnection conn, bool isInit sessionUpdate.session.InputAudioTranscription = new InputAudioTranscription { - Model = realtimeModelSettings.InputAudioTranscription.Model, + Model = settingService.GetUpgradeModel(realtimeModelSettings.InputAudioTranscription.Model), Language = realtimeModelSettings.InputAudioTranscription.Language, Prompt = string.Join(", ", words.Select(x => x.ToLower().Trim()).Distinct()).SubstringMax(1024) }; diff --git a/src/Plugins/BotSharp.Plugin.Planner/Sequential/SequentialPlanner.cs b/src/Plugins/BotSharp.Plugin.Planner/Sequential/SequentialPlanner.cs index 59743cb7c..cc22d742b 100644 --- a/src/Plugins/BotSharp.Plugin.Planner/Sequential/SequentialPlanner.cs +++ b/src/Plugins/BotSharp.Plugin.Planner/Sequential/SequentialPlanner.cs @@ -14,6 +14,9 @@ You may obtain a copy of the License at limitations under the License. ******************************************************************************/ +using BotSharp.Abstraction.Models; +using BotSharp.Abstraction.Settings; + namespace BotSharp.Plugin.Planner.Sequential; /// @@ -166,7 +169,8 @@ public async Task GetDecomposedStepAsync(Agent router, string me var inst = new DecomposedStep(); var llmProviderService = _services.GetRequiredService(); - var model = llmProviderService.GetProviderModel("openai", "gpt-4o"); + var settingService = _services.GetRequiredService(); + var model = llmProviderService.GetProviderModel("openai", settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o)); // chat completion var completion = CompletionProvider.GetChatCompletion(_services, diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs index 6bee18312..7fc661a88 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs @@ -1,4 +1,5 @@ using BotSharp.Abstraction.Instructs.Options; +using BotSharp.Abstraction.Models; namespace BotSharp.Plugin.SqlDriver.Functions; @@ -51,7 +52,7 @@ public async Task Execute(RoleDialogModel message) if (msgCopy.Data != null && msgCopy.Data is DbException ex) { - + var settingService = _services.GetRequiredService(); var instructService = _services.GetRequiredService(); var agentService = _services.GetRequiredService(); var states = _services.GetRequiredService(); @@ -63,7 +64,7 @@ public async Task Execute(RoleDialogModel message) new InstructOptions { Provider = "openai", - Model = "gpt-4o", + Model = settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o), AgentId = BuiltInAgentId.SqlDriver, TemplateName = "sql_statement_correctness", Data = new Dictionary diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs index 09d75301d..47b607a3e 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs @@ -6,6 +6,7 @@ using BotSharp.Abstraction.Knowledges.Enums; using BotSharp.Abstraction.VectorStorage.Models; using BotSharp.Plugin.SqlDriver.Models; +using BotSharp.Abstraction.Models; namespace BotSharp.Plugin.SqlDriver.Services; @@ -26,8 +27,9 @@ public async Task Import(ImportDbKnowledgeRequest request) { var sqlDriverSettings = _services.GetRequiredService(); var knowledgeService = _services.GetRequiredService(); + var settingService = _services.GetRequiredService(); var provider = request.Provider ?? "openai"; - var model = request.Model ?? "gpt-4o"; + var model = request.Model ?? settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o); var schema = request.Schema; var collectionName = request.KnowledgebaseCollection; diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 39587b64e..e4ad7bf57 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -647,7 +647,7 @@ "EnableTranslator": false, "LlmConfig": { "Provider": "openai", - "Model": "gpt-4.1-nano" + "Model": "gpt-5-nano" } }, diff --git a/tests/BotSharp.LLM.Tests/Core/LLMProvider.cs b/tests/BotSharp.LLM.Tests/Core/LLMProvider.cs index 5dd3d4a59..7b4fd6523 100644 --- a/tests/BotSharp.LLM.Tests/Core/LLMProvider.cs +++ b/tests/BotSharp.LLM.Tests/Core/LLMProvider.cs @@ -75,7 +75,7 @@ public static (IServiceCollection services, IConfiguration config, string modelN public static (IServiceCollection services, IConfiguration config, string modelName) CreateOpenAI() { - string modelName = "gpt-4o-mini"; + string modelName = "gpt-5-mini"; var apiKey = Environment.GetEnvironmentVariable("OPEN_AI_APIKEY") ?? throw new Exception("OPEN_AI_APIKEY is not set"); diff --git a/tests/BotSharp.LLM.Tests/appsettings.json b/tests/BotSharp.LLM.Tests/appsettings.json index db7c274aa..41ca7076d 100644 --- a/tests/BotSharp.LLM.Tests/appsettings.json +++ b/tests/BotSharp.LLM.Tests/appsettings.json @@ -168,7 +168,7 @@ "EnableTranslator": false, "LlmConfig": { "Provider": "azure-openai", - "Model": "gpt-4o-mini" + "Model": "gpt-5-mini" } }, //"MCPSettings": {