mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-12 12:59:07 +00:00
core: update json output parser (#15079)
- **Description:** changed json.py to handle additional cases of partial json string to be parsed, basically by dropping the last character in the string until a valid json string is found or the string is empty. Also added additional test cases. - **Issue:** function parse_partial_json could not parse cases where the key is present but the value is not. --------- Co-authored-by: Nuno Campos <nuno@langchain.dev>
This commit is contained in:
@@ -199,6 +199,9 @@ TEST_CASES_PARTIAL = [
|
||||
('{"foo": "bar", "bar": "foo}', '{"foo": "bar", "bar": "foo}"}'),
|
||||
('{"foo": "bar", "bar": "foo[', '{"foo": "bar", "bar": "foo["}'),
|
||||
('{"foo": "bar", "bar": "foo\\"', '{"foo": "bar", "bar": "foo\\""}'),
|
||||
('{"foo": "bar", "bar":', '{"foo": "bar"}'),
|
||||
('{"foo": "bar", "bar"', '{"foo": "bar"}'),
|
||||
('{"foo": "bar", ', '{"foo": "bar"}'),
|
||||
]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user