Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -351,8 +351,8 @@ def generate_answer(message, choice, retrieval_mode):
|
|
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 "
|
355 |
-
|
356 |
response = fetch_google_flights()
|
357 |
else:
|
358 |
prompt_template = QA_CHAIN_PROMPT_1 if choice == "Details" else QA_CHAIN_PROMPT_2
|
@@ -375,14 +375,22 @@ 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 in range(0, len(response_lines), 7): # Assuming 7 lines per restaurant/hotel/flight entry
|
379 |
-
formatted_response += f"{
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
385 |
formatted_response += "\n" # Extra line between items
|
|
|
386 |
|
387 |
return intro + formatted_response.strip(), extract_addresses(response)
|
388 |
|
@@ -395,6 +403,7 @@ def generate_answer(message, choice, retrieval_mode):
|
|
395 |
|
396 |
|
397 |
|
|
|
398 |
# def bot(history, choice, tts_choice, retrieval_mode):
|
399 |
# if not history:
|
400 |
# return history
|
|
|
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 ("JFK" in message or "BHM" in message):
|
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 |
+
item_counter = 1
|
379 |
+
|
380 |
for i in range(0, len(response_lines), 7): # Assuming 7 lines per restaurant/hotel/flight entry
|
381 |
+
formatted_response += f"{item_counter}. {response_lines[i]}\n" # Number and name
|
382 |
+
if i + 1 < len(response_lines):
|
383 |
+
formatted_response += f" {response_lines[i + 1]}\n" # Link and location
|
384 |
+
if i + 2 < len(response_lines):
|
385 |
+
formatted_response += f" {response_lines[i + 2]}\n" # Contact number
|
386 |
+
if i + 3 < len(response_lines):
|
387 |
+
formatted_response += f" {response_lines[i + 3]}\n" # Rating
|
388 |
+
if i + 4 < len(response_lines):
|
389 |
+
formatted_response += f" {response_lines[i + 4]}\n" # Snippet
|
390 |
+
if i + 5 < len(response_lines):
|
391 |
+
formatted_response += f" {response_lines[i + 5]}\n" # Divider
|
392 |
formatted_response += "\n" # Extra line between items
|
393 |
+
item_counter += 1
|
394 |
|
395 |
return intro + formatted_response.strip(), extract_addresses(response)
|
396 |
|
|
|
403 |
|
404 |
|
405 |
|
406 |
+
|
407 |
# def bot(history, choice, tts_choice, retrieval_mode):
|
408 |
# if not history:
|
409 |
# return history
|