Spaces:
Paused
Paused
Update app.py
Browse files
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
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
|
|
|
|
|
|
383 |
|
384 |
-
|
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 |
|