Spaces:
Running
on
Zero
Running
on
Zero
Update response_processor.py
Browse files- response_processor.py +13 -0
response_processor.py
CHANGED
|
@@ -328,6 +328,19 @@ class ResponseProcessor:
|
|
| 328 |
try:
|
| 329 |
import re
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
# 第一優先級:處理斜線問題
|
| 332 |
# 首先處理已知的斜線組合,使用形容詞替換
|
| 333 |
for slash_combo, replacement in self.slash_replacements.items():
|
|
|
|
| 328 |
try:
|
| 329 |
import re
|
| 330 |
|
| 331 |
+
meta_commentary_patterns = [
|
| 332 |
+
r'\s*Note that I have followed.*?description\.?\s*$',
|
| 333 |
+
r'\s*I have (?:followed|adhered to|ensured).*?description\.?\s*$',
|
| 334 |
+
r'\s*This description (?:follows|adheres to|maintains).*?guidelines\.?\s*$',
|
| 335 |
+
r'\s*I have also varied sentence structures.*?description\.?\s*$'
|
| 336 |
+
]
|
| 337 |
+
|
| 338 |
+
for pattern in meta_commentary_patterns:
|
| 339 |
+
response = re.sub(pattern, '', response, flags=re.IGNORECASE | re.DOTALL)
|
| 340 |
+
|
| 341 |
+
# 清理可能產生的多餘空格
|
| 342 |
+
response = re.sub(r'\s+$', '', response)
|
| 343 |
+
|
| 344 |
# 第一優先級:處理斜線問題
|
| 345 |
# 首先處理已知的斜線組合,使用形容詞替換
|
| 346 |
for slash_combo, replacement in self.slash_replacements.items():
|