Skip to content

fix(kg): robust LLM JSON parsing and extraction feedback#48

Merged
DankerMu merged 2 commits into
mainfrom
fix/kg-extraction-parsing
Feb 21, 2026
Merged

fix(kg): robust LLM JSON parsing and extraction feedback#48
DankerMu merged 2 commits into
mainfrom
fix/kg-extraction-parsing

Conversation

@DankerMu
Copy link
Copy Markdown
Owner

Summary

  • KG extraction returned empty results because _safe_loads_list couldn't handle markdown-fenced JSON or unescaped CJK quotes in LLM output
  • After successful extraction, UI showed "暂无提案" because default filter was pending but all proposals were auto_approved

Changes

  • Backend (kg_extraction.py): Strip markdown fences, fix unescaped ASCII quotes in CJK text, support {"items": [...]} wrapper, add response_format hint
  • Frontend (kg-panel.tsx): Switch to "all" filter after extraction, show success toast with count

Test plan

  • 127 unit tests pass
  • Live KG extraction returns 29 proposals (verified via curl)
  • UI: click "抽取 KG" → shows "抽取中..." → shows green toast with count → proposals listed

🤖 Generated with Claude Code

DankerMu and others added 2 commits February 21, 2026 19:28
- Strip markdown code fences from LLM output before JSON parsing
- Fix unescaped ASCII double quotes in CJK text (e.g. "灰潮事件")
- Support {"items": [...]} JSON wrapper format
- Add response_format hint for JSON-capable providers
- Switch to "all" filter after extraction so auto_approved results are visible
- Show success toast with extracted count after KG extraction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review findings:
- Narrow Unicode range to CJK unified ideographs only (exclude fullwidth punctuation)
- Move `import re` to module top level for consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DankerMu
Copy link
Copy Markdown
Owner Author

No description provided.

@DankerMu DankerMu merged commit 274f294 into main Feb 21, 2026
6 of 7 checks passed
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.

1 participant