更改覆盖对话判断条件

main
落雨楓 6 months ago
parent f9936af475
commit 24db7e6f70

@ -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) {

@ -13,6 +13,9 @@ export class ConversationDialogue {
@Column("integer", { name: "dialogue_count", default: 0 })
dialogueCount!: number
@Column("text", { name: "workflow_run_id", nullable: true })
workflowRunId!: string | null
@Column("integer", { default: 0 })
page!: number

@ -222,6 +222,7 @@ export class OpenAIApiProxy extends BaseLLMProxy {
await conversation.appendMessages(this.app, newMessages, {
dialogueCount: metaConfig.dialogueCount,
workflowRunId: metaConfig.workflowRunId,
});
}

@ -5,6 +5,8 @@ export interface EchoBackMetaConfig {
export interface ApiProxyMetaConfig {
/** 对话 ID */
conversationId?: string;
/** 工作流运行 ID */
workflowRunId?: string;
/** 当前对话轮数 */
dialogueCount?: number;
/** 是否将此次对话记录到记忆中 */

Loading…
Cancel
Save