Shreyas094 commited on
Commit
98f53b1
·
verified ·
1 Parent(s): d4f3b18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -493,12 +493,14 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search, c
493
 
494
  def extract_answer(full_response, instructions=None):
495
  try:
496
- # Remove the web search results and context information
497
  web_results_pattern = r"Answer based on: Web Results:.*?(?=\n\n)"
498
  context_pattern = r"Context:.*?Entities:.*?}\s*"
 
499
 
500
  full_response = re.sub(web_results_pattern, "", full_response, flags=re.DOTALL | re.IGNORECASE)
501
  full_response = re.sub(context_pattern, "", full_response, flags=re.DOTALL | re.IGNORECASE)
 
502
 
503
  # List of patterns to remove
504
  patterns_to_remove = [
 
493
 
494
  def extract_answer(full_response, instructions=None):
495
  try:
496
+ # Remove the web search results, context information, and "Human:" prefix
497
  web_results_pattern = r"Answer based on: Web Results:.*?(?=\n\n)"
498
  context_pattern = r"Context:.*?Entities:.*?}\s*"
499
+ human_prefix_pattern = r"Human:\s*"
500
 
501
  full_response = re.sub(web_results_pattern, "", full_response, flags=re.DOTALL | re.IGNORECASE)
502
  full_response = re.sub(context_pattern, "", full_response, flags=re.DOTALL | re.IGNORECASE)
503
+ full_response = re.sub(human_prefix_pattern, "", full_response, flags=re.IGNORECASE)
504
 
505
  # List of patterns to remove
506
  patterns_to_remove = [