Refactored

This commit is contained in:
Thorsten Sommer 2026-01-18 19:06:27 +01:00
parent d78d800ea0
commit 41aff4b9db
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -122,33 +122,37 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
{ {
get get
{ {
if (this.chatThread is not null) if (this.chatThread is null)
{ {
var convertThread = new ChatThread(); return new ChatThread
convertThread = convertThread with
{ {
SystemPrompt = SystemPrompts.DEFAULT, SystemPrompt = SystemPrompts.DEFAULT
Blocks =
[
new ContentBlock()
{
Role = ChatRole.USER,
HideFromUser = false,
ContentType = ContentType.TEXT,
Content = new ContentText()
{
FileAttachments = this.loadedDocumentPaths.ToList(),
}
},
this.chatThread.Blocks.Last(),
]
}; };
return convertThread;
} }
return new ChatThread return new ChatThread
{ {
SystemPrompt = SystemPrompts.DEFAULT SystemPrompt = SystemPrompts.DEFAULT,
Blocks =
[
// Replace the first "user block" (here, it was/is the block generated by the assistant) with a new one
// that includes the loaded document paths and a standard message about the previous analysis session:
new ContentBlock
{
Role = ChatRole.USER,
HideFromUser = false,
ContentType = ContentType.TEXT,
Content = new ContentText
{
Text = this.T("The result of your previous document analysis session."), Text = this.T("The result of your previous document analysis session."),
FileAttachments = this.loadedDocumentPaths.ToList(),
}
},
// Then, append the last block of the current chat thread
// (which is expected to be the AI response):
this.chatThread.Blocks.Last(),
]
}; };
} }
} }