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

# This file can contain various helper functions used across the core modules.
# For example, text parsing, sanitization, logging helpers, etc.

def basic_text_cleanup(text: str) -> str:
    """A very basic cleanup for LLM outputs."""
    if not text:
        return ""
    # Remove common code block markers if they are at the very start/end of the whole string
    text = text.strip()
    if text.startswith("```python"):
        text = text[len("```python"):].strip()
    elif text.startswith("```"):
        text = text[3:].strip()
    
    if text.endswith("```"):
        text = text[:-3].strip()
    return text

# Add more utilities as needed.