mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
clean chat history before /resume (#949)
This commit is contained in:
@@ -561,12 +561,21 @@ Add any other context about the problem here.
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const chat = await config?.getGeminiClient()?.getChat();
|
const chat = await config?.getGeminiClient()?.getChat();
|
||||||
|
if (!chat) {
|
||||||
|
addMessage({
|
||||||
|
type: MessageType.ERROR,
|
||||||
|
content: 'No chat client available to resume conversation.',
|
||||||
|
timestamp: new Date(),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
clearItems();
|
clearItems();
|
||||||
let i = 0;
|
chat.clearHistory();
|
||||||
const rolemap: { [key: string]: MessageType } = {
|
const rolemap: { [key: string]: MessageType } = {
|
||||||
user: MessageType.USER,
|
user: MessageType.USER,
|
||||||
model: MessageType.GEMINI,
|
model: MessageType.GEMINI,
|
||||||
};
|
};
|
||||||
|
let i = 0;
|
||||||
for (const item of conversation) {
|
for (const item of conversation) {
|
||||||
i += 1;
|
i += 1;
|
||||||
const text =
|
const text =
|
||||||
@@ -589,7 +598,7 @@ Add any other context about the problem here.
|
|||||||
} as HistoryItemWithoutId,
|
} as HistoryItemWithoutId,
|
||||||
i,
|
i,
|
||||||
);
|
);
|
||||||
chat?.addHistory(item);
|
chat.addHistory(item);
|
||||||
}
|
}
|
||||||
console.clear();
|
console.clear();
|
||||||
refreshStatic();
|
refreshStatic();
|
||||||
|
|||||||
@@ -289,6 +289,13 @@ export class GeminiChat {
|
|||||||
return structuredClone(history);
|
return structuredClone(history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the chat history.
|
||||||
|
*/
|
||||||
|
clearHistory(): void {
|
||||||
|
this.history = [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new entry to the chat history.
|
* Adds a new entry to the chat history.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user