mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-27 23:19:46 +00:00
Some checks are pending
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
|
|
using AIStudio.Provider;
|
|
using AIStudio.Settings;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AIStudio.Components;
|
|
|
|
public partial class ConfigurationProviderSelection : MSGComponentBase
|
|
{
|
|
[Parameter]
|
|
public Func<string> SelectedValue { get; set; } = () => string.Empty;
|
|
|
|
[Parameter]
|
|
public Action<string> SelectionUpdate { get; set; } = _ => { };
|
|
|
|
[Parameter]
|
|
public IEnumerable<ConfigurationSelectData<string>> Data { get; set; } = new List<ConfigurationSelectData<string>>();
|
|
|
|
/// <summary>
|
|
/// Is the selection component disabled?
|
|
/// </summary>
|
|
[Parameter]
|
|
public Func<bool> Disabled { get; set; } = () => false;
|
|
|
|
[Parameter]
|
|
public Func<string> HelpText { get; set; } = () => "Select a provider that is preselected.";
|
|
|
|
[Parameter]
|
|
public Tools.Components Component { get; set; } = Tools.Components.NONE;
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]);
|
|
await base.OnParametersSetAsync();
|
|
}
|
|
|
|
#endregion
|
|
|
|
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
|
|
private IEnumerable<ConfigurationSelectData<string>> FilteredData()
|
|
{
|
|
if(this.Component is not Tools.Components.NONE and not Tools.Components.APP_SETTINGS)
|
|
yield return new(T("Use app default"), string.Empty);
|
|
|
|
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.Component);
|
|
foreach (var providerId in this.Data)
|
|
{
|
|
var provider = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == providerId.Value);
|
|
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
|
|
yield return providerId;
|
|
}
|
|
}
|
|
|
|
#region Overrides of MSGComponentBase
|
|
|
|
protected override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
|
{
|
|
switch (triggeredEvent)
|
|
{
|
|
case Event.CONFIGURATION_CHANGED:
|
|
|
|
if(string.IsNullOrWhiteSpace(this.SelectedValue()))
|
|
break;
|
|
|
|
// Check if the selected value is still valid:
|
|
if (this.Data.All(x => x.Value != this.SelectedValue()))
|
|
{
|
|
this.SelectedValue = () => string.Empty;
|
|
this.SelectionUpdate(string.Empty);
|
|
await this.SettingsManager.StoreSettings();
|
|
}
|
|
|
|
this.StateHasChanged();
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |