mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 18:32:12 +00:00
Add settings prompt drop zones
This commit is contained in:
parent
3b670706e9
commit
75aeb784d2
@ -6541,6 +6541,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T34
|
||||
-- The current content of this Markdown file is loaded whenever the defaults are applied.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T3468539567"] = "The current content of this Markdown file is loaded whenever the defaults are applied."
|
||||
|
||||
-- Load default prompt from file
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T3763644960"] = "Load default prompt from file"
|
||||
|
||||
-- Default results table name
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T3816237687"] = "Default results table name"
|
||||
|
||||
@ -6562,6 +6565,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T48
|
||||
-- Default output mode
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T601648878"] = "Default output mode"
|
||||
|
||||
-- Load default Markdown instructions file
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T626322240"] = "Load default Markdown instructions file"
|
||||
|
||||
-- Default source of the instructions
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGBATCHPROCESSING::T704081768"] = "Default source of the instructions"
|
||||
|
||||
|
||||
@ -27,6 +27,12 @@ public partial class ReadFileContent : MSGComponentBase
|
||||
[Parameter]
|
||||
public EventCallback<string> FileContentChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reports the path after a file was loaded successfully.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<string> FilePathLoaded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the component will display the state of the attached document (if any).
|
||||
/// </summary>
|
||||
@ -359,6 +365,7 @@ public partial class ReadFileContent : MSGComponentBase
|
||||
private async Task ApplyFileContentAsync(string fileContent, string filePath)
|
||||
{
|
||||
await this.FileContentChanged.InvokeAsync(fileContent);
|
||||
await this.FilePathLoaded.InvokeAsync(filePath);
|
||||
this.loadedFileName = Path.GetFileName(filePath);
|
||||
this.hasLoadedFileContent = true;
|
||||
}
|
||||
|
||||
@ -23,10 +23,12 @@
|
||||
<ConfigurationSelect OptionDescription="@T("Default source of the instructions")" Disabled="@this.DefaultsDisabled" SelectedValue="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.PromptSource)" Data="@this.PromptSourceData" SelectionUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.PromptSource = value)" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.PromptSource, out var meta) && meta.IsLocked"/>
|
||||
@if (this.SettingsManager.ConfigurationData.BatchProcessing.PromptSource is BatchProcessingPromptSource.FREE_PROMPT)
|
||||
{
|
||||
<ReadFileContent Text="@T("Load default prompt from file")" FileContent="@this.SettingsManager.ConfigurationData.BatchProcessing.FreePrompt" FileContentChanged="@this.UpdateFreePromptFromFileAsync" EnableDragDrop="true" Layer="@DropLayers.DIALOGS" CatchAllDocuments="true" Disabled="@this.FreePromptImportDisabled()"/>
|
||||
<ConfigurationText OptionDescription="@T("Default prompt")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.EditNote" NumLines="5" MaxLines="26" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.FreePrompt)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.FreePrompt = value)" OptionHelp="@T("These instructions are applied to every document of a new batch run.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.FreePrompt, out var meta) && meta.IsLocked"/>
|
||||
}
|
||||
else if (this.SettingsManager.ConfigurationData.BatchProcessing.PromptSource is BatchProcessingPromptSource.FILE_IMPORT)
|
||||
{
|
||||
<ReadFileContent Text="@T("Load default Markdown instructions file")" Filter="@([FileTypes.MARKDOWN])" FilePathLoaded="@this.UpdatePromptFilePathAsync" EnableDragDrop="true" Layer="@DropLayers.DIALOGS" CatchAllDocuments="true" Disabled="@this.PromptFileImportDisabled()"/>
|
||||
<ConfigurationFile OptionDescription="@T("Default Markdown instructions file")" Disabled="@this.DefaultsDisabled" Icon="@Icons.Material.Filled.Description" Text="@(() => this.SettingsManager.ConfigurationData.BatchProcessing.PromptFilePath)" TextUpdate="@(value => this.SettingsManager.ConfigurationData.BatchProcessing.PromptFilePath = value)" FileDialogTitle="@T("Select the default Markdown instructions file")" Filter="@([FileTypes.MARKDOWN])" OptionHelp="@T("The current content of this Markdown file is loaded whenever the defaults are applied.")" IsLocked="() => ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.PromptFilePath, out var meta) && meta.IsLocked"/>
|
||||
}
|
||||
else
|
||||
|
||||
@ -7,6 +7,30 @@ public partial class SettingsDialogBatchProcessing : SettingsDialogBase
|
||||
{
|
||||
private bool DefaultsDisabled() => !this.SettingsManager.ConfigurationData.BatchProcessing.PreselectOptions;
|
||||
|
||||
private bool FreePromptImportDisabled() => this.DefaultsDisabled()
|
||||
|| ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.FreePrompt, out var meta) && meta.IsLocked;
|
||||
|
||||
private bool PromptFileImportDisabled() => this.DefaultsDisabled()
|
||||
|| ManagedConfiguration.TryGet(x => x.BatchProcessing, x => x.PromptFilePath, out var meta) && meta.IsLocked;
|
||||
|
||||
private async Task UpdateFreePromptFromFileAsync(string content)
|
||||
{
|
||||
this.SettingsManager.ConfigurationData.BatchProcessing.FreePrompt = content;
|
||||
await this.StoreImportedDefaultAsync();
|
||||
}
|
||||
|
||||
private async Task UpdatePromptFilePathAsync(string path)
|
||||
{
|
||||
this.SettingsManager.ConfigurationData.BatchProcessing.PromptFilePath = path;
|
||||
await this.StoreImportedDefaultAsync();
|
||||
}
|
||||
|
||||
private async Task StoreImportedDefaultAsync()
|
||||
{
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
|
||||
private IReadOnlyList<ConfigurationSelectData<BatchProcessingPromptSource>> PromptSourceData =>
|
||||
[
|
||||
.. Enum
|
||||
|
||||
Loading…
Reference in New Issue
Block a user