Skip to content

fix(suggestions): 兼容 LLM 输出中字段/对象间的全角逗号 - #401

Draft
longsizhuo wants to merge 1 commit into
mainfrom
vibe/wizardly-archimedes-hsqd7z
Draft

longsizhuo wants to merge 1 commit into
mainfrom
vibe/wizardly-archimedes-hsqd7z

Conversation

@longsizhuo

Copy link
Copy Markdown
Member

问题

Vercel 运行时日志里 /api/suggestions 持续出现「解析建议 JSON 失败」(#399 部署后 10/02 仍复现)。GLM 返回的建议用 ”,“ 分隔字段:

{"title":"基础概念”,“label":"基础知识”,“action":"..."}

中文引号被替换后仍残留全角逗号 ,,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

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
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
involutionhell-github-io Ready Ready Preview Oct 2, 2026 7:10pm UTC
website-preview Ready Ready Preview Oct 2, 2026 7:10pm UTC

This branch was successfully deployed

2 active deployments
Preview – involutionhell-github-io — 7a5dd06b Deployed Oct 2, 2026 by vercel[bot]
Preview – website-preview — 7a5dd06b Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants