Use local deep clone of example conversation

This commit is contained in:
Thorsten Sommer 2025-05-24 18:32:42 +02:00
parent 7e61d93468
commit ec6f66510c
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -58,6 +58,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
private List<string> UsedNames { get; set; } = []; private List<string> UsedNames { get; set; } = [];
private bool dataIsValid; private bool dataIsValid;
private List<ContentBlock> dataExampleConversation = [];
private string[] dataIssues = []; private string[] dataIssues = [];
private string dataEditingPreviousName = string.Empty; private string dataEditingPreviousName = string.Empty;
private bool isInlineEditOnGoing; private bool isInlineEditOnGoing;
@ -106,13 +107,13 @@ public partial class ChatTemplateDialog : MSGComponentBase
Name = this.DataName, Name = this.DataName,
SystemPrompt = this.DataSystemPrompt, SystemPrompt = this.DataSystemPrompt,
ExampleConversation = this.ExampleConversation, ExampleConversation = this.dataExampleConversation,
AllowProfileUsage = this.AllowProfileUsage, AllowProfileUsage = this.AllowProfileUsage,
}; };
private void RemoveMessage(ContentBlock item) private void RemoveMessage(ContentBlock item)
{ {
this.ExampleConversation.Remove(item); this.dataExampleConversation.Remove(item);
} }
private void AddNewMessageToEnd() private void AddNewMessageToEnd()
@ -128,7 +129,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
Time = DateTimeOffset.Now, Time = DateTimeOffset.Now,
}; };
this.ExampleConversation.Add(newEntry); this.dataExampleConversation.Add(newEntry);
} }
private void AddNewMessageBelow(ContentBlock currentItem) private void AddNewMessageBelow(ContentBlock currentItem)
@ -144,17 +145,12 @@ public partial class ChatTemplateDialog : MSGComponentBase
Time = DateTimeOffset.Now, Time = DateTimeOffset.Now,
}; };
// Rest of the method remains the same // The rest of the method remains the same:
var index = this.ExampleConversation.IndexOf(currentItem); var index = this.dataExampleConversation.IndexOf(currentItem);
if (index >= 0) if (index >= 0)
{ this.dataExampleConversation.Insert(index + 1, insertedEntry);
this.ExampleConversation.Insert(index + 1, newEntry);
}
else else
{ this.dataExampleConversation.Add(insertedEntry);
this.ExampleConversation.Add(newEntry);
}
} }
private void BackupItem(object? element) private void BackupItem(object? element)