Pijush2023 commited on
Commit
bbb8b3d
·
verified ·
1 Parent(s): 4443c31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -403,10 +403,12 @@ Answer:
403
 
404
 
405
  def clean_response(response_text):
406
- # Remove any unwanted follow-up questions or unnecessary text
407
- cleaned_response = re.sub(r'Question:.*\nAnswer:', '', response_text, flags=re.DOTALL).strip()
 
408
  return cleaned_response
409
 
 
410
  def generate_answer(message, choice, retrieval_mode, selected_model):
411
  logging.debug(f"generate_answer called with choice: {choice} and retrieval_mode: {retrieval_mode}")
412
 
@@ -477,6 +479,7 @@ def generate_answer(message, choice, retrieval_mode, selected_model):
477
 
478
 
479
 
 
480
  def bot(history, choice, tts_choice, retrieval_mode, model_choice):
481
  if not history:
482
  return history
 
403
 
404
 
405
  def clean_response(response_text):
406
+ # Remove any metadata-like information and focus on the main content
407
+ cleaned_response = re.sub(r'\[Document\(.*?\),?|\{.*?\}', '', response_text, flags=re.DOTALL)
408
+ cleaned_response = re.sub(r'\s+', ' ', cleaned_response).strip()
409
  return cleaned_response
410
 
411
+
412
  def generate_answer(message, choice, retrieval_mode, selected_model):
413
  logging.debug(f"generate_answer called with choice: {choice} and retrieval_mode: {retrieval_mode}")
414
 
 
479
 
480
 
481
 
482
+
483
  def bot(history, choice, tts_choice, retrieval_mode, model_choice):
484
  if not history:
485
  return history