Assistant send result (#75)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2024-08-18 12:32:18 +02:00
1 parent ea0ead58f8
commit 909fbe89bb
36 files changed
+400 -63

No files matched your search

@@ -1,5 +1,5 @@
@using AIStudio.Tools
@page "/assistant/grammar-spelling"
@attribute [Route(Path.ASSISTANT_GRAMMAR_SPELLING)]
@inherits AssistantBaseCore
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to check" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -25,11 +25,17 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
protected override bool ShowDedicatedProgress => true;
protected override IReadOnlyList<ButtonData> FooterButtons => new[]
{
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.correctedText)),
};
new SendToButton
{
Self = SendToAssistant.GRAMMAR_SPELLING_ASSISTANT,
UseResultingContentBlockData = false,
GetData = () => string.IsNullOrWhiteSpace(this.correctedText) ? this.inputText : this.correctedText
},
];
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
@@ -41,6 +47,10 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedProvider);
}
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT).FirstOrDefault();
if (deferredContent is not null)
this.inputText = deferredContent;
await base.OnInitializedAsync();
}