Spaces:
Sleeping
Sleeping
Update core/utils.py
Browse files- core/utils.py +20 -5
core/utils.py
CHANGED
@@ -1,6 +1,21 @@
|
|
1 |
# algoforge_prime/core/utils.py
|
2 |
-
|
3 |
-
#
|
4 |
-
#
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# algoforge_prime/core/utils.py
|
2 |
+
|
3 |
+
# This file can contain various helper functions used across the core modules.
|
4 |
+
# For example, text parsing, sanitization, logging helpers, etc.
|
5 |
+
|
6 |
+
def basic_text_cleanup(text: str) -> str:
|
7 |
+
"""A very basic cleanup for LLM outputs."""
|
8 |
+
if not text:
|
9 |
+
return ""
|
10 |
+
# Remove common code block markers if they are at the very start/end of the whole string
|
11 |
+
text = text.strip()
|
12 |
+
if text.startswith("```python"):
|
13 |
+
text = text[len("```python"):].strip()
|
14 |
+
elif text.startswith("```"):
|
15 |
+
text = text[3:].strip()
|
16 |
+
|
17 |
+
if text.endswith("```"):
|
18 |
+
text = text[:-3].strip()
|
19 |
+
return text
|
20 |
+
|
21 |
+
# Add more utilities as needed.
|