Pijush2023 commited on
Commit
f973269
·
verified ·
1 Parent(s): e52c5c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -346,13 +346,13 @@ def generate_answer(message, choice, retrieval_mode):
346
  intro = ""
347
  response = ""
348
  if "hotel" in message.lower() and "birmingham" in message.lower():
349
- intro = "Here are the top Hotels in Birmingham:"
350
  response = fetch_google_hotels()
351
  elif "restaurant" in message.lower() and "birmingham" in message.lower():
352
- intro = "Here are the top Restaurants in Birmingham:"
353
  response = fetch_yelp_restaurants()
354
  elif "flight" in message.lower() and "birmingham" in message.lower():
355
- # intro = "Here are some available flights for today:"
356
  response = fetch_google_flights()
357
  else:
358
  prompt_template = QA_CHAIN_PROMPT_1 if choice == "Details" else QA_CHAIN_PROMPT_2
@@ -375,16 +375,17 @@ def generate_answer(message, choice, retrieval_mode):
375
  # Assign numbers to each item in the response and format it
376
  response_lines = response.splitlines()
377
  formatted_response = ""
378
- for i, line in enumerate(response_lines):
379
- if i == 0:
380
- formatted_response += f"{i+1}. {line.strip()}\n"
381
- else:
382
- formatted_response += f" {line.strip()}\n"
 
 
 
383
 
384
- # Combine intro and formatted response
385
- final_response = f"{intro}\n\n{formatted_response}"
386
 
387
- return final_response, extract_addresses(response)
388
 
389
 
390
 
 
346
  intro = ""
347
  response = ""
348
  if "hotel" in message.lower() and "birmingham" in message.lower():
349
+ intro = "Here are the top Hotels in Birmingham:\n\n"
350
  response = fetch_google_hotels()
351
  elif "restaurant" in message.lower() and "birmingham" in message.lower():
352
+ intro = "Here are the top Restaurants in Birmingham:\n\n"
353
  response = fetch_yelp_restaurants()
354
  elif "flight" in message.lower() and "birmingham" in message.lower():
355
+ # intro = "Here are some available flights for today:\n\n"
356
  response = fetch_google_flights()
357
  else:
358
  prompt_template = QA_CHAIN_PROMPT_1 if choice == "Details" else QA_CHAIN_PROMPT_2
 
375
  # Assign numbers to each item in the response and format it
376
  response_lines = response.splitlines()
377
  formatted_response = ""
378
+ for i in range(0, len(response_lines), 7): # Assuming 7 lines per restaurant/hotel/flight entry
379
+ formatted_response += f"{i//7 + 1}. {response_lines[i]}\n" # Number and name
380
+ formatted_response += f" {response_lines[i + 1]}\n" # Link and location
381
+ formatted_response += f" {response_lines[i + 2]}\n" # Contact number
382
+ formatted_response += f" {response_lines[i + 3]}\n" # Rating
383
+ formatted_response += f" {response_lines[i + 4]}\n" # Snippet
384
+ formatted_response += f" {response_lines[i + 5]}\n" # Divider
385
+ formatted_response += "\n" # Extra line between items
386
 
387
+ return intro + formatted_response.strip(), extract_addresses(response)
 
388
 
 
389
 
390
 
391