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,34 +122,38 @@ 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
};
}
return new ChatThread
{ {
SystemPrompt = SystemPrompts.DEFAULT, SystemPrompt = SystemPrompts.DEFAULT,
Blocks = Blocks =
[ [
new ContentBlock() // 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, Role = ChatRole.USER,
HideFromUser = false, HideFromUser = false,
ContentType = ContentType.TEXT, ContentType = ContentType.TEXT,
Content = new ContentText() Content = new ContentText
{ {
Text = this.T("The result of your previous document analysis session."),
FileAttachments = this.loadedDocumentPaths.ToList(), 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(), this.chatThread.Blocks.Last(),
] ]
}; };
return convertThread;
}
return new ChatThread
{
SystemPrompt = SystemPrompts.DEFAULT
Text = this.T("The result of your previous document analysis session."),
};
} }
} }