Fix json in md when use quesion classifier node (#26992)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
Amy
2025-10-18 11:58:40 +08:00
committed by GitHub
parent 5937a66e22
commit 830f891a74
3 changed files with 34 additions and 4 deletions

View File

@@ -86,3 +86,24 @@ def test_parse_and_check_json_markdown_multiple_blocks_fails():
# opening fence to the last closing fence, causing JSON decode failure.
with pytest.raises(OutputParserError):
parse_and_check_json_markdown(src, [])
def test_parse_and_check_json_markdown_handles_think_fenced_and_raw_variants():
expected = {"keywords": ["2"], "category_id": "2", "category_name": "2"}
cases = [
"""
```json
[{"keywords": ["2"], "category_id": "2", "category_name": "2"}]
```, error: Expecting value: line 1 column 1 (char 0)
""",
"""
```json
{"keywords": ["2"], "category_id": "2", "category_name": "2"}
```, error: Extra data: line 2 column 5 (char 66)
""",
'{"keywords": ["2"], "category_id": "2", "category_name": "2"}',
'[{"keywords": ["2"], "category_id": "2", "category_name": "2"}]',
]
for src in cases:
obj = parse_and_check_json_markdown(src, ["keywords", "category_id", "category_name"])
assert obj == expected