Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -468,7 +468,12 @@ def clean_response(response_text):
|
|
468 |
response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
|
469 |
response_text = re.sub(r'<\|user\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
|
470 |
response_text = re.sub(r'<\|assistant\|>', '', response_text, flags=re.DOTALL)
|
471 |
-
|
|
|
|
|
|
|
|
|
|
|
472 |
# Clean up the text by removing extra whitespace
|
473 |
cleaned_response = response_text.strip()
|
474 |
cleaned_response = re.sub(r'\s+', ' ', cleaned_response)
|
|
|
468 |
response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
|
469 |
response_text = re.sub(r'<\|user\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
|
470 |
response_text = re.sub(r'<\|assistant\|>', '', response_text, flags=re.DOTALL)
|
471 |
+
#-------
|
472 |
+
response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
|
473 |
+
# Add spaces between words and dates (e.g., "born04/04/1963" becomes "born 04/04/1963")
|
474 |
+
response_text = re.sub(r'([a-zA-Z])(\d)', r'\1 \2', response_text)
|
475 |
+
response_text = re.sub(r'(\d)([a-zA-Z])', r'\1 \2', response_text)
|
476 |
+
#--------
|
477 |
# Clean up the text by removing extra whitespace
|
478 |
cleaned_response = response_text.strip()
|
479 |
cleaned_response = re.sub(r'\s+', ' ', cleaned_response)
|