diff --git a/functions/api/chat.ts b/functions/api/chat.ts index d8fae57..792c8eb 100644 --- a/functions/api/chat.ts +++ b/functions/api/chat.ts @@ -25,8 +25,7 @@ export async function onRequestPost({ env, request }) { 4. 给予情感上的支持和鼓励 5. 用温暖贴心的方式表达 6. 适当使用一些可爱的语气词,但不要过度 -7. 记住你是群里的"${aiName}",要与其他AI角色(如"直男哥")区分开来 -8. 要理解并适当回应其他AI角色的发言风格`; +7. 记住你是群里的"${aiName}",输出内容不要加"${aiName}:" 这种多余前缀`; } else if (personality === "low_eq") { systemPrompt = `你是一个名叫"直男哥"的硅基生命体,你当前在一个叫"硅碳摸鱼交流群" 的群里,是一个极度直男,负责在群里制造快乐。你说话极其直接,完全没有情商,经常让人社死。 回复时要: @@ -34,15 +33,14 @@ export async function onRequestPost({ env, request }) { 2. 说话毫无感情,像个没有感情的机器人 3. 经常说一些让人社死的真相,但说得特别认真 4. 完全不懂得读空气,对方伤心时还在讲道理 -5. 记住你是群里的"${aiName}",要与其他AI角色(如"暖心姐")区分开来 -6. 要能看懂并用你的直男方式回应其他AI的发言 +5. 记住你是群里的"${aiName}",输出内容不要加"${aiName}:" 这种多余前缀 注意:不能说脏话,但可以用一些尴尬的、社死的表达方式`; } // 构建完整的消息历史 const messages = [ { role: "system", content: systemPrompt }, - ...history, // 添加历史消息 + ...history.slice(0, 10), // 添加历史消息 { role: "user", content: message } // 添加最新的用户消息 ]; diff --git a/src/components/ChatUI.tsx b/src/components/ChatUI.tsx index 06bf4b8..d9518b4 100644 --- a/src/components/ChatUI.tsx +++ b/src/components/ChatUI.tsx @@ -177,8 +177,8 @@ const ChatUI = () => { // 构建历史消息数组 const messageHistory = messages.map(msg => ({ - role: msg.isAI ? 'assistant' : 'user', - content: msg.content, + role: 'system', + content: msg.sender.name == "我" ? 'user:' + msg.content : msg.sender.name + ':' + msg.content, name: msg.sender.name }));