Partial JSON parser extracted from OpenAI's vendored version.
npm install openai-partial-json-parser> Partial JSON parser extracted from OpenAI's vendored version.
- Intro
- Install
- Usage
- Why?
- Related
- License
This package exports OpenAI's vendored version of partial-json-parser as a standalone module, which itself is a refactored version of the original npm partial-json-parser.
It also adds some much-needed unit tests.
This package will be kept in sync with any changes to OpenAI's vendored version.
> [!NOTE]
> This package requires Node.js >= 18 or an equivalent environment (Bun, Deno, CF workers, etc).
``sh`
npm install openai-partial-json-parser
`ts
import { partialParse } from 'openai-partial-json-parser'
const json = partialParse('{ "foo": true, ')
// { foo: true }
`
- We should be able to access OpenAI's version of partial-json-parser without depending on the entire openai package.partial-json-parser
- OpenAI's vendored version of doesn't have any unit tests for some reason, which could cause undesired regressions.partial-json-parser
- We wanted a minimal, OpenAI-compatible version of for openai-fetch, dexter, and agentic.
- openai-zod-to-json-schema - Same as this module but for OpenAI's vendored zod-to-json-schema with support OpenAI's strict` mode for structured outputs.
MIT © Travis Fischer