mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-12 11:32:11 +00:00
Move provider capability icon setup out of Razor markup
This commit is contained in:
parent
3cd4df39bd
commit
4286663454
@ -1,18 +1,15 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits MSGComponentBase
|
||||
<MudSelect T="Provider" Value="@this.ProviderSettings" ValueChanged="@this.SelectionChanged" Validation="@this.ValidateProvider" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Apps" Margin="Margin.Dense" Label="@T("Provider")" Class="mb-3 rounded-lg" OuterClass="flex-grow-0" Variant="Variant.Outlined" Disabled="@this.Disabled">
|
||||
@foreach (var provider in this.GetAvailableProviders())
|
||||
@foreach (var providerItem in this.GetAvailableProviderSelectionItems())
|
||||
{
|
||||
<MudSelectItem Value="@provider">
|
||||
<MudSelectItem Value="@providerItem.Provider">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="w-100" Wrap="Wrap.NoWrap">
|
||||
<MudText Class="me-2">@provider</MudText>
|
||||
@{
|
||||
var capabilityIcons = this.GetCapabilityIcons(provider);
|
||||
}
|
||||
@if (capabilityIcons.Count > 0)
|
||||
<MudText Class="me-2">@providerItem.Provider</MudText>
|
||||
@if (providerItem.CapabilityIcons.Count > 0)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1" Wrap="Wrap.NoWrap" Class="flex-grow-0">
|
||||
@foreach (var capabilityIcon in capabilityIcons)
|
||||
@foreach (var capabilityIcon in providerItem.CapabilityIcons)
|
||||
{
|
||||
<MudTooltip Text="@capabilityIcon.Tooltip">
|
||||
<MudIcon Icon="@capabilityIcon.Icon" Size="Size.Small" Color="Color.Default" />
|
||||
@ -23,4 +20,4 @@
|
||||
</MudStack>
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudSelect>
|
||||
@ -49,6 +49,12 @@ public partial class ProviderSelection : MSGComponentBase
|
||||
await this.ProviderSettingsChanged.InvokeAsync(provider);
|
||||
}
|
||||
|
||||
private IEnumerable<ProviderSelectionItem> GetAvailableProviderSelectionItems()
|
||||
{
|
||||
foreach (var provider in this.GetAvailableProviders())
|
||||
yield return new(provider, this.GetCapabilityIcons(provider));
|
||||
}
|
||||
|
||||
private IReadOnlyList<CapabilityIcon> GetCapabilityIcons(AIStudio.Settings.Provider provider)
|
||||
{
|
||||
var capabilities = provider.GetModelCapabilities();
|
||||
@ -113,4 +119,6 @@ public partial class ProviderSelection : MSGComponentBase
|
||||
#endregion
|
||||
|
||||
private readonly record struct CapabilityIcon(string Icon, string Tooltip);
|
||||
}
|
||||
|
||||
private readonly record struct ProviderSelectionItem(AIStudio.Settings.Provider Provider, IReadOnlyList<CapabilityIcon> CapabilityIcons);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user