mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-20 22:12:56 +00:00
Use Provider.NONE
as a default value and refactor provider handling logic across components.
This commit is contained in:
parent
589d62c9ce
commit
1765a4d514
@ -54,7 +54,7 @@ public abstract class AgentBase(ILogger<AgentBase> logger, SettingsManager setti
|
|||||||
|
|
||||||
#region Implementation of IAgent
|
#region Implementation of IAgent
|
||||||
|
|
||||||
public abstract AIStudio.Settings.Provider? ProviderSettings { get; set; }
|
public abstract AIStudio.Settings.Provider ProviderSettings { get; set; }
|
||||||
|
|
||||||
public abstract Task<ChatThread> ProcessContext(ChatThread chatThread, IDictionary<string, string> additionalData);
|
public abstract Task<ChatThread> ProcessContext(ChatThread chatThread, IDictionary<string, string> additionalData);
|
||||||
|
|
||||||
@ -103,10 +103,9 @@ public abstract class AgentBase(ILogger<AgentBase> logger, SettingsManager setti
|
|||||||
|
|
||||||
protected async Task AddAIResponseAsync(ChatThread thread, IContent lastUserPrompt, DateTimeOffset time)
|
protected async Task AddAIResponseAsync(ChatThread thread, IContent lastUserPrompt, DateTimeOffset time)
|
||||||
{
|
{
|
||||||
if(this.ProviderSettings is null)
|
if(this.ProviderSettings == Settings.Provider.NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var providerSettings = this.ProviderSettings.Value;
|
|
||||||
var aiText = new ContentText
|
var aiText = new ContentText
|
||||||
{
|
{
|
||||||
// We have to wait for the remote
|
// We have to wait for the remote
|
||||||
@ -127,6 +126,6 @@ public abstract class AgentBase(ILogger<AgentBase> logger, SettingsManager setti
|
|||||||
// Use the selected provider to get the AI response.
|
// Use the selected provider to get the AI response.
|
||||||
// By awaiting this line, we wait for the entire
|
// By awaiting this line, we wait for the entire
|
||||||
// content to be streamed.
|
// content to be streamed.
|
||||||
await aiText.CreateFromProviderAsync(providerSettings.CreateProvider(this.Logger), providerSettings.Model, lastUserPrompt, thread);
|
await aiText.CreateFromProviderAsync(this.ProviderSettings.CreateProvider(this.Logger), this.ProviderSettings.Model, lastUserPrompt, thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -86,7 +86,7 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Settings.Provider? ProviderSettings { get; set; }
|
public override Settings.Provider ProviderSettings { get; set; } = Settings.Provider.NONE;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The data source selection agent does not work with context. Use
|
/// The data source selection agent does not work with context. Use
|
||||||
@ -141,6 +141,11 @@ public sealed class AgentDataSourceSelection (ILogger<AgentDataSourceSelection>
|
|||||||
|
|
||||||
// We start with the provider currently selected by the user:
|
// We start with the provider currently selected by the user:
|
||||||
var agentProvider = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_DATA_SOURCE_SELECTION, provider.Id, true);
|
var agentProvider = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_DATA_SOURCE_SELECTION, provider.Id, true);
|
||||||
|
if (agentProvider == Settings.Provider.NONE)
|
||||||
|
{
|
||||||
|
logger.LogWarning("No provider is selected for the agent. The agent cannot select data sources.");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// Assign the provider settings to the agent:
|
// Assign the provider settings to the agent:
|
||||||
logger.LogInformation($"The agent for the data source selection uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
logger.LogInformation($"The agent for the data source selection uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
||||||
|
@ -71,7 +71,7 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Settings.Provider? ProviderSettings { get; set; }
|
public override Settings.Provider ProviderSettings { get; set; } = Settings.Provider.NONE;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The retrieval context validation agent does not work with context. Use
|
/// The retrieval context validation agent does not work with context. Use
|
||||||
@ -133,6 +133,11 @@ public sealed class AgentRetrievalContextValidation (ILogger<AgentRetrievalConte
|
|||||||
{
|
{
|
||||||
// We start with the provider currently selected by the user:
|
// We start with the provider currently selected by the user:
|
||||||
var agentProvider = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION, provider.Id, true);
|
var agentProvider = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION, provider.Id, true);
|
||||||
|
if (agentProvider == Settings.Provider.NONE)
|
||||||
|
{
|
||||||
|
logger.LogWarning("No provider is selected for the agent.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Assign the provider settings to the agent:
|
// Assign the provider settings to the agent:
|
||||||
logger.LogInformation($"The agent for the retrieval context validation uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
logger.LogInformation($"The agent for the retrieval context validation uses the provider '{agentProvider.InstanceName}' ({agentProvider.UsedLLMProvider.ToName()}, confidence={agentProvider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level.GetName()}).");
|
||||||
|
@ -11,7 +11,7 @@ public sealed class AgentTextContentCleaner(ILogger<AgentBase> logger, SettingsM
|
|||||||
|
|
||||||
#region Overrides of AgentBase
|
#region Overrides of AgentBase
|
||||||
|
|
||||||
public override AIStudio.Settings.Provider? ProviderSettings { get; set; }
|
public override AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE;
|
||||||
|
|
||||||
protected override Type Type => Type.SYSTEM;
|
protected override Type Type => Type.SYSTEM;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public interface IAgent
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The provider to use for this agent.
|
/// The provider to use for this agent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AIStudio.Settings.Provider? ProviderSettings { get; set; }
|
public Settings.Provider ProviderSettings { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes a chat thread (i.e., context) and returns the updated thread.
|
/// Processes a chat thread (i.e., context) and returns the updated thread.
|
||||||
|
@ -85,7 +85,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
|||||||
|
|
||||||
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
||||||
|
|
||||||
protected AIStudio.Settings.Provider providerSettings;
|
protected AIStudio.Settings.Provider providerSettings = Settings.Provider.NONE;
|
||||||
protected MudForm? form;
|
protected MudForm? form;
|
||||||
protected bool inputIsValid;
|
protected bool inputIsValid;
|
||||||
protected Profile currentProfile = Profile.NO_PROFILE;
|
protected Profile currentProfile = Profile.NO_PROFILE;
|
||||||
@ -352,7 +352,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
|||||||
private async Task InnerResetForm()
|
private async Task InnerResetForm()
|
||||||
{
|
{
|
||||||
this.resultingContentBlock = null;
|
this.resultingContentBlock = null;
|
||||||
this.providerSettings = default;
|
this.providerSettings = Settings.Provider.NONE;
|
||||||
|
|
||||||
await this.JsRuntime.ClearDiv(RESULT_DIV_ID);
|
await this.JsRuntime.ClearDiv(RESULT_DIV_ID);
|
||||||
await this.JsRuntime.ClearDiv(AFTER_RESULT_DIV_ID);
|
await this.JsRuntime.ClearDiv(AFTER_RESULT_DIV_ID);
|
||||||
|
@ -20,7 +20,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
public EventCallback<ChatThread?> ChatThreadChanged { get; set; }
|
public EventCallback<ChatThread?> ChatThreadChanged { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public AIStudio.Settings.Provider Provider { get; set; }
|
public AIStudio.Settings.Provider Provider { get; set; } = AIStudio.Settings.Provider.NONE;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<AIStudio.Settings.Provider> ProviderChanged { get; set; }
|
public EventCallback<AIStudio.Settings.Provider> ProviderChanged { get; set; }
|
||||||
@ -634,7 +634,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
case AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER:
|
case AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER:
|
||||||
if(this.Provider == default)
|
if(this.Provider == AIStudio.Settings.Provider.NONE)
|
||||||
{
|
{
|
||||||
this.Provider = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
this.Provider = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
await this.ProviderChanged.InvokeAsync(this.Provider);
|
await this.ProviderChanged.InvokeAsync(this.Provider);
|
||||||
@ -797,7 +797,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingChatProviderBehavior.ALWAYS_USE_LATEST_CHAT_PROVIDER:
|
case LoadingChatProviderBehavior.ALWAYS_USE_LATEST_CHAT_PROVIDER:
|
||||||
if(this.Provider == default)
|
if(this.Provider == AIStudio.Settings.Provider.NONE)
|
||||||
this.Provider = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
this.Provider = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@ public partial class ConfigurationProviderSelection : MSGComponentBase
|
|||||||
foreach (var providerId in this.Data)
|
foreach (var providerId in this.Data)
|
||||||
{
|
{
|
||||||
var provider = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == providerId.Value);
|
var provider = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == providerId.Value);
|
||||||
|
if (provider is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
|
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
|
||||||
yield return providerId;
|
yield return providerId;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public partial class ProviderSelection : MSGComponentBase
|
|||||||
public AssistantBase<NoComponent>? AssistantBase { get; set; }
|
public AssistantBase<NoComponent>? AssistantBase { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public AIStudio.Settings.Provider ProviderSettings { get; set; }
|
public AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<AIStudio.Settings.Provider> ProviderSettingsChanged { get; set; }
|
public EventCallback<AIStudio.Settings.Provider> ProviderSettingsChanged { get; set; }
|
||||||
@ -32,6 +32,7 @@ public partial class ProviderSelection : MSGComponentBase
|
|||||||
{
|
{
|
||||||
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.AssistantBase?.Component ?? Tools.Components.NONE);
|
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.AssistantBase?.Component ?? Tools.Components.NONE);
|
||||||
foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
|
foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
|
||||||
|
if (provider.UsedLLMProvider != LLMProviders.NONE)
|
||||||
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
|
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
|
||||||
yield return provider;
|
yield return provider;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public partial class ReadWebContent : MSGComponentBase
|
|||||||
public EventCallback<string> ContentChanged { get; set; }
|
public EventCallback<string> ContentChanged { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public AIStudio.Settings.Provider ProviderSettings { get; set; }
|
public AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool AgentIsRunning { get; set; }
|
public bool AgentIsRunning { get; set; }
|
||||||
@ -43,7 +43,7 @@ public partial class ReadWebContent : MSGComponentBase
|
|||||||
private bool urlIsValid;
|
private bool urlIsValid;
|
||||||
private bool isProviderValid;
|
private bool isProviderValid;
|
||||||
|
|
||||||
private AIStudio.Settings.Provider providerSettings;
|
private AIStudio.Settings.Provider providerSettings = AIStudio.Settings.Provider.NONE;
|
||||||
|
|
||||||
#region Overrides of ComponentBase
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public partial class ReadWebContent : MSGComponentBase
|
|||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
markdown = this.HTMLParser.ParseToMarkdown(html);
|
markdown = this.HTMLParser.ParseToMarkdown(html);
|
||||||
|
|
||||||
if (this.useContentCleanerAgent)
|
if (this.useContentCleanerAgent && this.providerSettings != AIStudio.Settings.Provider.NONE)
|
||||||
{
|
{
|
||||||
this.AgentTextContentCleaner.ProviderSettings = this.providerSettings;
|
this.AgentTextContentCleaner.ProviderSettings = this.providerSettings;
|
||||||
var additionalData = new Dictionary<string, string>
|
var additionalData = new Dictionary<string, string>
|
||||||
@ -149,7 +149,7 @@ public partial class ReadWebContent : MSGComponentBase
|
|||||||
|
|
||||||
private string? ValidateProvider(bool shouldUseAgent)
|
private string? ValidateProvider(bool shouldUseAgent)
|
||||||
{
|
{
|
||||||
if(shouldUseAgent && this.providerSettings == default)
|
if(shouldUseAgent && this.providerSettings == AIStudio.Settings.Provider.NONE)
|
||||||
{
|
{
|
||||||
this.isProviderValid = false;
|
this.isProviderValid = false;
|
||||||
return T("Please select a provider to use the cleanup agent.");
|
return T("Please select a provider to use the cleanup agent.");
|
||||||
|
@ -54,6 +54,9 @@ public partial class SettingsPanelProviders : SettingsPanelBase
|
|||||||
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
|
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
|
||||||
private async Task EditLLMProvider(AIStudio.Settings.Provider provider)
|
private async Task EditLLMProvider(AIStudio.Settings.Provider provider)
|
||||||
{
|
{
|
||||||
|
if(provider == AIStudio.Settings.Provider.NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
if (provider.IsEnterpriseConfiguration)
|
if (provider.IsEnterpriseConfiguration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public partial class Chat : MSGComponentBase
|
|||||||
private IDialogService DialogService { get; init; } = null!;
|
private IDialogService DialogService { get; init; } = null!;
|
||||||
|
|
||||||
private ChatThread? chatThread;
|
private ChatThread? chatThread;
|
||||||
private AIStudio.Settings.Provider providerSettings;
|
private AIStudio.Settings.Provider providerSettings = AIStudio.Settings.Provider.NONE;
|
||||||
private bool workspaceOverlayVisible;
|
private bool workspaceOverlayVisible;
|
||||||
private string currentWorkspaceName = string.Empty;
|
private string currentWorkspaceName = string.Empty;
|
||||||
private Workspaces? workspaces;
|
private Workspaces? workspaces;
|
||||||
|
@ -18,7 +18,7 @@ public partial class Writer : MSGComponentBase
|
|||||||
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
||||||
|
|
||||||
private MudTextField<string> textField = null!;
|
private MudTextField<string> textField = null!;
|
||||||
private AIStudio.Settings.Provider providerSettings;
|
private AIStudio.Settings.Provider providerSettings = AIStudio.Settings.Provider.NONE;
|
||||||
private ChatThread? chatThread;
|
private ChatThread? chatThread;
|
||||||
private bool isStreaming;
|
private bool isStreaming;
|
||||||
private string userInput = string.Empty;
|
private string userInput = string.Empty;
|
||||||
|
@ -18,7 +18,7 @@ namespace AIStudio.Settings;
|
|||||||
/// <param name="IsSelfHosted">Whether the provider is self-hosted.</param>
|
/// <param name="IsSelfHosted">Whether the provider is self-hosted.</param>
|
||||||
/// <param name="Hostname">The hostname of the provider. Useful for self-hosted providers.</param>
|
/// <param name="Hostname">The hostname of the provider. Useful for self-hosted providers.</param>
|
||||||
/// <param name="Model">The LLM model to use for chat.</param>
|
/// <param name="Model">The LLM model to use for chat.</param>
|
||||||
public readonly record struct Provider(
|
public record Provider(
|
||||||
uint Num,
|
uint Num,
|
||||||
string Id,
|
string Id,
|
||||||
string InstanceName,
|
string InstanceName,
|
||||||
@ -31,6 +31,21 @@ public readonly record struct Provider(
|
|||||||
Host Host = Host.NONE,
|
Host Host = Host.NONE,
|
||||||
HFInferenceProvider HFInferenceProvider = HFInferenceProvider.NONE) : ISecretId, IConfigurationObject
|
HFInferenceProvider HFInferenceProvider = HFInferenceProvider.NONE) : ISecretId, IConfigurationObject
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static readonly Provider NONE = new();
|
||||||
|
|
||||||
|
public Provider() : this(
|
||||||
|
0,
|
||||||
|
Guid.Empty.ToString(),
|
||||||
|
string.Empty,
|
||||||
|
LLMProviders.NONE,
|
||||||
|
default,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
Guid.Empty)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#region Overrides of ValueType
|
#region Overrides of ValueType
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -215,18 +215,18 @@ public sealed class SettingsManager
|
|||||||
return this.ConfigurationData.Providers[0];
|
return this.ConfigurationData.Providers[0];
|
||||||
|
|
||||||
// Is there a current provider with a sufficiently high confidence level?
|
// Is there a current provider with a sufficiently high confidence level?
|
||||||
Provider currentProvider = default;
|
var currentProvider = Provider.NONE;
|
||||||
if (currentProviderId is not null && !string.IsNullOrWhiteSpace(currentProviderId))
|
if (currentProviderId is not null && !string.IsNullOrWhiteSpace(currentProviderId))
|
||||||
{
|
{
|
||||||
var currentProviderProbe = this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == currentProviderId);
|
var currentProviderProbe = this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == currentProviderId);
|
||||||
if (currentProviderProbe.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel)
|
if (currentProviderProbe is not null && currentProviderProbe.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel)
|
||||||
currentProvider = currentProviderProbe;
|
currentProvider = currentProviderProbe;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there a component-preselected provider with a sufficiently high confidence level?
|
// Is there a component-preselected provider with a sufficiently high confidence level?
|
||||||
Provider preselectedProvider = default;
|
var preselectedProvider = Provider.NONE;
|
||||||
var preselectedProviderProbe = component.PreselectedProvider(this);
|
var preselectedProviderProbe = component.PreselectedProvider(this);
|
||||||
if(preselectedProviderProbe != default && preselectedProviderProbe.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel)
|
if(preselectedProviderProbe != Provider.NONE && preselectedProviderProbe.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel)
|
||||||
preselectedProvider = preselectedProviderProbe;
|
preselectedProvider = preselectedProviderProbe;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -234,14 +234,14 @@ public sealed class SettingsManager
|
|||||||
// and the preselected provider is available and has a confidence level
|
// and the preselected provider is available and has a confidence level
|
||||||
// that is high enough.
|
// that is high enough.
|
||||||
//
|
//
|
||||||
if(usePreselectionBeforeCurrentProvider && preselectedProvider != default)
|
if(usePreselectionBeforeCurrentProvider && preselectedProvider != Provider.NONE)
|
||||||
return preselectedProvider;
|
return preselectedProvider;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Case: The current provider is available and has a confidence level that is
|
// Case: The current provider is available and has a confidence level that is
|
||||||
// high enough.
|
// high enough.
|
||||||
//
|
//
|
||||||
if(currentProvider != default)
|
if(currentProvider != Provider.NONE)
|
||||||
return currentProvider;
|
return currentProvider;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -250,11 +250,11 @@ public sealed class SettingsManager
|
|||||||
// level that is high enough. The preselected provider is available and
|
// level that is high enough. The preselected provider is available and
|
||||||
// has a confidence level that is high enough.
|
// has a confidence level that is high enough.
|
||||||
//
|
//
|
||||||
if(preselectedProvider != default)
|
if(preselectedProvider != Provider.NONE)
|
||||||
return preselectedProvider;
|
return preselectedProvider;
|
||||||
|
|
||||||
// When there is an app-wide preselected provider, and it has a confidence level that is high enough, we return it:
|
// When there is an app-wide preselected provider, and it has a confidence level that is high enough, we return it:
|
||||||
return this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProvider && x.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel);
|
return this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProvider && x.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel) ?? Provider.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile GetPreselectedProfile(Tools.Components component)
|
public Profile GetPreselectedProfile(Tools.Components component)
|
||||||
|
@ -113,7 +113,7 @@ public static class ComponentsExtensions
|
|||||||
Components.AGENT_DATA_SOURCE_SELECTION => settingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider) : default,
|
Components.AGENT_DATA_SOURCE_SELECTION => settingsManager.ConfigurationData.AgentDataSourceSelection.PreselectAgentOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.AgentDataSourceSelection.PreselectedAgentProvider) : default,
|
||||||
Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION => settingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider) : default,
|
Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION => settingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectAgentOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.AgentRetrievalContextValidation.PreselectedAgentProvider) : default,
|
||||||
|
|
||||||
_ => default,
|
_ => Settings.Provider.NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Profile PreselectedProfile(this Components component, SettingsManager settingsManager) => component switch
|
public static Profile PreselectedProfile(this Components component, SettingsManager settingsManager) => component switch
|
||||||
|
@ -37,7 +37,7 @@ public sealed class DataSourceService
|
|||||||
// does not mean anything. We cannot filter the data sources by any means.
|
// does not mean anything. We cannot filter the data sources by any means.
|
||||||
// We return an empty list. Better safe than sorry.
|
// We return an empty list. Better safe than sorry.
|
||||||
//
|
//
|
||||||
if (selectedLLMProvider == default)
|
if (selectedLLMProvider == Settings.Provider.NONE)
|
||||||
{
|
{
|
||||||
this.logger.LogWarning("The selected LLM provider is not set. We cannot filter the data sources by any means.");
|
this.logger.LogWarning("The selected LLM provider is not set. We cannot filter the data sources by any means.");
|
||||||
return new([], []);
|
return new([], []);
|
||||||
|
Loading…
Reference in New Issue
Block a user