Spaces:
Running
on
Zero
Running
on
Zero
Update response_processor.py
Browse files- response_processor.py +5 -5
response_processor.py
CHANGED
@@ -1218,7 +1218,7 @@ class ResponseProcessor:
|
|
1218 |
if not re.search(r'[.!?]', response):
|
1219 |
raise ResponseProcessingError("Response lacks proper sentence structure")
|
1220 |
|
1221 |
-
def remove_explanatory_notes(response: str, debug: bool = False) -> str:
|
1222 |
"""
|
1223 |
η§»ι€ LLM εζδΈηθ§£ιζ§ζ³¨ιεε
§ι¨θηζε
|
1224 |
|
@@ -1387,15 +1387,15 @@ class ResponseProcessor:
|
|
1387 |
result = re.sub(r'\s+([,.!?])', r'\1', result)
|
1388 |
result = result.strip()
|
1389 |
|
1390 |
-
if debug:
|
1391 |
-
|
1392 |
|
1393 |
return result if result else original_response
|
1394 |
|
1395 |
except Exception as e:
|
1396 |
# ε¦ζθηιη¨δΈηΌηι―θͺ€οΌθΏεεε§ζε
|
1397 |
-
if debug:
|
1398 |
-
|
1399 |
return original_response
|
1400 |
|
1401 |
def get_processor_info(self) -> Dict[str, Any]:
|
|
|
1218 |
if not re.search(r'[.!?]', response):
|
1219 |
raise ResponseProcessingError("Response lacks proper sentence structure")
|
1220 |
|
1221 |
+
def remove_explanatory_notes(self, response: str, debug: bool = False) -> str:
|
1222 |
"""
|
1223 |
η§»ι€ LLM εζδΈηθ§£ιζ§ζ³¨ιεε
§ι¨θηζε
|
1224 |
|
|
|
1387 |
result = re.sub(r'\s+([,.!?])', r'\1', result)
|
1388 |
result = result.strip()
|
1389 |
|
1390 |
+
if debug and hasattr(self, 'logger'):
|
1391 |
+
self.logger.info(f"Cleaning completed. Original length: {len(original_response)}, Final length: {len(result)}")
|
1392 |
|
1393 |
return result if result else original_response
|
1394 |
|
1395 |
except Exception as e:
|
1396 |
# ε¦ζθηιη¨δΈηΌηι―θͺ€οΌθΏεεε§ζε
|
1397 |
+
if debug and hasattr(self, 'logger'):
|
1398 |
+
self.logger.error(f"Error during cleaning: {str(e)}")
|
1399 |
return original_response
|
1400 |
|
1401 |
def get_processor_info(self) -> Dict[str, Any]:
|