Pijush2023 commited on
Commit
0a7cb11
·
verified ·
1 Parent(s): 740f5fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -40
app.py CHANGED
@@ -502,46 +502,6 @@ def bot(history, choice, tts_choice, retrieval_mode, model_choice):
502
 
503
  import re
504
 
505
- # def clean_response(response_text):
506
- # # Remove system and user tags
507
- # response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
508
- # response_text = re.sub(r'<\|user\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
509
- # response_text = re.sub(r'<\|assistant\|>', '', response_text, flags=re.DOTALL)
510
-
511
- # # Extract the document name and page number
512
- # document_match = re.search(r"Document\(metadata=\{'source':'(.+?)','page':(\d+)\}", response_text)
513
- # if document_match:
514
- # document_name = document_match.group(1).split('/')[-1] # Get the document name
515
- # page_number = document_match.group(2) # Get the page number
516
- # else:
517
- # document_name = "Unknown"
518
- # page_number = "Unknown"
519
-
520
- # # Remove the 'Document(metadata=...' part and keep only the page content
521
- # response_text = re.sub(r'Document\(metadata=\{.*?\},page_content=', '', response_text, flags=re.DOTALL)
522
-
523
- # # Remove any unwanted escape characters like \u and \u00
524
- # response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
525
-
526
- # # Ensure proper spacing between words and dates
527
- # response_text = re.sub(r'([a-zA-Z])(\d)', r'\1 \2', response_text)
528
- # response_text = re.sub(r'(\d)([a-zA-Z])', r'\1 \2', response_text)
529
-
530
- # # Remove the phrase "Sure! The Responses are as follows:" from the actual content
531
- # response_text = re.sub(r'Sure! The Responses are as follows:', '', response_text).strip()
532
-
533
- # # Clean up the text by removing extra whitespace
534
- # cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
535
-
536
- # # Format the final response with bullet points
537
- # final_response = f"""
538
- # Sure! The Responses are as follows:
539
- # • Document name - {document_name}
540
- # • Page No - {page_number}
541
- # • Response - {cleaned_response}
542
- # """
543
-
544
- # return final_response
545
 
546
  # def clean_response(response_text):
547
  # # Remove system and user tags
 
502
 
503
  import re
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
 
506
  # def clean_response(response_text):
507
  # # Remove system and user tags