mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 00:40:20 +00:00 
			
		
		
		
	Factored bias-of-the-day settings
This commit is contained in:
		
							parent
							
								
									c77753f1f5
								
							
						
					
					
						commit
						29a5798b83
					
				@ -0,0 +1,29 @@
 | 
			
		||||
@using AIStudio.Settings
 | 
			
		||||
@using AIStudio.Settings.DataModel
 | 
			
		||||
@inherits SettingsPanelBase
 | 
			
		||||
 | 
			
		||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Psychology" HeaderText="Assistant: Bias of the Day">
 | 
			
		||||
 | 
			
		||||
    <ConfigurationOption OptionDescription="Restrict to one bias a day?" LabelOn="Yes, you can only retrieve one bias per day" LabelOff="No restriction. You can retrieve as many biases as you want per day." State="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.RestrictOneBiasPerDay)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.BiasOfTheDay.RestrictOneBiasPerDay = updatedState)"/>
 | 
			
		||||
    
 | 
			
		||||
    <MudField Label="Statistics" Variant="Variant.Outlined" Class="mb-2">
 | 
			
		||||
        <MudText Typo="Typo.body1">
 | 
			
		||||
            You have learned about @this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Count out of @BiasCatalog.ALL_BIAS.Count biases.
 | 
			
		||||
        </MudText>
 | 
			
		||||
        <MudButton Size="Size.Small" Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Restore" Color="Color.Error" OnClick="@(() => this.ResetBiasOfTheDayHistory())">
 | 
			
		||||
            Reset
 | 
			
		||||
        </MudButton>
 | 
			
		||||
    </MudField>
 | 
			
		||||
    
 | 
			
		||||
    <MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
 | 
			
		||||
        <ConfigurationOption OptionDescription="Preselect options?" LabelOn="Options are preselected" LabelOff="No options are preselected" State="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions = updatedState)" OptionHelp="When enabled, you can preselect options. This is might be useful when you prefer a specific language or LLM model."/>
 | 
			
		||||
        <ConfigurationSelect OptionDescription="Preselect the language" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonLanguagesOptionalData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage = selectedValue)" OptionHelp="Which language should be preselected?"/>
 | 
			
		||||
        @if (this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage is CommonLanguages.OTHER)
 | 
			
		||||
        {
 | 
			
		||||
            <ConfigurationText OptionDescription="Preselect another language" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedOtherLanguage = updatedText)"/>
 | 
			
		||||
        }
 | 
			
		||||
        <ConfigurationSelect OptionDescription="Preselect one of your profiles?" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProfile)" Data="@ConfigurationSelectDataFactory.GetProfilesData(this.SettingsManager.ConfigurationData.Profiles)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProfile = selectedValue)" OptionHelp="Would you like to preselect one of your profiles?"/>
 | 
			
		||||
        <ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.MinimumProviderConfidence = selectedValue)"/>
 | 
			
		||||
        <ConfigurationProviderSelection Component="Components.BIAS_DAY_ASSISTANT" Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProvider = selectedValue)"/>
 | 
			
		||||
    </MudPaper>
 | 
			
		||||
</ExpansionPanel>
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
using AIStudio.Dialogs;
 | 
			
		||||
 | 
			
		||||
using DialogOptions = AIStudio.Dialogs.DialogOptions;
 | 
			
		||||
 | 
			
		||||
namespace AIStudio.Components.Settings;
 | 
			
		||||
 | 
			
		||||
public partial class SettingsPanelAssistantBias : SettingsPanelBase
 | 
			
		||||
{
 | 
			
		||||
    private async Task ResetBiasOfTheDayHistory()
 | 
			
		||||
    {
 | 
			
		||||
        var dialogParameters = new DialogParameters
 | 
			
		||||
        {
 | 
			
		||||
            { "Message", "Are you sure you want to reset your bias-of-the-day statistics? The system will no longer remember which biases you already know. As a result, biases you are already familiar with may be addressed again." },
 | 
			
		||||
        };
 | 
			
		||||
        
 | 
			
		||||
        var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>("Reset your bias-of-the-day statistics", dialogParameters, DialogOptions.FULLSCREEN);
 | 
			
		||||
        var dialogResult = await dialogReference.Result;
 | 
			
		||||
        if (dialogResult is null || dialogResult.Canceled)
 | 
			
		||||
            return;
 | 
			
		||||
        
 | 
			
		||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Clear();
 | 
			
		||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.MinValue;
 | 
			
		||||
        await this.SettingsManager.StoreSettings();
 | 
			
		||||
        
 | 
			
		||||
        await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -506,32 +506,7 @@
 | 
			
		||||
            </MudPaper>
 | 
			
		||||
        </ExpansionPanel>
 | 
			
		||||
 | 
			
		||||
        <ExpansionPanel HeaderIcon="@Icons.Material.Filled.Psychology" HeaderText="Assistant: Bias of the Day">
 | 
			
		||||
 | 
			
		||||
            <ConfigurationOption OptionDescription="Restrict to one bias a day?" LabelOn="Yes, you can only retrieve one bias per day" LabelOff="No restriction. You can retrieve as many biases as you want per day." State="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.RestrictOneBiasPerDay)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.BiasOfTheDay.RestrictOneBiasPerDay = updatedState)"/>
 | 
			
		||||
            
 | 
			
		||||
            <MudField Label="Statistics" Variant="Variant.Outlined" Class="mb-2">
 | 
			
		||||
                <MudText Typo="Typo.body1">
 | 
			
		||||
                    You have learned about @this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Count out of @BiasCatalog.ALL_BIAS.Count biases.
 | 
			
		||||
                </MudText>
 | 
			
		||||
                <MudButton Size="Size.Small" Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Restore" Color="Color.Error" OnClick="@(() => this.ResetBiasOfTheDayHistory())">
 | 
			
		||||
                    Reset
 | 
			
		||||
                </MudButton>
 | 
			
		||||
            </MudField>
 | 
			
		||||
            
 | 
			
		||||
            <MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
 | 
			
		||||
                <ConfigurationOption OptionDescription="Preselect options?" LabelOn="Options are preselected" LabelOff="No options are preselected" State="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions = updatedState)" OptionHelp="When enabled, you can preselect options. This is might be useful when you prefer a specific language or LLM model."/>
 | 
			
		||||
                <ConfigurationSelect OptionDescription="Preselect the language" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonLanguagesOptionalData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage = selectedValue)" OptionHelp="Which language should be preselected?"/>
 | 
			
		||||
                @if (this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage is CommonLanguages.OTHER)
 | 
			
		||||
                {
 | 
			
		||||
                    <ConfigurationText OptionDescription="Preselect another language" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedOtherLanguage = updatedText)"/>
 | 
			
		||||
                }
 | 
			
		||||
                <ConfigurationSelect OptionDescription="Preselect one of your profiles?" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProfile)" Data="@ConfigurationSelectDataFactory.GetProfilesData(this.SettingsManager.ConfigurationData.Profiles)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProfile = selectedValue)" OptionHelp="Would you like to preselect one of your profiles?"/>
 | 
			
		||||
                <ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.MinimumProviderConfidence = selectedValue)"/>
 | 
			
		||||
                <ConfigurationProviderSelection Component="Components.BIAS_DAY_ASSISTANT" Data="@this.availableLLMProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedProvider = selectedValue)"/>
 | 
			
		||||
            </MudPaper>
 | 
			
		||||
        </ExpansionPanel>
 | 
			
		||||
        
 | 
			
		||||
        <SettingsPanelAgentContentCleaner AvailableLLMProvidersFunc="@(() => this.availableLLMProviders)" />
 | 
			
		||||
        <SettingsPanelAssistantBias AvailableLLMProvidersFunc="() => this.availableLLMProviders" />
 | 
			
		||||
        <SettingsPanelAgentContentCleaner AvailableLLMProvidersFunc="() => this.availableLLMProviders" />
 | 
			
		||||
    </MudExpansionPanels>
 | 
			
		||||
</InnerScrolling>
 | 
			
		||||
@ -334,29 +334,6 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
 | 
			
		||||
        await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region Bias-of-the-day related
 | 
			
		||||
 | 
			
		||||
    private async Task ResetBiasOfTheDayHistory()
 | 
			
		||||
    {
 | 
			
		||||
        var dialogParameters = new DialogParameters
 | 
			
		||||
        {
 | 
			
		||||
            { "Message", "Are you sure you want to reset your bias-of-the-day statistics? The system will no longer remember which biases you already know. As a result, biases you are already familiar with may be addressed again." },
 | 
			
		||||
        };
 | 
			
		||||
        
 | 
			
		||||
        var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>("Reset your bias-of-the-day statistics", dialogParameters, DialogOptions.FULLSCREEN);
 | 
			
		||||
        var dialogResult = await dialogReference.Result;
 | 
			
		||||
        if (dialogResult is null || dialogResult.Canceled)
 | 
			
		||||
            return;
 | 
			
		||||
        
 | 
			
		||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Clear();
 | 
			
		||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.MinValue;
 | 
			
		||||
        await this.SettingsManager.StoreSettings();
 | 
			
		||||
        
 | 
			
		||||
        await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
    
 | 
			
		||||
    #region Implementation of IMessageBusReceiver
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user