From bcdbf7dcbd5be0faa07a05bd04795093a6d82637 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 23 Aug 2024 18:11:54 +0200 Subject: [PATCH] Improved the rewrite assistant by letting you choose the voice for the sentence structure (#92) --- .../AssistantRewriteImprove.razor | 1 + .../AssistantRewriteImprove.razor.cs | 7 +++++-- .../RewriteImprove/SentenceStructure.cs | 9 +++++++++ .../SentenceStructureExtensions.cs | 20 +++++++++++++++++++ app/MindWork AI Studio/Pages/Settings.razor | 1 + .../Settings/ConfigurationSelectData.cs | 6 ++++++ .../Settings/DataModel/DataRewriteImprove.cs | 5 +++++ .../wwwroot/changelog/v0.8.12.md | 1 + 8 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructure.cs create mode 100644 app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructureExtensions.cs diff --git a/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor b/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor index 5000c1f..c9f8be4 100644 --- a/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor +++ b/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor @@ -4,6 +4,7 @@ + diff --git a/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor.cs b/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor.cs index 48328a6..303a127 100644 --- a/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor.cs +++ b/app/MindWork AI Studio/Assistants/RewriteImprove/AssistantRewriteImprove.razor.cs @@ -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 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. - The style of the text: {this.selectedWritingStyle.Prompt()}. You follow the rules according - to {this.SystemPromptLanguage()} in all your changes. + The style of the text: {this.selectedWritingStyle.Prompt()}.{this.selectedSentenceStructure.Prompt()} + You follow the rules according to {this.SystemPromptLanguage()} in all your changes. """; protected override bool ShowResult => false; @@ -53,6 +53,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore this.selectedTargetLanguage = CommonLanguages.AS_IS; this.customTargetLanguage = string.Empty; 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.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider); this.selectedWritingStyle = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle; + this.selectedSentenceStructure = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedSentenceStructure; return true; } @@ -89,6 +91,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore private string customTargetLanguage = string.Empty; private string rewrittenText = string.Empty; private WritingStyles selectedWritingStyle; + private SentenceStructure selectedSentenceStructure; private string? ValidateText(string text) { diff --git a/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructure.cs b/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructure.cs new file mode 100644 index 0000000..acb85a0 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructure.cs @@ -0,0 +1,9 @@ +namespace AIStudio.Assistants.RewriteImprove; + +public enum SentenceStructure +{ + NOT_SPECIFIED = 0, + + ACTIVE, + PASSIVE, +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructureExtensions.cs b/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructureExtensions.cs new file mode 100644 index 0000000..3abefd1 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/RewriteImprove/SentenceStructureExtensions.cs @@ -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, + }; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Settings.razor b/app/MindWork AI Studio/Pages/Settings.razor index 324fd0f..59d701c 100644 --- a/app/MindWork AI Studio/Pages/Settings.razor +++ b/app/MindWork AI Studio/Pages/Settings.razor @@ -197,6 +197,7 @@ } + diff --git a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs index f879237..d62c777 100644 --- a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs +++ b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs @@ -116,4 +116,10 @@ public static class ConfigurationSelectDataFactory foreach (var style in Enum.GetValues()) yield return new(style.Name(), style); } + + public static IEnumerable> GetSentenceStructureData() + { + foreach (var voice in Enum.GetValues()) + yield return new(voice.Name(), voice); + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataRewriteImprove.cs b/app/MindWork AI Studio/Settings/DataModel/DataRewriteImprove.cs index 7be49dc..48742de 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataRewriteImprove.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataRewriteImprove.cs @@ -24,6 +24,11 @@ public sealed class DataRewriteImprove /// Preselect any writing style? /// public WritingStyles PreselectedWritingStyle { get; set; } + + /// + /// Preselect any voice style? + /// + public SentenceStructure PreselectedSentenceStructure { get; set; } /// /// Preselect a provider? diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.8.12.md b/app/MindWork AI Studio/wwwroot/changelog/v0.8.12.md index 27eaf39..4a2dc89 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.8.12.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.8.12.md @@ -2,6 +2,7 @@ - Added an e-mail writing assistant. - Added the possibility to preselect some e-mail writing assistant options. - 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 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).