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 ("JFK" in message or "BHM" in message):
|
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
|
@@ -372,11 +372,20 @@ def generate_answer(message, choice, retrieval_mode):
|
|
372 |
else:
|
373 |
response = "Invalid retrieval mode selected."
|
374 |
|
375 |
-
# Assign numbers to each item in the response
|
376 |
response_lines = response.splitlines()
|
377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
-
return intro + numbered_response, extract_addresses(response)
|
380 |
|
381 |
|
382 |
|
|
|
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 ("JFK" in message or "BHM" in message):
|
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
|
|
|
372 |
else:
|
373 |
response = "Invalid retrieval mode selected."
|
374 |
|
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 |
|
391 |
|