Pijush2023 commited on
Commit
072f1b0
·
verified ·
1 Parent(s): 2c0e685

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -623,8 +623,8 @@ def clean_response(response_text):
623
  # Remove the entire 'Document(metadata=...' and any mention of it from the response
624
  response_text = re.sub(r'Document\(metadata=\{.*?\},page_content=', '', response_text, flags=re.DOTALL)
625
 
626
- # Extract top 5 fetched results (based on some identifier you have)
627
- top_results = response_text.split('\n')[:5] # Assuming top 5 results are first 5 lines of content
628
 
629
  # Remove any unwanted escape characters like \u and \u00
630
  response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
@@ -640,20 +640,22 @@ def clean_response(response_text):
640
  cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
641
 
642
  # Format the final response with bullet points
643
- final_response = f"""
644
- Sure! Here is the response for your Query:
645
- Document name - {document_name}
646
- Page No - {page_number}
647
- Top 5 Fetched Results:
648
- {''.join([f'{i+1}. {result.strip()}\n' for i, result in enumerate(top_results)])}
649
- Actual Response: {cleaned_response}
650
- """
 
651
 
652
  return final_response
653
 
654
 
655
 
656
 
 
657
  # Define a new template specifically for GPT-4o-mini in VDB Details mode
658
  gpt4o_mini_template_details = f"""
659
  As a highly specialized assistant, I provide precise, detailed, and informative responses. On this bright day of {current_date}, I'm equipped to assist with all your queries about Birmingham, Alabama, offering detailed insights tailored to your needs.
 
623
  # Remove the entire 'Document(metadata=...' and any mention of it from the response
624
  response_text = re.sub(r'Document\(metadata=\{.*?\},page_content=', '', response_text, flags=re.DOTALL)
625
 
626
+ # Extract top 5 fetched results (assuming the top 5 results are the first 5 lines of content)
627
+ top_results = response_text.split('\n')[:5] # Adjust this as per your actual data structure
628
 
629
  # Remove any unwanted escape characters like \u and \u00
630
  response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
 
640
  cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
641
 
642
  # Format the final response with bullet points
643
+ top_five_formatted = ''.join([f'{i+1}. {result.strip()}\n' for i, result in enumerate(top_results)])
644
+
645
+ final_response = (
646
+ f"Sure! Here is the response for your Query:\n"
647
+ f"Document name - {document_name}\n"
648
+ f"• Page No - {page_number}\n"
649
+ f"Top 5 Fetched Results:\n{top_five_formatted}"
650
+ f"• Actual Response - {cleaned_response}"
651
+ )
652
 
653
  return final_response
654
 
655
 
656
 
657
 
658
+
659
  # Define a new template specifically for GPT-4o-mini in VDB Details mode
660
  gpt4o_mini_template_details = f"""
661
  As a highly specialized assistant, I provide precise, detailed, and informative responses. On this bright day of {current_date}, I'm equipped to assist with all your queries about Birmingham, Alabama, offering detailed insights tailored to your needs.