Update app.py
Browse files
app.py
CHANGED
@@ -164,7 +164,7 @@ def query_router(query, method, retriever):
|
|
164 |
|
165 |
# Function to reset input and output
|
166 |
def reset_query_field():
|
167 |
-
return "","" # Reset only the query input
|
168 |
|
169 |
# Function to update the clock
|
170 |
def update_datetime():
|
@@ -190,7 +190,6 @@ if os.path.exists(src_logo) and not os.path.exists(dst_logo):
|
|
190 |
shutil.copy(src_logo, dst_logo)
|
191 |
print(f"Copied logo to {dst_logo}")
|
192 |
|
193 |
-
|
194 |
# Main function to create and launch the Gradio interface
|
195 |
def main():
|
196 |
# Initialize retriever
|
@@ -236,81 +235,78 @@ def main():
|
|
236 |
}
|
237 |
"""
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
|
|
258 |
|
259 |
-
|
260 |
-
|
|
|
|
|
261 |
|
262 |
-
|
263 |
-
|
|
|
264 |
|
265 |
-
|
266 |
-
with gr.Row(elem_classes="datetime-display"):
|
267 |
-
date_display = gr.Textbox(label="Date", interactive=False)
|
268 |
-
time_display = gr.Textbox(label="Time", interactive=False)
|
269 |
-
|
270 |
-
# Update date and time initially
|
271 |
-
date_val, time_val = get_current_datetime()
|
272 |
-
date_display.value = date_val
|
273 |
-
time_display.value = time_val
|
274 |
-
|
275 |
-
# Add refresh button for time
|
276 |
-
refresh_btn = gr.Button("Update Date & Time")
|
277 |
-
refresh_btn.click(fn=update_datetime, inputs=[], outputs=[date_display, time_display])
|
278 |
-
|
279 |
-
gr.Markdown("<p style='text-align: center; color: black;'>Ask me anything!</p>")
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
# Buttons Section
|
290 |
-
with gr.Row():
|
291 |
-
submit_button = gr.Button("Submit")
|
292 |
-
reset_button = gr.Button("Reset Query")
|
293 |
-
|
294 |
-
# Button Click Events
|
295 |
-
submit_button.click(
|
296 |
-
lambda query, method: query_router(query, method, retriever),
|
297 |
-
inputs=[query_input, query_method],
|
298 |
-
outputs=output_box
|
299 |
-
)
|
300 |
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
-
# Launch
|
313 |
-
|
314 |
|
315 |
if __name__ == "__main__":
|
316 |
-
main()
|
|
|
|
|
|
164 |
|
165 |
# Function to reset input and output
|
166 |
def reset_query_field():
|
167 |
+
return "", "" # Reset only the query input
|
168 |
|
169 |
# Function to update the clock
|
170 |
def update_datetime():
|
|
|
190 |
shutil.copy(src_logo, dst_logo)
|
191 |
print(f"Copied logo to {dst_logo}")
|
192 |
|
|
|
193 |
# Main function to create and launch the Gradio interface
|
194 |
def main():
|
195 |
# Initialize retriever
|
|
|
235 |
}
|
236 |
"""
|
237 |
|
238 |
+
# Create the Gradio interface using Blocks
|
239 |
+
with gr.Blocks(css=custom_css) as demo:
|
240 |
+
with gr.Row(elem_id="header-container"):
|
241 |
+
with gr.Column():
|
242 |
+
if os.path.exists(dst_logo):
|
243 |
+
gr.HTML(f"""
|
244 |
+
<div style="text-align:center; background-color:black; padding:15px;">
|
245 |
+
<img src="/static/Equinix-LOGO.jpeg" alt="Equinix Logo" style="max-height:80px;">
|
246 |
+
</div>
|
247 |
+
""")
|
248 |
+
else:
|
249 |
+
# Fallback to text logo
|
250 |
+
gr.HTML("""
|
251 |
+
<div style="text-align:center; background-color:black; padding:15px;">
|
252 |
+
<div style="color:#FF0000; font-size:24px;">■■■■</div>
|
253 |
+
<div style="font-size:28px; letter-spacing:5px; margin-top:5px; color:white;">EQUINIX</div>
|
254 |
+
</div>
|
255 |
+
""")
|
256 |
+
|
257 |
+
# Title & Description
|
258 |
+
gr.Markdown("<h1 style='text-align: center; color: black;'>Equinix Chatbot for Automation Team</h1>")
|
259 |
|
260 |
+
# Date and Time Display
|
261 |
+
with gr.Row(elem_classes="datetime-display"):
|
262 |
+
date_display = gr.Textbox(label="Date", interactive=False)
|
263 |
+
time_display = gr.Textbox(label="Time", interactive=False)
|
264 |
|
265 |
+
# Add refresh button for time
|
266 |
+
refresh_btn = gr.Button("Update Date & Time")
|
267 |
+
refresh_btn.click(fn=update_datetime, inputs=[], outputs=[date_display, time_display])
|
268 |
|
269 |
+
gr.Markdown("<p style='text-align: center; color: black;'>Ask me anything!</p>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
+
# Input & Dropdown Section
|
272 |
+
with gr.Row():
|
273 |
+
query_input = gr.Textbox(label="Enter your query")
|
274 |
+
query_method = gr.Dropdown(["Team Query", "General Query"], label="Select Query Type", value="Team Query")
|
275 |
|
276 |
+
# Output Textbox
|
277 |
+
output_box = gr.Textbox(label="Response", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
+
# Buttons Section
|
280 |
+
with gr.Row():
|
281 |
+
submit_button = gr.Button("Submit")
|
282 |
+
reset_button = gr.Button("Reset Query")
|
283 |
+
|
284 |
+
# Button Click Events
|
285 |
+
submit_button.click(
|
286 |
+
lambda query, method: query_router(query, method, retriever),
|
287 |
+
inputs=[query_input, query_method],
|
288 |
+
outputs=output_box
|
289 |
+
)
|
290 |
+
|
291 |
+
# Reset only the query input
|
292 |
+
reset_button.click(reset_query_field, inputs=[], outputs=[query_input, output_box])
|
293 |
+
|
294 |
+
# Update date and time on submission
|
295 |
+
submit_button.click(
|
296 |
+
fn=update_datetime,
|
297 |
+
inputs=[],
|
298 |
+
outputs=[date_display, time_display]
|
299 |
+
)
|
300 |
+
|
301 |
+
# Initialize date and time values
|
302 |
+
date_val, time_val = get_current_datetime()
|
303 |
+
date_display.value = date_val
|
304 |
+
time_display.value = time_val
|
305 |
|
306 |
+
# Launch the interface
|
307 |
+
demo.launch(share=True)
|
308 |
|
309 |
if __name__ == "__main__":
|
310 |
+
main()
|
311 |
+
|
312 |
+
|