This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import json | |
import ast | |
from pydantic import ValidationError | |
def extract_code_block(text): | |
# This regex looks for ```json or ``` followed by { ... } (JSON or dict-like structure) | |
code_block = re.findall(r'```(?:json)?\s*({.*?})\s*```', text, re.DOTALL) | |