From 6466092a51b28737f304e635e18fd319e8838223 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Fri, 22 Aug 2025 14:22:49 -0500 Subject: [PATCH] refine web search model select --- .../MLTasks/Settings/LlmModelSetting.cs | 1 + .../WebSearch/Functions/WebIntelligentSearchFn.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs b/src/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs index 501985f45..79ca86fd4 100644 --- a/src/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs +++ b/src/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs @@ -86,6 +86,7 @@ public class ReasoningSetting public class WebSearchSetting { + public bool IsDefault { get; set; } public string? SearchContextSize { get; set; } } diff --git a/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs b/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs index 138748fb2..fecbe42bc 100644 --- a/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs +++ b/src/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs @@ -53,8 +53,16 @@ private async Task GetChatCompletion(Agent agent, List { try { + var provider = "openai"; + var defaultModel = "gpt-4o-mini-search-preview"; + var llmProviderService = _services.GetRequiredService(); - var completion = CompletionProvider.GetChatCompletion(_services, provider: "openai", model: "gpt-4o-search-preview"); + var models = llmProviderService.GetProviderModels(provider); + var webSearchModel = models.FirstOrDefault(x => x.WebSearch?.IsDefault == true)?.Name + ?? models.FirstOrDefault(x => x.WebSearch != null)?.Name + ?? defaultModel; + + var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: webSearchModel); var response = await completion.GetChatCompletions(agent, dialogs); return response.Content; }