mgbam's picture
Update core/utils.py
289370b verified
raw
history blame
684 Bytes
# 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.