|
|
|
|
@ -300,22 +300,24 @@ export class Conversation {
|
|
|
|
|
*/
|
|
|
|
|
public async appendMessages(app: App, messages: any[], options: {
|
|
|
|
|
dialogueCount?: number,
|
|
|
|
|
replaceCurrentDialogue?: boolean
|
|
|
|
|
workflowRunId?: string | null,
|
|
|
|
|
} = {}): Promise<void> {
|
|
|
|
|
// 确保当前页存在
|
|
|
|
|
await this.ensureCurrentPage(app);
|
|
|
|
|
|
|
|
|
|
let conversationDialogue: ConversationDialogue | null = null;
|
|
|
|
|
if (typeof options.dialogueCount === "number") {
|
|
|
|
|
if (options.replaceCurrentDialogue) {
|
|
|
|
|
// 删除当前对话在内的后续对话
|
|
|
|
|
await this.removeDialogueAfter(app, options.dialogueCount);
|
|
|
|
|
} else {
|
|
|
|
|
// 删除后续对话
|
|
|
|
|
await this.removeDialogueAfter(app, options.dialogueCount + 1);
|
|
|
|
|
}
|
|
|
|
|
// 获取指定对话轮数的对话块
|
|
|
|
|
conversationDialogue = await this.getDialogueAt(app, options.dialogueCount);
|
|
|
|
|
|
|
|
|
|
if (conversationDialogue && conversationDialogue.workflowRunId === options.workflowRunId) {
|
|
|
|
|
// 如果对话块存在且工作流运行 ID 相同,则仅删除后续对话
|
|
|
|
|
await this.removeDialogueAfter(app, options.dialogueCount + 1);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果对话块不存在或工作流运行 ID 不同,则删除当前对话在内的后续对话
|
|
|
|
|
conversationDialogue = null;
|
|
|
|
|
await this.removeDialogueAfter(app, options.dialogueCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!conversationDialogue) {
|
|
|
|
|
|