Pijush2023 commited on
Commit
f8ecddd
·
verified ·
1 Parent(s): 7e40505

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -47
app.py CHANGED
@@ -487,47 +487,6 @@ import re
487
 
488
 
489
 
490
- # def clean_response(response_text):
491
- # # Remove system and user tags
492
- # response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
493
- # response_text = re.sub(r'<\|user\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
494
- # response_text = re.sub(r'<\|assistant\|>', '', response_text, flags=re.DOTALL)
495
-
496
- # # Extract the document name and page number
497
- # document_match = re.search(r"Document\(metadata=\{'source':'(.+?)','page':(\d+)\}", response_text)
498
- # if document_match:
499
- # document_name = document_match.group(1).split('/')[-1] # Get the document name
500
- # page_number = document_match.group(2) # Get the page number
501
- # else:
502
- # document_name = "Unknown"
503
- # page_number = "Unknown"
504
-
505
- # # Remove the 'Document(metadata=...' part and keep only the page content
506
- # response_text = re.sub(r'Document\(metadata=\{.*?\},page_content=', '', response_text, flags=re.DOTALL)
507
-
508
- # # Remove any unwanted escape characters like \u and \u00
509
- # response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
510
-
511
- # # Ensure proper spacing between words and dates
512
- # response_text = re.sub(r'([a-zA-Z])(\d)', r'\1 \2', response_text)
513
- # response_text = re.sub(r'(\d)([a-zA-Z])', r'\1 \2', response_text)
514
-
515
- # # Remove the phrase "Sure! The Responses are as follows:" from the actual content
516
- # response_text = re.sub(r'Sure! The Responses are as follows:', '', response_text).strip()
517
-
518
- # # Clean up the text by removing extra whitespace
519
- # cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
520
-
521
- # # Format the final response with bullet points
522
- # final_response = f"""
523
- # Sure! The Responses are as follows:
524
- # • Document name - {document_name}
525
- # • Page No - {page_number}
526
- # • Response - {cleaned_response}
527
- # """
528
-
529
- # return final_response
530
-
531
  def clean_response(response_text):
532
  # Remove system and user tags
533
  response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
@@ -549,12 +508,12 @@ def clean_response(response_text):
549
  # Remove any unwanted escape characters like \u and \u00
550
  response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
551
 
552
- # Insert spaces between letters and numbers
553
- response_text = re.sub(r'([a-zA-Z])(\d)', r'\1 \2', response_text) # Letter followed by a number
554
- response_text = re.sub(r'(\d)([a-zA-Z])', r'\1 \2', response_text) # Number followed by a letter
555
 
556
- # Ensure spaces between words, even when run together (e.g., between lowercase and uppercase letters)
557
- response_text = re.sub(r'([a-z])([A-Z])', r'\1 \2', response_text) # Insert space between lowercase and uppercase letters
558
 
559
  # Clean up the text by removing extra whitespace
560
  cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
@@ -577,6 +536,8 @@ Sure! The Responses are as follows:
577
 
578
 
579
 
 
 
580
  # Define a new template specifically for GPT-4o-mini in VDB Details mode
581
  gpt4o_mini_template_details = f"""
582
  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.
@@ -1500,7 +1461,7 @@ def fetch_google_flights(departure_id="JFK", arrival_id="BHM", outbound_date=cur
1500
 
1501
 
1502
 
1503
- with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1504
 
1505
 
1506
  with gr.Row():
 
487
 
488
 
489
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  def clean_response(response_text):
491
  # Remove system and user tags
492
  response_text = re.sub(r'<\|system\|>.*?<\|end\|>', '', response_text, flags=re.DOTALL)
 
508
  # Remove any unwanted escape characters like \u and \u00
509
  response_text = re.sub(r'\\u[0-9A-Fa-f]{4}', '', response_text)
510
 
511
+ # Ensure proper spacing between words and dates
512
+ response_text = re.sub(r'([a-zA-Z])(\d)', r'\1 \2', response_text)
513
+ response_text = re.sub(r'(\d)([a-zA-Z])', r'\1 \2', response_text)
514
 
515
+ # Remove the phrase "Sure! The Responses are as follows:" from the actual content
516
+ response_text = re.sub(r'Sure! The Responses are as follows:', '', response_text).strip()
517
 
518
  # Clean up the text by removing extra whitespace
519
  cleaned_response = re.sub(r'\s+', ' ', response_text).strip()
 
536
 
537
 
538
 
539
+
540
+
541
  # Define a new template specifically for GPT-4o-mini in VDB Details mode
542
  gpt4o_mini_template_details = f"""
543
  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.
 
1461
 
1462
 
1463
 
1464
+ with gr.Blocks(theme='gradio/soft') as demo:
1465
 
1466
 
1467
  with gr.Row():