2025-03-12 10:31:01 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2025-03-12 17:05:27 +00:00
|
|
|
|
2025-03-12 10:31:01 +00:00
|
|
|
using AIStudio.Settings;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
namespace AIStudio.Dialogs.Settings;
|
|
|
|
|
|
|
|
public abstract class SettingsDialogBase : ComponentBase
|
|
|
|
{
|
|
|
|
[CascadingParameter]
|
2025-03-12 18:12:56 +00:00
|
|
|
protected IMudDialogInstance MudDialog { get; set; } = null!;
|
2025-03-12 10:31:01 +00:00
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public List<ConfigurationSelectData<string>> AvailableLLMProviders { get; set; } = new();
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
protected SettingsManager SettingsManager { get; init; } = null!;
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
protected IDialogService DialogService { get; init; } = null!;
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
protected MessageBus MessageBus { get; init; } = null!;
|
|
|
|
|
|
|
|
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
this.UpdateProviders();
|
|
|
|
base.OnInitialized();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
protected void Close() => this.MudDialog.Cancel();
|
|
|
|
|
|
|
|
[SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")]
|
|
|
|
private void UpdateProviders()
|
|
|
|
{
|
|
|
|
this.AvailableLLMProviders.Clear();
|
|
|
|
foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
|
|
|
|
this.AvailableLLMProviders.Add(new (provider.InstanceName, provider.Id));
|
|
|
|
}
|
|
|
|
}
|