Changed SendToButton to support sending to chat as input

This commit is contained in:
Peer Schütt 2026-04-10 16:28:53 +02:00
parent 1f071211f3
commit 5f686bf1c1
6 changed files with 18 additions and 4 deletions

View File

@ -372,9 +372,14 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
switch (destination)
{
case Tools.Components.CHAT:
var convertedChatThread = this.ConvertToChatThread;
convertedChatThread = convertedChatThread with { SelectedProvider = this.providerSettings.Id };
MessageBus.INSTANCE.DeferMessage(this, sendToData.Event, convertedChatThread);
if (sendToButton.SendToChatAsInput)
MessageBus.INSTANCE.DeferMessage(this, Event.SEND_TO_CHAT_INPUT, contentToSend);
else
{
var convertedChatThread = this.ConvertToChatThread;
convertedChatThread = convertedChatThread with { SelectedProvider = this.providerSettings.Id };
MessageBus.INSTANCE.DeferMessage(this, sendToData.Event, convertedChatThread);
}
break;
default:

View File

@ -100,6 +100,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
{
Self = Tools.Components.PROMPT_OPTIMIZER_ASSISTANT,
UseResultingContentBlockData = false,
SendToChatAsInput = true,
GetText = () => string.IsNullOrWhiteSpace(this.optimizedPrompt) ? this.inputPrompt : this.optimizedPrompt,
},
];

View File

@ -92,6 +92,10 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
this.currentChatTemplate = this.SettingsManager.GetPreselectedChatTemplate(Tools.Components.CHAT);
this.userInput = this.currentChatTemplate.PredefinedUserPrompt;
var deferredInput = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CHAT_INPUT).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(deferredInput))
this.userInput = deferredInput;
// Apply template's file attachments, if any:
foreach (var attachment in this.currentChatTemplate.FileAttachments)
this.chatDocumentPaths.Add(attachment);

View File

@ -44,6 +44,7 @@
<EmbeddedResource Include="wwwroot\**" CopyToOutputDirectory="PreserveNewest" />
<EmbeddedResource Include="Plugins\**" CopyToOutputDirectory="PreserveNewest" />
<EmbeddedResource Include="Assistants\I18N\allTexts.lua" CopyToOutputDirectory="PreserveNewest" />
<EmbeddedResource Include="Assistants\PromptOptimizer\prompting_guideline.md" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>

View File

@ -51,6 +51,7 @@ public enum Event
SEND_TO_CODING_ASSISTANT,
SEND_TO_TEXT_SUMMARIZER_ASSISTANT,
SEND_TO_CHAT,
SEND_TO_CHAT_INPUT,
SEND_TO_EMAIL_ASSISTANT,
SEND_TO_LEGAL_CHECK_ASSISTANT,
SEND_TO_SYNONYMS_ASSISTANT,

View File

@ -7,7 +7,9 @@ public readonly record struct SendToButton() : IButtonData
public Func<string> GetText { get; init; } = () => string.Empty;
public bool UseResultingContentBlockData { get; init; } = true;
public bool SendToChatAsInput { get; init; }
public Components Self { get; init; } = Components.NONE;
}
}