时间

所属版本时间2026年03月08日

原因

通过Jinja控制思考模式关闭,模型输出普通文本,但llama.cpp仍然认为思考模式是启用的,故其解析器期望得到</think>,当格式不匹配时,解析失败并抛出 std::runtime_error 异常。

临时修改摘要

文件: common/chat.cpp:1549-1557

修改: 当 common_chat_peg_parse 函数中 is_partial=false 且解析失败时,将输入作为普通文本返回,而非抛出异常。

CPP
if (!is_partial) {
	LOG_WRN("Parser failed at pos %zu, treating input as plain content\n", result.end);
	common_chat_msg msg;
	msg.role = "assistant";
	msg.content = input;
	return msg;
}
点击展开查看更多

版权声明

作者: Cheyne Xie

链接: https://chaim.eu.org/posts/f47269f8/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键