aiqknow commited on
Commit
f98590d
·
verified ·
1 Parent(s): 1be0522

Upload 97 files

Browse files
Files changed (1) hide show
  1. chatmock/routes_custom.py +5 -1
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. Final trim
 
 
 
 
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({