mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:59:48 +00:00
Implemented preselection options of icon finder assistant
This commit is contained in:
parent
f378ac6d83
commit
4fe0f82e0f
@ -5,6 +5,21 @@ public partial class AssistantIconFinder : AssistantBaseCore
|
||||
private string inputContext = string.Empty;
|
||||
private IconSources selectedIconSource;
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (this.SettingsManager.ConfigurationData.PreselectIconOptions)
|
||||
{
|
||||
this.selectedIconSource = this.SettingsManager.ConfigurationData.PreselectedIconSource;
|
||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedIconProvider);
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override string Title => "Icon Finder";
|
||||
|
||||
protected override string Description =>
|
||||
|
@ -60,10 +60,7 @@
|
||||
<MudText Typo="Typo.h6" Class="mt-3">No providers configured yet.</MudText>
|
||||
}
|
||||
|
||||
<MudButton
|
||||
Variant="Variant.Filled" Color="@Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.AddRoad"
|
||||
Class="mt-3 mb-6" OnClick="@this.AddProvider">
|
||||
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddProvider">
|
||||
Add Provider
|
||||
</MudButton>
|
||||
|
||||
@ -79,5 +76,11 @@
|
||||
<MudText Typo="Typo.h4" Class="mb-3">Workspace Options</MudText>
|
||||
<ConfigurationSelect OptionDescription="Workspace behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior = selectedValue)" OptionHelp="Should we store your chats?"/>
|
||||
<ConfigurationSelect OptionDescription="Workspace maintenance" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageTemporaryMaintenancePolicyData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy = selectedValue)" OptionHelp="If and when should we delete your temporary chats?"/>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mb-3">Assistants Options</MudText>
|
||||
<MudText Typo="Typo.h5" Class="mb-3">Icon Finder Options</MudText>
|
||||
<ConfigurationOption OptionDescription="Preselection icon options?" LabelOn="Icon options are preselected" LabelOff="No icon options are preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectIconOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectIconOptions = updatedState)" OptionHelp="When enabled, you can preselect the icon options. This is might be useful when you prefer a specific icon source or LLM model."/>
|
||||
<ConfigurationSelect OptionDescription="Preselected icon source" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedIconSource)" Data="@ConfigurationSelectDataFactory.GetIconSourcesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedIconSource = selectedValue)" OptionHelp="Which icon source should be preselected?"/>
|
||||
<ConfigurationProviderSelection Data="@this.availableProviders" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedIconProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedIconProvider = selectedValue)"/>
|
||||
</MudPaper>
|
||||
</InnerScrolling>
|
@ -24,6 +24,18 @@ public partial class Settings : ComponentBase
|
||||
|
||||
[Inject]
|
||||
protected MessageBus MessageBus { get; init; } = null!;
|
||||
|
||||
private readonly List<ConfigurationSelectData<string>> availableProviders = new();
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.UpdateProviders();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Provider related
|
||||
|
||||
@ -43,6 +55,8 @@ public partial class Settings : ComponentBase
|
||||
addedProvider = addedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ };
|
||||
|
||||
this.SettingsManager.ConfigurationData.Providers.Add(addedProvider);
|
||||
this.UpdateProviders();
|
||||
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
@ -75,6 +89,8 @@ public partial class Settings : ComponentBase
|
||||
editedProvider = editedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ };
|
||||
|
||||
this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider;
|
||||
this.UpdateProviders();
|
||||
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
@ -99,6 +115,7 @@ public partial class Settings : ComponentBase
|
||||
await this.SettingsManager.StoreSettings();
|
||||
}
|
||||
|
||||
this.UpdateProviders();
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
|
||||
@ -128,6 +145,13 @@ public partial class Settings : ComponentBase
|
||||
var modelName = provider.Model.ToString();
|
||||
return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName;
|
||||
}
|
||||
|
||||
private void UpdateProviders()
|
||||
{
|
||||
this.availableProviders.Clear();
|
||||
foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
|
||||
this.availableProviders.Add(new (provider.InstanceName, provider.Id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using AIStudio.Components.Pages.IconFinder;
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
namespace AIStudio.Settings;
|
||||
@ -55,4 +56,10 @@ public static class ConfigurationSelectDataFactory
|
||||
yield return new("Navigation never expands, no tooltips", NavBehavior.NEVER_EXPAND_NO_TOOLTIPS);
|
||||
yield return new("Always expand navigation", NavBehavior.ALWAYS_EXPAND);
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<IconSources>> GetIconSourcesData()
|
||||
{
|
||||
foreach (var source in Enum.GetValues<IconSources>())
|
||||
yield return new(source.ToString(), source);
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using AIStudio.Components.Pages.IconFinder;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
/// <summary>
|
||||
@ -56,4 +58,19 @@ public sealed class Data
|
||||
/// The navigation behavior.
|
||||
/// </summary>
|
||||
public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER;
|
||||
|
||||
/// <summary>
|
||||
/// Do we want to preselect an icon source?
|
||||
/// </summary>
|
||||
public bool PreselectIconOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The preselected icon source.
|
||||
/// </summary>
|
||||
public IconSources PreselectedIconSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The preselected icon provider.
|
||||
/// </summary>
|
||||
public string PreselectedIconProvider { get; set; } = string.Empty;
|
||||
}
|
Loading…
Reference in New Issue
Block a user