fix: 修复参考文献收集失败、编号错乱与标题/条目格式问题 - #113
Open
hailuohl wants to merge 1 commit into
Open
Conversation
- replace_references_with_uuid 正则冒号改为可选:writer 提示词规定的
引用格式 {[^1] 引用} 不带冒号,原正则却要求 {[^1]: 引用},两者从未
对齐导致引用永远收集失败,参考文献节只剩空标题
- sort_text_with_footnotes 修复重复引用编号:同一文献跨章节出现时
原实现每次递增 ref_index,正文出现 [2] 而列表只有 [1];现复用首个编号
- 正文引用标记由 [^n] 改为 [n]:[^n] 是 markdown 脚注引用语法,
不支持的渲染器直接丢字面量,文献内容会被渲染成页脚脚注而非参考文献
- 参考文献标题去掉行首空格:' ## 参考文献' 在严格渲染器(pandoc 等)
中不识别为标题、输出字面文本;条目由 [^n]: 脚注定义改为 [n] 普通
文本,避免不支持脚注的渲染器整节丢弃
- writer 提示词引用格式明确带冒号并给出完整示例
新增 app/tests/test_user_output.py 覆盖上述场景。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
UserOutput的参考文献链路存在四个问题,导致生成的res.md参考文献一节为空或格式损坏:{[^1] 完整引用信息}(无冒号),而replace_references_with_uuid的正则要求{[^1]: 引用信息}(带冒号),两者从未对齐。模型按提示词输出时正则匹配不到,引用原样残留在正文里,参考文献节只剩空标题。sort_text_with_footnotes每次都递增ref_index,正文出现[2]但参考文献列表只有[1]。[^n]:不支持脚注的 markdown 渲染器直接丢字面量;支持脚注的渲染器把文献内容渲染成页脚脚注,而不是集中的参考文献节。" ## 参考文献"在严格渲染器(如 pandoc)中不识别为标题,输出字面## 参考文献文本。修复
replace_references_with_uuid正则冒号改为可选,兼容{[^1]: …}与{[^1] …}两种写法[^n]改为普通[n]文本;文末条目由[^n]: 脚注定义改为[n] 文本效果对比
同一输入(两处引用同一篇文献,一处带冒号一处不带)走
get_result_to_save():测试
新增
app/tests/test_user_output.py(上游此前无该模块测试),覆盖上述四个场景——在main上 4 例全部失败,本分支全部通过。验证:
uv run python -m unittest app.tests.test_user_output