magentic icon indicating copy to clipboard operation
magentic copied to clipboard

Implements streamed JSON array parsing using pydantic_core.from_json with fallback

Open jo-s-eph opened this issue 11 months ago • 1 comments

This PR addresses issue #422 by Integrating pydantic_core.from_json for parsing JSON chunks in iter_streamed_json_array and aiter_streamed_json_arraywith a fallback to the character-by-character parsing with JsonArrayParserState to handle incomplete or malformed JSON.

jo-s-eph avatar Mar 20 '25 10:03 jo-s-eph

@jo-s-eph The whole JsonArrayParserState should be gone. In the end I expect there to be less code due from switching to pydantic_core.from_json. My suggested approach is in comment https://github.com/jackmpcollins/magentic/issues/422#issuecomment-2643968478 Thanks for working on this and let me know if you have any questions I can help with

jackmpcollins avatar Apr 07 '25 01:04 jackmpcollins