Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -337,19 +337,26 @@ def bot(history, choice, tts_choice, retrieval_mode):
|
|
337 |
|
338 |
|
339 |
def format_restaurant_info(restaurant_info):
|
|
|
|
|
|
|
|
|
340 |
formatted_info = []
|
341 |
for restaurant in restaurant_info:
|
|
|
|
|
342 |
formatted_info.append(
|
343 |
-
f"**Name:** {restaurant
|
344 |
-
f"**Rating:** {restaurant
|
345 |
-
f"**Reviews:** {restaurant
|
346 |
-
f"**Phone:** {restaurant
|
347 |
-
f"**Snippet:** {restaurant
|
348 |
-
f"**Services:** {restaurant
|
349 |
-
f"**Yelp URL:** [Link]({restaurant
|
350 |
)
|
351 |
return "\n\n".join(formatted_info)
|
352 |
|
|
|
353 |
def fetch_yelp_restaurants():
|
354 |
params = {
|
355 |
"engine": "yelp",
|
@@ -377,7 +384,8 @@ def fetch_yelp_restaurants():
|
|
377 |
return yelp_data
|
378 |
|
379 |
def process_restaurant_query(query):
|
380 |
-
restaurant_info = fetch_yelp_restaurants()
|
|
|
381 |
formatted_info = format_restaurant_info(restaurant_info)
|
382 |
return formatted_info
|
383 |
|
@@ -386,7 +394,6 @@ def process_restaurant_query(query):
|
|
386 |
|
387 |
|
388 |
|
389 |
-
|
390 |
def add_message(history, message):
|
391 |
history.append((message, None))
|
392 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
|
|
337 |
|
338 |
|
339 |
def format_restaurant_info(restaurant_info):
|
340 |
+
if not isinstance(restaurant_info, list): # Check if it's not a list
|
341 |
+
print("Error: restaurant_info is not a list") # Add a helpful error message
|
342 |
+
return "Error: Unable to retrieve restaurant information."
|
343 |
+
|
344 |
formatted_info = []
|
345 |
for restaurant in restaurant_info:
|
346 |
+
if not isinstance(restaurant, dict): # Ensure each item is a dictionary
|
347 |
+
continue
|
348 |
formatted_info.append(
|
349 |
+
f"**Name:** {restaurant.get('name', 'N/A')}\n"
|
350 |
+
f"**Rating:** {restaurant.get('rating', 'N/A')} stars\n"
|
351 |
+
f"**Reviews:** {restaurant.get('reviews', 'N/A')}\n"
|
352 |
+
f"**Phone:** {restaurant.get('phone', 'N/A')}\n"
|
353 |
+
f"**Snippet:** {restaurant.get('snippet', 'N/A')}\n"
|
354 |
+
f"**Services:** {restaurant.get('services', 'N/A')}\n"
|
355 |
+
f"**Yelp URL:** [Link]({restaurant.get('link', '#')})\n"
|
356 |
)
|
357 |
return "\n\n".join(formatted_info)
|
358 |
|
359 |
+
|
360 |
def fetch_yelp_restaurants():
|
361 |
params = {
|
362 |
"engine": "yelp",
|
|
|
384 |
return yelp_data
|
385 |
|
386 |
def process_restaurant_query(query):
|
387 |
+
restaurant_info = fetch_yelp_restaurants()
|
388 |
+
print("DEBUG: restaurant_info =", restaurant_info) # Add this line for debugging
|
389 |
formatted_info = format_restaurant_info(restaurant_info)
|
390 |
return formatted_info
|
391 |
|
|
|
394 |
|
395 |
|
396 |
|
|
|
397 |
def add_message(history, message):
|
398 |
history.append((message, None))
|
399 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|