Fix provider filtering for assistants

This commit is contained in:
Thorsten Sommer 2026-01-29 07:20:07 +01:00
parent 9fc5c809b0
commit a8ae1928f7
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 27 additions and 8 deletions

View File

@ -22,8 +22,10 @@
@if (this.Body is not null) @if (this.Body is not null)
{ {
<CascadingValue Value="@this"> <CascadingValue Value="@this">
<CascadingValue Value="@this.Component">
@this.Body @this.Body
</CascadingValue> </CascadingValue>
</CascadingValue>
<MudStack Row="true" AlignItems="AlignItems.Center" StretchItems="StretchItems.Start" Class="mb-3"> <MudStack Row="true" AlignItems="AlignItems.Center" StretchItems="StretchItems.Start" Class="mb-3">
<MudButton Disabled="@this.SubmitDisabled" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle"> <MudButton Disabled="@this.SubmitDisabled" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle">

View File

@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using AIStudio.Assistants;
using AIStudio.Provider; using AIStudio.Provider;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@ -10,7 +10,7 @@ namespace AIStudio.Components;
public partial class ProviderSelection : MSGComponentBase public partial class ProviderSelection : MSGComponentBase
{ {
[CascadingParameter] [CascadingParameter]
public AssistantBase<NoComponent>? AssistantBase { get; set; } public Tools.Components? Component { get; set; }
[Parameter] [Parameter]
public AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE; public AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE;
@ -21,6 +21,9 @@ public partial class ProviderSelection : MSGComponentBase
[Parameter] [Parameter]
public Func<AIStudio.Settings.Provider, string?> ValidateProvider { get; set; } = _ => null; public Func<AIStudio.Settings.Provider, string?> ValidateProvider { get; set; } = _ => null;
[Inject]
private ILogger<ProviderSelection> Logger { get; init; } = null!;
private async Task SelectionChanged(AIStudio.Settings.Provider provider) private async Task SelectionChanged(AIStudio.Settings.Provider provider)
{ {
this.ProviderSettings = provider; this.ProviderSettings = provider;
@ -30,10 +33,23 @@ public partial class ProviderSelection : MSGComponentBase
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")] [SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
private IEnumerable<AIStudio.Settings.Provider> GetAvailableProviders() private IEnumerable<AIStudio.Settings.Provider> GetAvailableProviders()
{ {
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.AssistantBase?.Component ?? Tools.Components.NONE); switch (this.Component)
{
case null:
this.Logger.LogError("Component is null! Cannot filter providers based on component settings. Missed CascadingParameter?");
yield break;
case Tools.Components.NONE:
this.Logger.LogError("Component is NONE! Cannot filter providers based on component settings. Used wrong component?");
yield break;
case { } component:
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(component);
foreach (var provider in this.SettingsManager.ConfigurationData.Providers) foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
if (provider.UsedLLMProvider != LLMProviders.NONE) 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;
break;
}
} }
} }

View File

@ -1 +1,2 @@
# v26.2.1, build 233 (2026-02-xx xx:xx UTC) # v26.2.1, build 233 (2026-02-xx xx:xx UTC)
- Fixed a bug where the global minimum confidence level was not being applied to the assistants.