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

@ -1,4 +1,5 @@
import json
import re
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Any
@ -194,6 +195,8 @@ class QuestionClassifierNode(Node):
category_name = node_data.classes[0].name
category_id = node_data.classes[0].id
if "<think>" in result_text:
result_text = re.sub(r"<think[^>]*>[\s\S]*?</think>", "", result_text, flags=re.IGNORECASE)
result_text_json = parse_and_check_json_markdown(result_text, [])
# result_text_json = json.loads(result_text.strip('```JSON\n'))
if "category_name" in result_text_json and "category_id" in result_text_json: