handle invalid json output

pull/21891/head
ytqh 1 year ago
parent 47b6e067ea
commit 5d1c58ae90

@ -227,6 +227,11 @@ def process_user_health_summary(user: EndUser, new_messages: str):
import json import json
result = response["data"]["outputs"]["result"] result = response["data"]["outputs"]["result"]
# preprocess result in case of ```json xxxx```
if result.startswith("```json") or result.endswith("```"):
result = result.strip("```json").strip("```")
result = json.loads(result) result = json.loads(result)
if "health_status" in result: if "health_status" in result:
user.health_status = result["health_status"] user.health_status = result["health_status"]

Loading…
Cancel
Save