File size: 481 Bytes
43ce954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import re


# def extract_sql(response):
#     match = re.search(r"```sql\s+(.*?)\s+```", response, re.DOTALL | re.IGNORECASE)
#     return match.group(1) if match else None


def extract_sql(response):
    matches = re.findall(r"```sql\s+(.*?)\s+```", response, re.DOTALL | re.IGNORECASE)
    if matches:
        return matches[0].strip()
    return None


def is_sql(response):
    return bool(re.search(r"```sql\s+.*?```", response, re.DOTALL | re.IGNORECASE))