diff --git a/src/plugins/ai/backend.rs b/src/plugins/ai/backend.rs index fc5c11b..8371d77 100644 --- a/src/plugins/ai/backend.rs +++ b/src/plugins/ai/backend.rs @@ -154,16 +154,12 @@ impl AiBackend for LocalCliBackend { // --single-turn 单轮模式,生成完即退出(否则进交互模式等待 stdin,永远不退出) // --no-warmup 跳过预热(减少延迟) // -sys system prompt(角色人设) - // -p 用户输入(只传当前消息,历史通过 context 另传,V1 简化) + // -p 用户当前消息(V1 不带历史,避免模型回显历史内容) // - // 历史上下文 V1 简化处理:拼到 -p 里(小模型 ctx 1024 有限,只保留最近 2 轮) - let mut prompt = String::new(); - for (role, content) in history.iter().rev().take(4) { - // 逆序取最近 2 轮(4 条消息),正序拼接 - prompt.insert_str(0, &format!("{content}\n")); - } - prompt.push_str(user_message); - + // V1 边界:会话内上下文由 ChatPipeline 的 sessions 维护, + // 但 llama-cli --single-turn 模式每次是独立调用, + // 历史拼接会导致模型把历史当输入回显。V1 简化为无历史单轮对话。 + let _ = history; // V1 不使用历史,参数保留供未来扩展 let tokens = if max_tokens == 0 { 128 } else { max_tokens as u32 }; let output = Command::new(self.llama_cli()) @@ -174,7 +170,7 @@ impl AiBackend for LocalCliBackend { .arg("-sys") .arg(persona) .arg("-p") - .arg(&prompt) + .arg(user_message) .arg("-n") .arg(tokens.to_string()) .arg("-t") diff --git a/src/plugins/http/chat.html b/src/plugins/http/chat.html new file mode 100644 index 0000000..917cd4e --- /dev/null +++ b/src/plugins/http/chat.html @@ -0,0 +1,284 @@ + + +
+ + +