mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 04:00:21 +00:00 
			
		
		
		
	Improved the rewrite assistant by letting you choose the voice for the sentence structure
This commit is contained in:
		
							parent
							
								
									537a608e7a
								
							
						
					
					
						commit
						6740d5f8db
					
				@ -4,6 +4,7 @@
 | 
				
			|||||||
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to improve" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
 | 
					<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to improve" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
 | 
				
			||||||
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
 | 
					<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
 | 
				
			||||||
<EnumSelection T="WritingStyles" NameFunc="@(style => style.Name())" @bind-Value="@this.selectedWritingStyle" Icon="@Icons.Material.Filled.Edit" Label="Writing style" AllowOther="@false" />
 | 
					<EnumSelection T="WritingStyles" NameFunc="@(style => style.Name())" @bind-Value="@this.selectedWritingStyle" Icon="@Icons.Material.Filled.Edit" Label="Writing style" AllowOther="@false" />
 | 
				
			||||||
 | 
					<EnumSelection T="SentenceStructure" NameFunc="@(voice => voice.Name())" @bind-Value="@this.selectedSentenceStructure" Icon="@Icons.Material.Filled.Person4" Label="Sentence structure" />
 | 
				
			||||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
 | 
					<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.RewriteText()">
 | 
					<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.RewriteText()">
 | 
				
			||||||
 | 
				
			|||||||
@ -19,8 +19,8 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
 | 
				
			|||||||
        text. You can also correct spelling and grammar issues. You never add additional information. You never
 | 
					        text. You can also correct spelling and grammar issues. You never add additional information. You never
 | 
				
			||||||
        ask the user for additional information. Your response only contains the improved text. You do not explain
 | 
					        ask the user for additional information. Your response only contains the improved text. You do not explain
 | 
				
			||||||
        your changes. If no changes are needed, you return the text unchanged.
 | 
					        your changes. If no changes are needed, you return the text unchanged.
 | 
				
			||||||
        The style of the text: {this.selectedWritingStyle.Prompt()}. You follow the rules according
 | 
					        The style of the text: {this.selectedWritingStyle.Prompt()}.{this.selectedSentenceStructure.Prompt()}
 | 
				
			||||||
        to {this.SystemPromptLanguage()} in all your changes.
 | 
					        You follow the rules according to {this.SystemPromptLanguage()} in all your changes.
 | 
				
			||||||
        """;
 | 
					        """;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    protected override bool ShowResult => false;
 | 
					    protected override bool ShowResult => false;
 | 
				
			||||||
@ -53,6 +53,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
 | 
				
			|||||||
            this.selectedTargetLanguage = CommonLanguages.AS_IS;
 | 
					            this.selectedTargetLanguage = CommonLanguages.AS_IS;
 | 
				
			||||||
            this.customTargetLanguage = string.Empty;
 | 
					            this.customTargetLanguage = string.Empty;
 | 
				
			||||||
            this.selectedWritingStyle = WritingStyles.NOT_SPECIFIED;
 | 
					            this.selectedWritingStyle = WritingStyles.NOT_SPECIFIED;
 | 
				
			||||||
 | 
					            this.selectedSentenceStructure = SentenceStructure.NOT_SPECIFIED;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -64,6 +65,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
 | 
				
			|||||||
            this.customTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage;
 | 
					            this.customTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage;
 | 
				
			||||||
            this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider);
 | 
					            this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider);
 | 
				
			||||||
            this.selectedWritingStyle = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle;
 | 
					            this.selectedWritingStyle = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle;
 | 
				
			||||||
 | 
					            this.selectedSentenceStructure = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedSentenceStructure;
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -89,6 +91,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
 | 
				
			|||||||
    private string customTargetLanguage = string.Empty;
 | 
					    private string customTargetLanguage = string.Empty;
 | 
				
			||||||
    private string rewrittenText = string.Empty;
 | 
					    private string rewrittenText = string.Empty;
 | 
				
			||||||
    private WritingStyles selectedWritingStyle;
 | 
					    private WritingStyles selectedWritingStyle;
 | 
				
			||||||
 | 
					    private SentenceStructure selectedSentenceStructure;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private string? ValidateText(string text)
 | 
					    private string? ValidateText(string text)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					namespace AIStudio.Assistants.RewriteImprove;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public enum SentenceStructure
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    NOT_SPECIFIED = 0,
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    ACTIVE,
 | 
				
			||||||
 | 
					    PASSIVE,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					namespace AIStudio.Assistants.RewriteImprove;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public static class SentenceStructureExtensions
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public static string Name(this SentenceStructure sentenceStructure) => sentenceStructure switch
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SentenceStructure.ACTIVE => "Active voice",
 | 
				
			||||||
 | 
					        SentenceStructure.PASSIVE => "Passive voice",
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        _ => "Not Specified",
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static string Prompt(this SentenceStructure sentenceStructure) => sentenceStructure switch
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SentenceStructure.ACTIVE => " Use an active voice for the sentence structure.",
 | 
				
			||||||
 | 
					        SentenceStructure.PASSIVE => " Use a passive voice for the sentence structure.",
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        _ => string.Empty,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -197,6 +197,7 @@
 | 
				
			|||||||
                    <ConfigurationText OptionDescription="Preselect another target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage = updatedText)"/>
 | 
					                    <ConfigurationText OptionDescription="Preselect another target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage = updatedText)"/>
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                <ConfigurationSelect OptionDescription="Preselect a writing style" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle)" Data="@ConfigurationSelectDataFactory.GetWritingStyles4RewriteData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle = selectedValue)" OptionHelp="Which writing style should be preselected?"/>
 | 
					                <ConfigurationSelect OptionDescription="Preselect a writing style" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle)" Data="@ConfigurationSelectDataFactory.GetWritingStyles4RewriteData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle = selectedValue)" OptionHelp="Which writing style should be preselected?"/>
 | 
				
			||||||
 | 
					                <ConfigurationSelect OptionDescription="Preselect a sentence structure" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedSentenceStructure)" Data="@ConfigurationSelectDataFactory.GetSentenceStructureData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedSentenceStructure = selectedValue)" OptionHelp="Which voice should be preselected for the sentence structure?"/>
 | 
				
			||||||
                <ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider = selectedValue)"/>
 | 
					                <ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider = selectedValue)"/>
 | 
				
			||||||
            </MudPaper>
 | 
					            </MudPaper>
 | 
				
			||||||
        </ExpansionPanel>
 | 
					        </ExpansionPanel>
 | 
				
			||||||
 | 
				
			|||||||
@ -116,4 +116,10 @@ public static class ConfigurationSelectDataFactory
 | 
				
			|||||||
        foreach (var style in Enum.GetValues<WritingStylesEMail>())
 | 
					        foreach (var style in Enum.GetValues<WritingStylesEMail>())
 | 
				
			||||||
            yield return new(style.Name(), style);
 | 
					            yield return new(style.Name(), style);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public static IEnumerable<ConfigurationSelectData<SentenceStructure>> GetSentenceStructureData()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        foreach (var voice in Enum.GetValues<SentenceStructure>())
 | 
				
			||||||
 | 
					            yield return new(voice.Name(), voice);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -24,6 +24,11 @@ public sealed class DataRewriteImprove
 | 
				
			|||||||
    /// Preselect any writing style?
 | 
					    /// Preselect any writing style?
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public WritingStyles PreselectedWritingStyle { get; set; }
 | 
					    public WritingStyles PreselectedWritingStyle { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Preselect any voice style?
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public SentenceStructure PreselectedSentenceStructure { get; set; }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// Preselect a provider?
 | 
					    /// Preselect a provider?
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
- Added an e-mail writing assistant.
 | 
					- Added an e-mail writing assistant.
 | 
				
			||||||
- Added the possibility to preselect some e-mail writing assistant options.
 | 
					- Added the possibility to preselect some e-mail writing assistant options.
 | 
				
			||||||
- Fixed the header height of assistant pages.
 | 
					- Fixed the header height of assistant pages.
 | 
				
			||||||
 | 
					- Improved the rewrite assistant by letting you choose the voice for the sentence structure (passive or active).
 | 
				
			||||||
- Improved assistant footer handling; the footer is now fixed at the bottom of the page.
 | 
					- Improved assistant footer handling; the footer is now fixed at the bottom of the page.
 | 
				
			||||||
- Improved the coding assistant by adding a button to delete a context.
 | 
					- Improved the coding assistant by adding a button to delete a context.
 | 
				
			||||||
- Improved chat page by scrolling to the bottom after loading (configurable; default is on).
 | 
					- Improved chat page by scrolling to the bottom after loading (configurable; default is on).
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user