Fix provider filtering for assistants

This commit is contained in:
Thorsten Sommer 2026-01-29 07:20:07 +01:00
parent 1e4eb7c725
commit 6d206b0c0e
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,7 +22,9 @@
@if (this.Body is not null)
{
<CascadingValue Value="@this">
@this.Body
<CascadingValue Value="@this.Component">
@this.Body
</CascadingValue>
</CascadingValue>
<MudStack Row="true" AlignItems="AlignItems.Center" StretchItems="StretchItems.Start" Class="mb-3">

View File

@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using AIStudio.Assistants;
using AIStudio.Provider;
using Microsoft.AspNetCore.Components;
@ -10,7 +10,7 @@ namespace AIStudio.Components;
public partial class ProviderSelection : MSGComponentBase
{
[CascadingParameter]
public AssistantBase<NoComponent>? AssistantBase { get; set; }
public Tools.Components? Component { get; set; }
[Parameter]
public AIStudio.Settings.Provider ProviderSettings { get; set; } = AIStudio.Settings.Provider.NONE;
@ -21,6 +21,9 @@ public partial class ProviderSelection : MSGComponentBase
[Parameter]
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)
{
this.ProviderSettings = provider;
@ -30,10 +33,23 @@ public partial class ProviderSelection : MSGComponentBase
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
private IEnumerable<AIStudio.Settings.Provider> GetAvailableProviders()
{
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.AssistantBase?.Component ?? Tools.Components.NONE);
foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
if (provider.UsedLLMProvider != LLMProviders.NONE)
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
yield return provider;
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)
if (provider.UsedLLMProvider != LLMProviders.NONE)
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
yield return provider;
break;
}
}
}

View File

@ -1 +1,2 @@
# 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.