feat: 自动重命名会话

This commit is contained in:
肖应宇 2026-03-12 11:11:41 +08:00
parent fb7f72fcb9
commit 2417a769bb
2 changed files with 15 additions and 4 deletions

View File

@ -181,6 +181,7 @@ async function handleSend(
deepThinking?: boolean;
systemPrompt?: string;
skipUserMessage?: boolean;
conversationTitle?: string;
},
) {
//
@ -221,7 +222,13 @@ async function handleSend(
//
if (!currentConversation.value) {
await chatStore.createConversation();
await chatStore.createConversation(options?.conversationTitle || text);
} else if (currentConversation.value.title === "新对话") {
// ""
chatStore.renameConversation(
currentConversation.value.id,
options?.conversationTitle || text
);
}
// 使使
@ -488,7 +495,11 @@ function handleRegenerate(messageId: string) {
}
function handleSuggestion(suggestion: Suggestion) {
handleSend(suggestion.text, [], { systemPrompt: suggestion.systemPrompt, skipUserMessage: true });
handleSend(suggestion.text, [], {
systemPrompt: suggestion.systemPrompt,
skipUserMessage: true,
conversationTitle: suggestion.text,
});
}
function focusInput() {

View File

@ -79,10 +79,10 @@ export const useChatStore = defineStore("chat", () => {
}
// 创建对话
async function createConversation(): Promise<string> {
async function createConversation(title?: string): Promise<string> {
const newConversation: Conversation = {
id: generateId(),
title: "新对话",
title: title || "新对话",
messages: [],
createdAt: Date.now(),
updatedAt: Date.now(),