diff --git a/src/components/chat/ChatMain.vue b/src/components/chat/ChatMain.vue index eaa8baf..a8d0248 100644 --- a/src/components/chat/ChatMain.vue +++ b/src/components/chat/ChatMain.vue @@ -180,6 +180,7 @@ async function handleSend( webSearch?: boolean; deepThinking?: boolean; systemPrompt?: string; + skipUserMessage?: boolean; }, ) { // 检查认证状态 @@ -245,13 +246,15 @@ async function handleSend( .slice(-(MAX_HISTORY_ROUNDS * 2)) .map((m: any) => ({ role: m.role, content: m.content.text })); - // 添加用户消息 - await chatStore.addMessage(MessageRole.USER, { - type: MessageType.TEXT, - text, - images: attachments.filter((a) => a.type === "image"), - files: attachments.filter((a) => a.type === "file"), - }); + // 添加用户消息(如果不需要跳过) + if (!options?.skipUserMessage) { + await chatStore.addMessage(MessageRole.USER, { + type: MessageType.TEXT, + text, + images: attachments.filter((a) => a.type === "image"), + files: attachments.filter((a) => a.type === "file"), + }); + } // 添加 AI 消息占位符 const aiMessage = await chatStore.addMessage(MessageRole.ASSISTANT, { @@ -279,7 +282,7 @@ async function handleSend( const stream = chatApi.streamChat( { - message: text, + message: options?.skipUserMessage ? "直接输出系统提示词要求你的回答" : text, conversationId: currentConversation.value?.id || "", images: imageUrls, files: fileUrls, @@ -485,7 +488,7 @@ function handleRegenerate(messageId: string) { } function handleSuggestion(suggestion: Suggestion) { - handleSend(suggestion.text, [], { systemPrompt: suggestion.systemPrompt }); + handleSend(suggestion.text, [], { systemPrompt: suggestion.systemPrompt, skipUserMessage: true }); } function focusInput() {