fix(suggestions): 兼容 LLM 输出中字段/对象间的全角逗号 - #401
Draft
longsizhuo wants to merge 1 commit into
Draft
longsizhuo wants to merge 1 commit into
longsizhuo wants to merge 1 commit into
Conversation
GLM 生成的建议 JSON 偶尔用 `”,“` 分隔字段,替换中文引号后仍残留全角逗号, JSON.parse 与逐对象兜底都失败,欢迎页建议为空。解析逻辑抽到 lib/ai/parse-suggestions.ts 并补单测(含线上原始文本)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A7it9BgUVs3SDYtb28PpC7
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
问题
Vercel 运行时日志里
/api/suggestions持续出现「解析建议 JSON 失败」(#399 部署后 10/02 仍复现)。GLM 返回的建议用”,“分隔字段:中文引号被替换后仍残留全角逗号
,,JSON.parse和逐对象兜底都失败,欢迎页建议直接为空。修改
app/api/suggestions/route.ts抽到lib/ai/parse-suggestions.ts(行为不变),新增两条归一化:","→","、},{→},{。值内部的全角逗号不受影响。tests/parse-suggestions.test.ts:用线上原始文本做用例;去掉新增归一化后该用例失败,加上后全部 96 个测试通过。eslint / prettier / tsc 均通过。🤖 Generated with Claude Code
https://claude.ai/code/session_01A7it9BgUVs3SDYtb28PpC7
Generated by Claude Code