You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure GetProviderModels cannot return null and that model entries have non-null Name before selection; otherwise the fallback may still propagate a null Name into CompletionProvider.
The provider and default model are hardcoded; consider sourcing from configuration to avoid coupling and ease future changes or multi-provider scenarios.
Guard against null or empty results from GetProviderModels to avoid NullReferenceException. Also ensure webSearchModel is non-empty before passing to the completion provider, otherwise use the defaultModel.
var provider = "openai";
var defaultModel = "gpt-4o-mini-search-preview";
var llmProviderService = _services.GetRequiredService<ILlmProviderService>();
-var models = llmProviderService.GetProviderModels(provider);+var models = llmProviderService.GetProviderModels(provider) ?? Enumerable.Empty<LlmModelSetting>();+
var webSearchModel = models.FirstOrDefault(x => x.WebSearch?.IsDefault == true)?.Name
?? models.FirstOrDefault(x => x.WebSearch != null)?.Name
?? defaultModel;
+if (string.IsNullOrWhiteSpace(webSearchModel))+{+ webSearchModel = defaultModel;+}+
var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: webSearchModel);
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that GetProviderModels could return null, causing a NullReferenceException, and also handles the edge case of a model having an empty name, improving the code's robustness.
Medium
General
Filter by compatible model type
Prefer stricter selection by ensuring the model Type supports chat completions before choosing it for web search. This avoids selecting an embedding or incompatible model accidentally marked with WebSearch.
Why: The suggestion improves the model selection logic by adding a filter for LlmModelType.Chat, making the selection more robust by preventing the use of incompatible model types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
Description
Add dynamic web search model selection logic
Introduce
IsDefaultflag for web search settingsReplace hardcoded model with configurable selection
Diagram Walkthrough
File Walkthrough
LlmModelSetting.cs
Add IsDefault flag to WebSearchSettingsrc/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs
IsDefaultboolean property toWebSearchSettingclassWebIntelligentSearchFn.cs
Implement dynamic web search model selectionsrc/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs