Spaces:
Sleeping
Sleeping
update Gradio UI to include spinner
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ from tools.analytics_tool import AnalyticsTool
|
|
| 10 |
import json
|
| 11 |
import gradio as gr
|
| 12 |
import warnings
|
|
|
|
| 13 |
|
| 14 |
warnings.filterwarnings("ignore")
|
| 15 |
|
|
@@ -229,12 +230,24 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as app:
|
|
| 229 |
)
|
| 230 |
|
| 231 |
run_button = gr.Button("π Run Full Analysis", variant="primary")
|
|
|
|
| 232 |
report_output = gr.Markdown(label="π Intelligence Report")
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
run_button.click(
|
| 235 |
-
|
| 236 |
inputs=[crypto, currency, days],
|
| 237 |
-
outputs=report_output,
|
| 238 |
show_progress=True
|
| 239 |
)
|
| 240 |
|
|
|
|
| 10 |
import json
|
| 11 |
import gradio as gr
|
| 12 |
import warnings
|
| 13 |
+
import time
|
| 14 |
|
| 15 |
warnings.filterwarnings("ignore")
|
| 16 |
|
|
|
|
| 230 |
)
|
| 231 |
|
| 232 |
run_button = gr.Button("π Run Full Analysis", variant="primary")
|
| 233 |
+
spinner = gr.HTML("")
|
| 234 |
report_output = gr.Markdown(label="π Intelligence Report")
|
| 235 |
|
| 236 |
+
def analyze_crypto(crypto, days):
|
| 237 |
+
spinner.update(value="<p> β³ <b>Running...</b></p>")
|
| 238 |
+
time.sleep(0.5)
|
| 239 |
+
try:
|
| 240 |
+
report = generate_report(crypto, currency, days)
|
| 241 |
+
spinner.update(value="<p>β
<b>Complete!</b></p>")
|
| 242 |
+
return spinner.value, report
|
| 243 |
+
except Exception as e:
|
| 244 |
+
spinner.update(value=f"<p>β Error: {e}</p>")
|
| 245 |
+
return spinner.value, "An error occurred during analysis."
|
| 246 |
+
|
| 247 |
run_button.click(
|
| 248 |
+
analyze_crypto,
|
| 249 |
inputs=[crypto, currency, days],
|
| 250 |
+
outputs=[spinner, report_output],
|
| 251 |
show_progress=True
|
| 252 |
)
|
| 253 |
|