展示HN:JSON-Healer:修复和验证来自大型语言模型输出的损坏JSON

1作者: freakynit2 个月前原帖
构建了json-healer,这是一个小型的npm包,用于修复由大型语言模型(LLMs)生成的格式错误或不完整的JSON。<p>受到OpenRouter最近推出的响应修复工具的启发(<a href="https:&#x2F;&#x2F;openrouter.ai&#x2F;docs&#x2F;guides&#x2F;features&#x2F;plugins&#x2F;response-healing" rel="nofollow">https:&#x2F;&#x2F;openrouter.ai&#x2F;docs&#x2F;guides&#x2F;features&#x2F;plugins&#x2F;response-...</a>),该实现与模型无关,可以处理来自任何LLM或文本源的JSON,而不仅限于OpenRouter。<p>包含全面的测试用例,设计上易于集成到依赖结构化LLM输出的现有工作流程中。<p><a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@freakynit&#x2F;json-healer" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@freakynit&#x2F;json-healer</a><p>欢迎反馈!
查看原文
Built json-healer, a small npm package that repairs malformed or partial JSON produced by LLMs.<p>Inspired by OpenRouter’s recently launched response healer (<a href="https:&#x2F;&#x2F;openrouter.ai&#x2F;docs&#x2F;guides&#x2F;features&#x2F;plugins&#x2F;response-healing" rel="nofollow">https:&#x2F;&#x2F;openrouter.ai&#x2F;docs&#x2F;guides&#x2F;features&#x2F;plugins&#x2F;response-...</a>), this implementation is model-agnostic and works with JSON from any LLM or text source, not just OpenRouter.<p>Includes comprehensive test cases and is designed to be easy to drop into existing pipelines that rely on structured LLM output.<p><a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@freakynit&#x2F;json-healer" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@freakynit&#x2F;json-healer</a><p>Feedback welcome!