更新了响应形式
This commit is contained in:
parent
d04e406972
commit
28ff0979c1
Binary file not shown.
Binary file not shown.
@ -146,3 +146,4 @@ class TopicGenerator:
|
||||
return topics
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ class TopicParser:
|
||||
# 验证每个选题是否包含所有必需的键
|
||||
valid_topics = []
|
||||
required_keys = {"index", "date", "logic", "object", "product", "style", "target_audience"}
|
||||
optional_keys = {"product_logic", "style_logic", "target_audience_logic"}
|
||||
|
||||
for i, item in enumerate(parsed_json):
|
||||
if isinstance(item, dict) and required_keys.issubset(item.keys()):
|
||||
|
||||
Binary file not shown.
@ -202,14 +202,12 @@ def process_llm_json_text(text: Any) -> Optional[Dict[str, Any]]:
|
||||
for candidate in json_candidates:
|
||||
# 直接尝试解析
|
||||
try:
|
||||
import json
|
||||
return json.loads(candidate)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
# 使用json_repair尝试修复
|
||||
try:
|
||||
import json_repair
|
||||
return json_repair.loads(candidate)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user