Upload 97 files
Browse files
chatmock/routes_custom.py
CHANGED
|
@@ -99,7 +99,11 @@ def custom_api(model_name: str | None = None):
|
|
| 99 |
# 3. Handle newlines: replace with spaces
|
| 100 |
clean_text = clean_text.replace("\n\n", " ").replace("\n", " ")
|
| 101 |
|
| 102 |
-
# 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
clean_text = re.sub(r'\s+', ' ', clean_text).strip()
|
| 104 |
|
| 105 |
return jsonify({
|
|
|
|
| 99 |
# 3. Handle newlines: replace with spaces
|
| 100 |
clean_text = clean_text.replace("\n\n", " ").replace("\n", " ")
|
| 101 |
|
| 102 |
+
# 4. Remove emojis and other special non-ascii characters for clean plain text
|
| 103 |
+
# This removes the \ud83d\ude04 type sequences
|
| 104 |
+
clean_text = clean_text.encode('ascii', 'ignore').decode('ascii')
|
| 105 |
+
|
| 106 |
+
# 5. Final trim
|
| 107 |
clean_text = re.sub(r'\s+', ' ', clean_text).strip()
|
| 108 |
|
| 109 |
return jsonify({
|