import json from typing import Dict def clean_response(res:str): try: raw = res.strip() # bersihin block fencing kalau ada if raw.startswith("```"): import re raw = re.sub(r"^```[a-zA-Z]*\n?", "", raw) raw = re.sub(r"\n?```$", "", raw) j_res = json.loads(raw) return j_res except Exception as e: return None