magentic
magentic copied to clipboard
Implements streamed JSON array parsing using pydantic_core.from_json with fallback
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 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