File size: 792 Bytes
0e3fb27
78d3c76
289370b
 
78d3c76
 
289370b
78d3c76
289370b
78d3c76
 
 
 
 
289370b
78d3c76
 
 
 
 
 
289370b
78d3c76
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# algoforge_prime/core/utils.py
import re

def basic_text_cleanup(text: str) -> str:
    """A basic cleanup for LLM outputs that might be wrapped in markdown code blocks."""
    if not text or not isinstance(text, str):
        return ""
    
    text = text.strip()
    # Common markdown code block patterns
    patterns = [
        r"^```python\s*(.*?)\s*```$",  # ```python ... ```
        r"^```\s*(.*?)\s*```$",        # ``` ... ```
    ]
    
    for pattern in patterns:
        match = re.match(pattern, text, re.DOTALL | re.IGNORECASE)
        if match:
            return match.group(1).strip() # Return content within the markers
            
    return text # Return original if no common markers found

# Add more utilities as needed.
print("DEBUG: core.utils - Module defined.")