Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/MindWork AI Studio/Assistants/AssistantBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<MudText Typo="Typo.h3">
@this.Title
</MudText>

<MudSpacer/>

@if (this.HeaderActions is not null)
{
@this.HeaderActions
}

@if (this.HasSettingsPanel)
{
Expand All @@ -31,7 +38,7 @@
</CascadingValue>

<MudStack Row="true" AlignItems="AlignItems.Center" StretchItems="StretchItems.Start" Class="mb-3">
<MudButton Disabled="@this.SubmitDisabled" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle">
<MudButton Disabled="@(this.SubmitDisabled || this.isProcessing)" Variant="Variant.Filled" OnClick="@(async () => await this.Start())" Style="@this.SubmitButtonStyle">
@this.SubmitText
</MudButton>
@if (this.isProcessing && this.cancellationTokenSource is not null)
Expand Down Expand Up @@ -71,6 +78,11 @@
}
}
}

@if (this.ShowResult && this.AfterResultContent is not null)
{
@this.AfterResultContent
}

<div id="@AFTER_RESULT_DIV_ID" class="mt-3">
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/MindWork AI Studio/Assistants/AssistantBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher

protected virtual ChatThread ConvertToChatThread => this.chatThread ?? new();

private protected virtual RenderFragment? HeaderActions => null;

private protected virtual RenderFragment? AfterResultContent => null;

protected virtual IReadOnlyList<IButtonData> FooterButtons => [];

protected virtual bool HasSettingsPanel => typeof(TSettings) != typeof(NoSettingsPanel);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
@attribute [Route(Routes.ASSISTANT_PROMPT_OPTIMIZER)]
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogPromptOptimizer>

<MudTextField T="string"
@bind-Text="@this.inputPrompt"
Validation="@this.ValidateInputPrompt"
AdornmentIcon="@Icons.Material.Filled.AutoFixHigh"
Adornment="Adornment.Start"
Label="@T("Prompt or prompt description")"
Variant="Variant.Outlined"
Lines="8"
AutoGrow="@true"
MaxLines="20"
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>
</MudStack>

@if (this.ShowUpdatedPromptGuidelinesIndicator)
{
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Outlined" Class="mb-3">
<MudStack Row="true" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap">
<MudText Typo="Typo.body2">@T("Prompt recommendations were updated based on your latest optimization.")</MudText>
</MudStack>
</MudAlert>
}

@if (!this.useCustomPromptGuide)
{
<MudJustifiedText Class="mb-3">@T("Use these recommendations, that are based on the default 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="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="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="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="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="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="2" AutoGrow="@true" />
</MudItem>
</MudGrid>
}

@if (this.useCustomPromptGuide)
{
<MudJustifiedText Class="mb-3">@T("Use the prompt recommendations from the custom prompt guide that was provided by the user.")</MudJustifiedText>
}

<MudStack Row="true" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap" StretchItems="StretchItems.None" Class="mb-3">
<MudButton Variant="Variant.Outlined"
StartIcon="@Icons.Material.Filled.MenuBook"
OnClick="@(async () => await this.OpenPromptingGuidelineDialog())">
@T("View default prompt guide")
</MudButton>

<MudSwitch T="bool" Value="@this.useCustomPromptGuide" ValueChanged="@this.SetUseCustomPromptGuide" Color="Color.Primary" Class="mx-1">
@T("Use custom prompt guide")
</MudSwitch>

@if (this.useCustomPromptGuide)
{
<AttachDocuments Name="Custom Prompt Guide"
Layer="@DropLayers.ASSISTANTS"
@bind-DocumentPaths="@this.customPromptGuideFiles"
OnChange="@this.OnCustomPromptGuideFilesChanged"
CatchAllDocuments="false"
UseSmallForm="true"
ValidateMediaFileTypes="false"
Provider="@this.providerSettings"/>
}

<MudTextField T="string"
Text="@this.CustomPromptGuideFileName"
Label="@T("Custom prompt guide file")"
ReadOnly="true"
Disabled="@(!this.useCustomPromptGuide)"
Variant="Variant.Outlined"
Class="mx-2"
Style="min-width: 18rem;"/>

<MudButton Variant="Variant.Outlined"
StartIcon="@Icons.Material.Filled.Visibility"
Disabled="@(!this.CanPreviewCustomPromptGuide)"
OnClick="@(async () => await this.OpenCustomPromptGuideDialog())">
@T("View")
</MudButton>
</MudStack>

<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
Loading