promplate / partial-json-parser-js

Parse partial JSON generated by LLM
https://npmjs.com/partial-json
MIT License
76 stars 2 forks source link

Allow partials strings #7

Closed thgh closed 6 months ago

thgh commented 6 months ago

It would be cool to parse it like this: (for AI completions)

in:  { "name": { "first": "ind", "last": "go

out: { "name": { "first": "ind", "last": "go" } }
CNSeniorious000 commented 6 months ago

Yeah, but I think it is implemented now, you can use JSON.stringify(parse(text)) to get the completed JSON as string.

Of course the spaces inside is not preserved. Do you mean that? Or I don't get the difference.

thgh commented 6 months ago

Hi, sorry! I thought this repo was related to https://www.npmjs.com/package/partial-json-parser which documents that unclosed strings are considered undefined.

I used this project and it works perfect for the LLM case :-) Thanks!