mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 11:51:37 +00:00
Working on the prototype for PromptOptimizer
This commit is contained in:
parent
6836fd25b5
commit
b69fa215f8
@ -1,5 +1,5 @@
|
||||
@attribute [Route(Routes.ASSISTANT_PROMPT_OPTIMIZER)]
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.NoSettingsPanel>
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogPromptOptimizer>
|
||||
|
||||
<MudTextField T="string"
|
||||
@bind-Text="@this.inputPrompt"
|
||||
@ -14,27 +14,61 @@
|
||||
Class="mb-3"
|
||||
UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
|
||||
<EnumSelection T="CommonLanguages"
|
||||
NameFunc="@(language => language.NameSelectingOptional())"
|
||||
@bind-Value="@this.selectedTargetLanguage"
|
||||
Icon="@Icons.Material.Filled.Translate"
|
||||
Label="@T("Language for the optimized prompt")"
|
||||
AllowOther="@true"
|
||||
OtherValue="CommonLanguages.OTHER"
|
||||
@bind-OtherInput="@this.customTargetLanguage"
|
||||
ValidateOther="@this.ValidateCustomLanguage"
|
||||
LabelOther="@T("Custom language")"/>
|
||||
|
||||
<MudTextField T="string"
|
||||
AutoGrow="true"
|
||||
Lines="2"
|
||||
@bind-Text="@this.importantAspects"
|
||||
Class="mb-3"
|
||||
Label="@T("(Optional) Important Aspects for the prompt")"
|
||||
HelperText="@T("(Optional) Specify aspects the optimizer should emphasize in the resulting prompt, such as role precision, step ordering, output structure, or constraints.")"
|
||||
ShrinkLabel="true"
|
||||
Variant="Variant.Outlined"
|
||||
AdornmentIcon="@Icons.Material.Filled.List"
|
||||
Adornment="Adornment.Start"/>
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Class="mb-2">
|
||||
<MudText Typo="Typo.h6">@T("Prompt Recommendations")</MudText>
|
||||
@if (this.ShowUpdatedPromptGuidelinesIndicator)
|
||||
{
|
||||
<MudTooltip Text="@T("Prompt recommendations updated from your latest optimization.")">
|
||||
<MudIcon Icon="@Icons.Material.Filled.AutoFixHigh" Color="Color.Info" Size="Size.Medium" Class="ml-2"/>
|
||||
</MudTooltip>
|
||||
}
|
||||
</MudStack>
|
||||
|
||||
@if (!this.useCustomPromptGuide)
|
||||
{
|
||||
<MudJustifiedText Class="mb-3">@T("Use these recommendations, that are based on our own prompt guide, to improve the clarity, directness, and relevance of your prompts. The suggestions are updated based on your latest prompt optimization.")</MudJustifiedText>
|
||||
|
||||
<MudGrid Class="mb-3">
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recClarityDirectness" Label="@T("Be clear and direct")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recClarityDirectness" Label="@T("Be clear and direct")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recExamplesContext" Label="@T("Add examples and context")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recExamplesContext" Label="@T("Add examples and context")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recSequentialSteps" Label="@T("Use sequential steps")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recSequentialSteps" Label="@T("Use sequential steps")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recStructureMarkers" Label="@T("Structure with markers")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recStructureMarkers" Label="@T("Structure with markers")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recRoleDefinition" Label="@T("Give the model a role")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recRoleDefinition" Label="@T("Give the model a role")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudTextField T="string" Value="@this.recLanguageChoice" Label="@T("Choose prompt language deliberately")" ReadOnly="true" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" />
|
||||
<MudTextField T="string" Value="@this.recLanguageChoice" Label="@T("Choose prompt language deliberately")" ReadOnly="true" Variant="Variant.Outlined" Lines="2" AutoGrow="@true" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
}
|
||||
@ -64,7 +98,7 @@
|
||||
|
||||
<MudTextField T="string"
|
||||
Text="@this.CustomPromptGuideFileName"
|
||||
Label="@T("Custom guide file")"
|
||||
Label="@T("Custom prompt guide file")"
|
||||
ReadOnly="true"
|
||||
Disabled="@(!this.useCustomPromptGuide)"
|
||||
Variant="Variant.Outlined"
|
||||
@ -79,28 +113,4 @@
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<EnumSelection T="CommonLanguages"
|
||||
NameFunc="@(language => language.NameSelectingOptional())"
|
||||
@bind-Value="@this.selectedTargetLanguage"
|
||||
Icon="@Icons.Material.Filled.Translate"
|
||||
Label="@T("Language for the optimized prompt")"
|
||||
AllowOther="@true"
|
||||
OtherValue="CommonLanguages.OTHER"
|
||||
@bind-OtherInput="@this.customTargetLanguage"
|
||||
ValidateOther="@this.ValidateCustomLanguage"
|
||||
LabelOther="@T("Custom language")"/>
|
||||
|
||||
<MudTextField T="string"
|
||||
AutoGrow="true"
|
||||
Lines="2"
|
||||
@bind-Text="@this.importantAspects"
|
||||
Class="mb-3"
|
||||
Label="@T("(Optional) Important Aspects for the prompt")"
|
||||
HelperText="@T("(Optional) Specify aspects the optimizer should emphasize in the resulting prompt, such as role precision, step ordering, output structure, or constraints.")"
|
||||
ShrinkLabel="true"
|
||||
Variant="Variant.Outlined"
|
||||
AdornmentIcon="@Icons.Material.Filled.List"
|
||||
Adornment="Adornment.Start"/>
|
||||
|
||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ using Microsoft.Extensions.FileProviders;
|
||||
|
||||
namespace AIStudio.Assistants.PromptOptimizer;
|
||||
|
||||
public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPanel>
|
||||
public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialogPromptOptimizer>
|
||||
{
|
||||
private static readonly Regex JSON_CODE_FENCE_REGEX = new(
|
||||
pattern: """```(?:json)?\s*(?<json>\{[\s\S]*\})\s*```""",
|
||||
@ -31,7 +31,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
|
||||
protected override string Title => T("Prompt Optimizer");
|
||||
|
||||
protected override string Description => T("Optimize a prompt using your prompt guideline and get targeted recommendations for future versions.");
|
||||
protected override string Description => T("Optimize a prompt using either the default or your individual prompt guideline and get targeted recommendations for future versions of the prompt.");
|
||||
|
||||
protected override string SystemPrompt =>
|
||||
"""
|
||||
@ -70,22 +70,37 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
protected override void ResetForm()
|
||||
{
|
||||
this.inputPrompt = string.Empty;
|
||||
this.selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
this.customTargetLanguage = string.Empty;
|
||||
this.importantAspects = string.Empty;
|
||||
this.useCustomPromptGuide = false;
|
||||
this.customPromptGuideFiles.Clear();
|
||||
this.currentCustomPromptGuidePath = string.Empty;
|
||||
this.customPromptingGuidelineContent = string.Empty;
|
||||
this.hasUpdatedDefaultRecommendations = false;
|
||||
this.ResetGuidelineSummaryToDefault();
|
||||
this.ResetOutput();
|
||||
|
||||
if (!this.MightPreselectValues())
|
||||
{
|
||||
this.selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
this.customTargetLanguage = string.Empty;
|
||||
this.importantAspects = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool MightPreselectValues() => false;
|
||||
protected override bool MightPreselectValues()
|
||||
{
|
||||
if (!this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)
|
||||
return false;
|
||||
|
||||
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedTargetLanguage;
|
||||
this.customTargetLanguage = this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedOtherLanguage;
|
||||
this.importantAspects = this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedImportantAspects;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.ResetGuidelineSummaryToDefault();
|
||||
this.hasUpdatedDefaultRecommendations = false;
|
||||
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_PROMPT_OPTIMIZER_ASSISTANT).FirstOrDefault();
|
||||
if (deferredContent is not null)
|
||||
@ -95,7 +110,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
}
|
||||
|
||||
private string inputPrompt = string.Empty;
|
||||
private CommonLanguages selectedTargetLanguage;
|
||||
private CommonLanguages selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private string importantAspects = string.Empty;
|
||||
private bool useCustomPromptGuide;
|
||||
@ -103,6 +118,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
private string currentCustomPromptGuidePath = string.Empty;
|
||||
private string customPromptingGuidelineContent = string.Empty;
|
||||
private bool isLoadingCustomPromptGuide;
|
||||
private bool hasUpdatedDefaultRecommendations;
|
||||
|
||||
private string optimizedPrompt = string.Empty;
|
||||
private string recClarityDirectness = string.Empty;
|
||||
@ -112,7 +128,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
private string recRoleDefinition = string.Empty;
|
||||
private string recLanguageChoice = string.Empty;
|
||||
|
||||
private bool HasOptimizationResult => !string.IsNullOrWhiteSpace(this.optimizedPrompt);
|
||||
private bool ShowUpdatedPromptGuidelinesIndicator => !this.useCustomPromptGuide && this.hasUpdatedDefaultRecommendations;
|
||||
private bool CanPreviewCustomPromptGuide => this.useCustomPromptGuide && this.customPromptGuideFiles.Count > 0;
|
||||
private string CustomPromptGuideFileName => this.customPromptGuideFiles.Count switch
|
||||
{
|
||||
@ -159,6 +175,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
|
||||
this.ClearInputIssues();
|
||||
this.ResetOutput();
|
||||
this.hasUpdatedDefaultRecommendations = false;
|
||||
|
||||
var promptingGuideline = await this.GetPromptingGuidelineForOptimizationAsync();
|
||||
if (string.IsNullOrWhiteSpace(promptingGuideline))
|
||||
@ -177,12 +194,12 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
if (!TryParseOptimizationResult(aiResponse, out var parsedResult))
|
||||
{
|
||||
this.optimizedPrompt = aiResponse.Trim();
|
||||
this.recClarityDirectness = T("Add clearer goals and explicit quality expectations.");
|
||||
this.recExamplesContext = T("Add short examples and background context for your specific use case.");
|
||||
this.recSequentialSteps = T("Break the task into numbered steps if order matters.");
|
||||
this.recStructureMarkers = T("Use headings or markers to separate context, task, and constraints.");
|
||||
this.recRoleDefinition = T("Define a role for the model to focus output style and expertise.");
|
||||
this.recLanguageChoice = T("Use English for complex prompts and explicitly request response language if needed.");
|
||||
if (!this.useCustomPromptGuide)
|
||||
{
|
||||
this.ApplyFallbackRecommendations();
|
||||
this.hasUpdatedDefaultRecommendations = true;
|
||||
}
|
||||
|
||||
this.AddInputIssue(T("The model response was not in the expected JSON format. The raw response is shown as optimized prompt."));
|
||||
this.AddVisibleOptimizedPromptBlock();
|
||||
return;
|
||||
@ -298,12 +315,31 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
private void ApplyOptimizationResult(PromptOptimizationResult optimizationResult)
|
||||
{
|
||||
this.optimizedPrompt = optimizationResult.OptimizedPrompt.Trim();
|
||||
this.recClarityDirectness = this.EmptyFallback(optimizationResult.Recommendations.ClarityAndDirectness);
|
||||
this.recExamplesContext = this.EmptyFallback(optimizationResult.Recommendations.ExamplesAndContext);
|
||||
this.recSequentialSteps = this.EmptyFallback(optimizationResult.Recommendations.SequentialSteps);
|
||||
this.recStructureMarkers = this.EmptyFallback(optimizationResult.Recommendations.StructureWithMarkers);
|
||||
this.recRoleDefinition = this.EmptyFallback(optimizationResult.Recommendations.RoleDefinition);
|
||||
this.recLanguageChoice = this.EmptyFallback(optimizationResult.Recommendations.LanguageChoice);
|
||||
if (this.useCustomPromptGuide)
|
||||
return;
|
||||
|
||||
this.ApplyRecommendations(optimizationResult.Recommendations);
|
||||
this.hasUpdatedDefaultRecommendations = true;
|
||||
}
|
||||
|
||||
private void ApplyRecommendations(PromptOptimizationRecommendations recommendations)
|
||||
{
|
||||
this.recClarityDirectness = this.EmptyFallback(recommendations.ClarityAndDirectness);
|
||||
this.recExamplesContext = this.EmptyFallback(recommendations.ExamplesAndContext);
|
||||
this.recSequentialSteps = this.EmptyFallback(recommendations.SequentialSteps);
|
||||
this.recStructureMarkers = this.EmptyFallback(recommendations.StructureWithMarkers);
|
||||
this.recRoleDefinition = this.EmptyFallback(recommendations.RoleDefinition);
|
||||
this.recLanguageChoice = this.EmptyFallback(recommendations.LanguageChoice);
|
||||
}
|
||||
|
||||
private void ApplyFallbackRecommendations()
|
||||
{
|
||||
this.recClarityDirectness = T("Add clearer goals and explicit quality expectations.");
|
||||
this.recExamplesContext = T("Add short examples and background context for your specific use case.");
|
||||
this.recSequentialSteps = T("Break the task into numbered steps if order matters.");
|
||||
this.recStructureMarkers = T("Use headings or markers to separate context, task, and constraints.");
|
||||
this.recRoleDefinition = T("Define a role for the model to focus output style and expertise.");
|
||||
this.recLanguageChoice = T("Use English for complex prompts and explicitly request response language if needed.");
|
||||
}
|
||||
|
||||
private string EmptyFallback(string text)
|
||||
@ -322,11 +358,11 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
private void ResetGuidelineSummaryToDefault()
|
||||
{
|
||||
this.recClarityDirectness = T("Use clear, explicit instructions and directly state quality expectations.");
|
||||
this.recExamplesContext = T("Include short examples and context that explain the purpose behind requirements.");
|
||||
this.recExamplesContext = T("Include short examples and context that explain the purpose behind your requirements.");
|
||||
this.recSequentialSteps = T("Prefer numbered steps when task order matters.");
|
||||
this.recStructureMarkers = T("Separate context, task, constraints, and output format with headings or markers.");
|
||||
this.recRoleDefinition = T("Assign a role to shape tone, expertise, and focus.");
|
||||
this.recLanguageChoice = T("For complex tasks, write prompts in English and request response language explicitly if needed.");
|
||||
this.recLanguageChoice = T("For complex tasks, write prompts in English.");
|
||||
}
|
||||
|
||||
private void AddVisibleOptimizedPromptBlock()
|
||||
@ -411,14 +447,16 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<NoSettingsPane
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep only a single file and prefer the newly attached one over the previous selection.
|
||||
var selected = files.FirstOrDefault(file => !string.Equals(file.FilePath, this.currentCustomPromptGuidePath, StringComparison.OrdinalIgnoreCase))
|
||||
?? files.First();
|
||||
|
||||
var replacedPrevious = !string.IsNullOrWhiteSpace(this.currentCustomPromptGuidePath) &&
|
||||
!string.Equals(this.currentCustomPromptGuidePath, selected.FilePath, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
this.customPromptGuideFiles = [ selected ];
|
||||
this.currentCustomPromptGuidePath = selected.FilePath;
|
||||
|
||||
if (files.Count > 1)
|
||||
if (files.Count > 1 || replacedPrevious)
|
||||
this.Snackbar.Add(T("Replaced the previously selected custom prompt guide file."), Severity.Info);
|
||||
|
||||
await this.LoadCustomPromptGuidelineContentAsync(selected);
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
@using AIStudio.Settings
|
||||
@inherits SettingsDialogBase
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6" Class="d-flex align-center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.AutoFixHigh" Class="mr-2" />
|
||||
@T("Assistant: Prompt Optimizer Options")
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
||||
<ConfigurationOption OptionDescription="@T("Preselect prompt optimizer options?")" LabelOn="@T("Prompt optimizer options are preselected")" LabelOff="@T("No prompt optimizer options are preselected")" State="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions = updatedState)" OptionHelp="@T("When enabled, you can preselect target language, important aspects, and provider defaults for the prompt optimizer assistant.")"/>
|
||||
<ConfigurationSelect OptionDescription="@T("Preselect the target language")" Disabled="@(() => !this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedTargetLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonLanguagesOptionalData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedTargetLanguage = selectedValue)" OptionHelp="@T("Which target language should be preselected?")"/>
|
||||
@if (this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedTargetLanguage is CommonLanguages.OTHER)
|
||||
{
|
||||
<ConfigurationText OptionDescription="@T("Preselect another target language")" Disabled="@(() => !this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedOtherLanguage = updatedText)"/>
|
||||
}
|
||||
<ConfigurationText OptionDescription="@T("Preselect important aspects")" Disabled="@(() => !this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" Text="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedImportantAspects)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedImportantAspects = updatedText)" NumLines="2" OptionHelp="@T("Preselect aspects the optimizer should emphasize, such as role clarity, structure, or output constraints.")" Icon="@Icons.Material.Filled.List"/>
|
||||
<ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PromptOptimizer.MinimumProviderConfidence = selectedValue)"/>
|
||||
<ConfigurationProviderSelection Component="Components.PROMPT_OPTIMIZER_ASSISTANT" Data="@this.availableLLMProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PromptOptimizer.PreselectedProvider = selectedValue)"/>
|
||||
</MudPaper>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@this.Close" Variant="Variant.Filled">
|
||||
@T("Close")
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@ -0,0 +1,3 @@
|
||||
namespace AIStudio.Dialogs.Settings;
|
||||
|
||||
public partial class SettingsDialogPromptOptimizer : SettingsDialogBase;
|
||||
@ -27,7 +27,7 @@
|
||||
<AssistantBlock TSettings="SettingsDialogTranslation" Component="Components.TRANSLATION_ASSISTANT" Name="@T("Translation")" Description="@T("Translate text into another language.")" Icon="@Icons.Material.Filled.Translate" Link="@Routes.ASSISTANT_TRANSLATION"/>
|
||||
<AssistantBlock TSettings="SettingsDialogGrammarSpelling" Component="Components.GRAMMAR_SPELLING_ASSISTANT" Name="@T("Grammar & Spelling")" Description="@T("Check grammar and spelling of a given text.")" Icon="@Icons.Material.Filled.Edit" Link="@Routes.ASSISTANT_GRAMMAR_SPELLING"/>
|
||||
<AssistantBlock TSettings="SettingsDialogRewrite" Component="Components.REWRITE_ASSISTANT" Name="@T("Rewrite & Improve")" Description="@T("Rewrite and improve a given text for a chosen style.")" Icon="@Icons.Material.Filled.Edit" Link="@Routes.ASSISTANT_REWRITE"/>
|
||||
<AssistantBlock TSettings="NoSettingsPanel" Component="Components.PROMPT_OPTIMIZER_ASSISTANT" Name="@T("Prompt Optimizer")" Description="@T("Optimize a prompt using a guideline and receive targeted recommendations.")" Icon="@Icons.Material.Filled.AutoFixHigh" Link="@Routes.ASSISTANT_PROMPT_OPTIMIZER"/>
|
||||
<AssistantBlock TSettings="SettingsDialogPromptOptimizer" Component="Components.PROMPT_OPTIMIZER_ASSISTANT" Name="@T("Prompt Optimizer")" Description="@T("Optimize a prompt using a guideline and receive targeted recommendations.")" Icon="@Icons.Material.Filled.AutoFixHigh" Link="@Routes.ASSISTANT_PROMPT_OPTIMIZER"/>
|
||||
<AssistantBlock TSettings="SettingsDialogSynonyms" Component="Components.SYNONYMS_ASSISTANT" Name="@T("Synonyms")" Description="@T("Find synonyms for a given word or phrase.")" Icon="@Icons.Material.Filled.Spellcheck" Link="@Routes.ASSISTANT_SYNONYMS"/>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
@ -115,6 +115,8 @@ public sealed class Data
|
||||
public DataGrammarSpelling GrammarSpelling { get; init; } = new();
|
||||
|
||||
public DataRewriteImprove RewriteImprove { get; init; } = new();
|
||||
|
||||
public DataPromptOptimizer PromptOptimizer { get; init; } = new();
|
||||
|
||||
public DataEMail EMail { get; init; } = new();
|
||||
|
||||
@ -131,4 +133,4 @@ public sealed class Data
|
||||
public DataBiasOfTheDay BiasOfTheDay { get; init; } = new();
|
||||
|
||||
public DataI18N I18N { get; init; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataPromptOptimizer
|
||||
{
|
||||
/// <summary>
|
||||
/// Preselect prompt optimizer options?
|
||||
/// </summary>
|
||||
public bool PreselectOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Preselect the target language?
|
||||
/// </summary>
|
||||
public CommonLanguages PreselectedTargetLanguage { get; set; } = CommonLanguages.AS_IS;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect a custom target language when "Other" is selected?
|
||||
/// </summary>
|
||||
public string PreselectedOtherLanguage { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect important aspects for the optimization.
|
||||
/// </summary>
|
||||
public string PreselectedImportantAspects { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum confidence level required for a provider to be considered.
|
||||
/// </summary>
|
||||
public ConfidenceLevel MinimumProviderConfidence { get; set; } = ConfidenceLevel.NONE;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect a provider?
|
||||
/// </summary>
|
||||
public string PreselectedProvider { get; set; } = string.Empty;
|
||||
}
|
||||
@ -81,6 +81,7 @@ public static class ComponentsExtensions
|
||||
Components.GRAMMAR_SPELLING_ASSISTANT => settingsManager.ConfigurationData.GrammarSpelling.PreselectOptions ? settingsManager.ConfigurationData.GrammarSpelling.MinimumProviderConfidence : default,
|
||||
Components.ICON_FINDER_ASSISTANT => settingsManager.ConfigurationData.IconFinder.PreselectOptions ? settingsManager.ConfigurationData.IconFinder.MinimumProviderConfidence : default,
|
||||
Components.REWRITE_ASSISTANT => settingsManager.ConfigurationData.RewriteImprove.PreselectOptions ? settingsManager.ConfigurationData.RewriteImprove.MinimumProviderConfidence : default,
|
||||
Components.PROMPT_OPTIMIZER_ASSISTANT => settingsManager.ConfigurationData.PromptOptimizer.PreselectOptions ? settingsManager.ConfigurationData.PromptOptimizer.MinimumProviderConfidence : default,
|
||||
Components.TRANSLATION_ASSISTANT => settingsManager.ConfigurationData.Translation.PreselectOptions ? settingsManager.ConfigurationData.Translation.MinimumProviderConfidence : default,
|
||||
Components.AGENDA_ASSISTANT => settingsManager.ConfigurationData.Agenda.PreselectOptions ? settingsManager.ConfigurationData.Agenda.MinimumProviderConfidence : default,
|
||||
Components.CODING_ASSISTANT => settingsManager.ConfigurationData.Coding.PreselectOptions ? settingsManager.ConfigurationData.Coding.MinimumProviderConfidence : default,
|
||||
@ -109,6 +110,7 @@ public static class ComponentsExtensions
|
||||
Components.GRAMMAR_SPELLING_ASSISTANT => settingsManager.ConfigurationData.GrammarSpelling.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.GrammarSpelling.PreselectedProvider) : null,
|
||||
Components.ICON_FINDER_ASSISTANT => settingsManager.ConfigurationData.IconFinder.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.IconFinder.PreselectedProvider) : null,
|
||||
Components.REWRITE_ASSISTANT => settingsManager.ConfigurationData.RewriteImprove.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.RewriteImprove.PreselectedProvider) : null,
|
||||
Components.PROMPT_OPTIMIZER_ASSISTANT => settingsManager.ConfigurationData.PromptOptimizer.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.PromptOptimizer.PreselectedProvider) : null,
|
||||
Components.TRANSLATION_ASSISTANT => settingsManager.ConfigurationData.Translation.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.Translation.PreselectedProvider) : null,
|
||||
Components.AGENDA_ASSISTANT => settingsManager.ConfigurationData.Agenda.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.Agenda.PreselectedProvider) : null,
|
||||
Components.CODING_ASSISTANT => settingsManager.ConfigurationData.Coding.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.Coding.PreselectedProvider) : null,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user