Akj2023 commited on
Commit
d203c46
·
1 Parent(s): 77e6edd

Fix spinner with new UI

Browse files
Files changed (2) hide show
  1. app.py +23 -9
  2. style.css +12 -0
app.py CHANGED
@@ -94,6 +94,11 @@ st.header('Your Itinerary')
94
  # Create a loading spinner
95
  loading_spinner = st.spinner("Generating itinerary...")
96
 
 
 
 
 
 
97
  if submit:
98
  missing_fields = []
99
 
@@ -133,15 +138,17 @@ if submit:
133
  'accommodation': accommodation,
134
  'schedule': schedule
135
  }
 
136
  # Display loading spinner while generating the itinerary
137
  with loading_spinner:
 
 
 
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")
@@ -150,17 +157,24 @@ if submit:
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.
 
94
  # Create a loading spinner
95
  loading_spinner = st.spinner("Generating itinerary...")
96
 
97
+ # Read custom CSS from the external file
98
+ with open("styles.css", "r") as css_file:
99
+ custom_css = css_file.read()
100
+
101
+
102
  if submit:
103
  missing_fields = []
104
 
 
138
  'accommodation': accommodation,
139
  'schedule': schedule
140
  }
141
+
142
  # Display loading spinner while generating the itinerary
143
  with loading_spinner:
144
+
145
+ # Apply custom CSS to the spinner only
146
+ st.markdown(f"<style>{custom_css}</style>", unsafe_allow_html=True)
147
 
148
  # Call the generate_itinerary method (without artificial delay)
149
  itinerary_result = agent.generate_itinerary(user_details)
150
 
151
  if itinerary_result and itinerary_result["itinerary_suggestion"]:
 
 
152
 
153
  # Display the itinerary and other information (same as before)
154
  st.subheader("Itinerary Suggestion")
 
157
  st.write("Validation Dict:", itinerary_result["validation_dict"])
158
 
159
  elif itinerary_result and itinerary_result["itinerary_suggestion"] is None:
 
 
160
 
161
  # Display a message for unrealistic edge cases (same as before)
162
+ st.markdown(
163
+ """<div style='background-color:#ffebeb; padding:10px; border-radius:5px;'>
164
+ <p style='color:#ff0000; font-weight:bold;'>Error: The travel plan is not valid.</p>
165
+ <p>Please review your input and try again.</p>
166
+ </div>""",
167
+ unsafe_allow_html=True
168
+ )
169
  else:
 
 
170
 
171
+ st.markdown(
172
+ """<div style='background-color:#ffebeb; padding:10px; border-radius:5px;'>
173
+ <p style='color:#ff0000; font-weight:bold;'>An error occurred while generating the itinerary.</p>
174
+ <p>Please try again later or contact support.</p>
175
+ </div>""",
176
+ unsafe_allow_html=True
177
+ )
178
 
179
  note = """Here is your personalized travel itinerary covering all the major locations you want to visit.
180
  This map gives you a general overview of your travel route from start to finish.
style.css ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* styles.css */
2
+ .st-spinner > div > div > svg {
3
+ width: 100px;
4
+ height: 100px;
5
+ }
6
+
7
+ .st-spinner {
8
+ position: fixed;
9
+ left: 50%;
10
+ top: 50%;
11
+ transform: translate(-50%, -50%);
12
+ }