Spaces:
Sleeping
Sleeping
Switch to Hugging Face Inference API instead of local models
Browse files- ai_service.py +3 -3
ai_service.py
CHANGED
|
@@ -10,12 +10,12 @@ MODEL_NAME = HF_MODEL
|
|
| 10 |
def clean_ai_response(text: str):
|
| 11 |
if not text: return ""
|
| 12 |
text = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL)
|
| 13 |
-
# Remove markdown tables
|
| 14 |
-
text = re.sub(r'\|.*?\|', '', text)
|
| 15 |
-
text = re.sub(r'[-|]{3,}', '', text)
|
| 16 |
# Remove HTML tags
|
| 17 |
text = re.sub(r'<br\s*/?>', '\n', text)
|
| 18 |
text = re.sub(r'<[^>]+>', '', text)
|
|
|
|
|
|
|
|
|
|
| 19 |
# Remove markdown bold/italic
|
| 20 |
text = re.sub(r'[*_]{1,3}(.*?)[*_]{1,3}', r'\1', text)
|
| 21 |
# Remove markdown headers
|
|
|
|
| 10 |
def clean_ai_response(text: str):
|
| 11 |
if not text: return ""
|
| 12 |
text = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL)
|
|
|
|
|
|
|
|
|
|
| 13 |
# Remove HTML tags
|
| 14 |
text = re.sub(r'<br\s*/?>', '\n', text)
|
| 15 |
text = re.sub(r'<[^>]+>', '', text)
|
| 16 |
+
# Remove markdown tables (lines that start and end with |)
|
| 17 |
+
text = re.sub(r'^\|.*\|\s*$', '', text, flags=re.MULTILINE)
|
| 18 |
+
text = re.sub(r'^[\s|:-]+$', '', text, flags=re.MULTILINE)
|
| 19 |
# Remove markdown bold/italic
|
| 20 |
text = re.sub(r'[*_]{1,3}(.*?)[*_]{1,3}', r'\1', text)
|
| 21 |
# Remove markdown headers
|