Spaces:
Runtime error
Runtime error
Add a loading UI Spinner
Browse files- app.py +32 -19
- templates/mapping.py +0 -1
app.py
CHANGED
@@ -90,6 +90,10 @@ with st.sidebar:
|
|
90 |
|
91 |
# Main page layout
|
92 |
st.header('Your Itinerary')
|
|
|
|
|
|
|
|
|
93 |
if submit:
|
94 |
missing_fields = []
|
95 |
|
@@ -129,25 +133,34 @@ if submit:
|
|
129 |
'accommodation': accommodation,
|
130 |
'schedule': schedule
|
131 |
}
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
note = """Here is your personalized travel itinerary covering all the major locations you want to visit.
|
153 |
This map gives you a general overview of your travel route from start to finish.
|
|
|
90 |
|
91 |
# Main page layout
|
92 |
st.header('Your Itinerary')
|
93 |
+
|
94 |
+
# Create a loading placeholder
|
95 |
+
loading_placeholder = st.empty()
|
96 |
+
|
97 |
if submit:
|
98 |
missing_fields = []
|
99 |
|
|
|
133 |
'accommodation': accommodation,
|
134 |
'schedule': schedule
|
135 |
}
|
136 |
+
# Display loading spinner while generating the itinerary
|
137 |
+
with loading_placeholder.spinner("Generating itinerary..."):
|
138 |
+
|
139 |
+
# Call the generate_itinerary method (without artificial delay)
|
140 |
+
itinerary_result = agent.generate_itinerary(user_details)
|
141 |
+
|
142 |
+
if itinerary_result and itinerary_result["itinerary_suggestion"]:
|
143 |
+
# Remove the loading spinner
|
144 |
+
loading_placeholder.empty()
|
145 |
+
|
146 |
+
# Display the itinerary and other information (same as before)
|
147 |
+
st.subheader("Itinerary Suggestion")
|
148 |
+
st.write(itinerary_result["itinerary_suggestion"])
|
149 |
+
st.write("List of Places:", itinerary_result["list_of_places"])
|
150 |
+
st.write("Validation Dict:", itinerary_result["validation_dict"])
|
151 |
+
|
152 |
+
elif itinerary_result and itinerary_result["itinerary_suggestion"] is None:
|
153 |
+
# Remove the loading spinner
|
154 |
+
loading_placeholder.empty()
|
155 |
+
|
156 |
+
# Display a message for unrealistic edge cases (same as before)
|
157 |
+
st.error("The travel plan is not valid.")
|
158 |
+
else:
|
159 |
+
# Remove the loading spinner
|
160 |
+
loading_placeholder.empty()
|
161 |
+
|
162 |
+
# Handle other errors (same as before)
|
163 |
+
st.error("An error occurred while generating the itinerary.")
|
164 |
|
165 |
note = """Here is your personalized travel itinerary covering all the major locations you want to visit.
|
166 |
This map gives you a general overview of your travel route from start to finish.
|
templates/mapping.py
CHANGED
@@ -31,7 +31,6 @@ class MappingTemplate(object):
|
|
31 |
For example:
|
32 |
|
33 |
####
|
34 |
-
Itinerary for a 2-day driving trip within London:
|
35 |
- Day 1:
|
36 |
- Start at Buckingham Palace (The Mall, London SW1A 1AA)
|
37 |
- Visit the Tower of London (Tower Hill, London EC3N 4AB)
|
|
|
31 |
For example:
|
32 |
|
33 |
####
|
|
|
34 |
- Day 1:
|
35 |
- Start at Buckingham Palace (The Mall, London SW1A 1AA)
|
36 |
- Visit the Tower of London (Tower Hill, London EC3N 4AB)
|