Spaces:
Sleeping
Sleeping
Update formatter_node.py
Browse files- formatter_node.py +12 -1
formatter_node.py
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
|
|
|
|
|
| 1 |
def formatter_node(llm_output):
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
def formatter_node(llm_output):
|
| 4 |
+
cleaned = llm_output.strip()
|
| 5 |
+
|
| 6 |
+
# Remove common LLM prefixes
|
| 7 |
+
cleaned = re.sub(r'^(Answer:|Final Answer:)\s*', '', cleaned, flags=re.IGNORECASE)
|
| 8 |
+
|
| 9 |
+
# Remove enclosing quotes if any
|
| 10 |
+
if cleaned.startswith('"') and cleaned.endswith('"'):
|
| 11 |
+
cleaned = cleaned[1:-1]
|
| 12 |
+
|
| 13 |
+
return cleaned.strip()
|