Refactor CreateFromExistingChatThread condition and enhance DeepClone with optional hide state adjustment

This commit is contained in:
Thorsten Sommer 2025-07-10 20:50:19 +02:00
parent 08ddc3dcec
commit 99a7989540
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -97,17 +97,11 @@ public partial class ChatTemplateDialog : MSGComponentBase
this.dataExampleConversation = this.ExampleConversation.Select(n => n.DeepClone()).ToList();
}
if (this.CreateFromExistingChatThread)
if (this.CreateFromExistingChatThread && this.ExistingChatThread is not null)
{
this.DataSystemPrompt = this.ExistingChatThread!.SystemPrompt;
this.dataExampleConversation = this.ExistingChatThread!.Blocks.Select(n => n.DeepClone()).ToList();
this.DataName = this.ExistingChatThread!.Name;
// the contentblocks that we copy are visible to the user, and we don't want to show them while using the template
foreach (var item in this.dataExampleConversation)
{
item.HideFromUser = true;
}
this.DataSystemPrompt = this.ExistingChatThread.SystemPrompt;
this.dataExampleConversation = this.ExistingChatThread.Blocks.Select(n => n.DeepClone(true)).ToList();
this.DataName = this.ExistingChatThread.Name;
}
await base.OnInitializedAsync();