Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -980,21 +980,29 @@ def fetch_google_hotels():
|
|
980 |
import os
|
981 |
|
982 |
params = {
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
}
|
993 |
|
994 |
search = GoogleSearch(params)
|
995 |
results = search.get_dict()
|
|
|
|
|
|
|
|
|
996 |
hotel_results = results.get("hotels_results", [])
|
997 |
|
|
|
|
|
|
|
|
|
998 |
def star_rating(rating):
|
999 |
full_stars = int(float(rating))
|
1000 |
half_star = 1 if (float(rating) - full_stars) >= 0.5 else 0
|
@@ -1019,8 +1027,12 @@ def fetch_google_hotels():
|
|
1019 |
response_text += f"**Price:** {price}\n"
|
1020 |
response_text += "-" * 50 + "\n"
|
1021 |
|
|
|
|
|
|
|
1022 |
return response_text
|
1023 |
|
|
|
1024 |
def fetch_flight_info(message):
|
1025 |
|
1026 |
departure_id = "JFK" # Replace with parsed value from the message
|
|
|
980 |
import os
|
981 |
|
982 |
params = {
|
983 |
+
"engine": "google_hotels",
|
984 |
+
"q": "Birmingham Resorts",
|
985 |
+
"check_in_date": "2024-08-14",
|
986 |
+
"check_out_date": "2024-08-15",
|
987 |
+
"adults": "2",
|
988 |
+
"currency": "USD",
|
989 |
+
"gl": "us",
|
990 |
+
"hl": "en",
|
991 |
+
"api_key": os.getenv("SERP_API") # Ensure you use your SERP API key
|
992 |
}
|
993 |
|
994 |
search = GoogleSearch(params)
|
995 |
results = search.get_dict()
|
996 |
+
|
997 |
+
# Debugging: Print the entire response to check the content
|
998 |
+
print("Google Hotels API Response:", results)
|
999 |
+
|
1000 |
hotel_results = results.get("hotels_results", [])
|
1001 |
|
1002 |
+
if not hotel_results:
|
1003 |
+
print("No hotel results found.")
|
1004 |
+
return "No hotel information available."
|
1005 |
+
|
1006 |
def star_rating(rating):
|
1007 |
full_stars = int(float(rating))
|
1008 |
half_star = 1 if (float(rating) - full_stars) >= 0.5 else 0
|
|
|
1027 |
response_text += f"**Price:** {price}\n"
|
1028 |
response_text += "-" * 50 + "\n"
|
1029 |
|
1030 |
+
# Debugging: Print the generated response text
|
1031 |
+
print("Generated Hotel Response Text:", response_text)
|
1032 |
+
|
1033 |
return response_text
|
1034 |
|
1035 |
+
|
1036 |
def fetch_flight_info(message):
|
1037 |
|
1038 |
departure_id = "JFK" # Replace with parsed value from the message
|