Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
|
@@ -214,8 +214,7 @@ crypto_analysis_crew = Crew(
|
|
| 214 |
# ----------------------
|
| 215 |
|
| 216 |
def generate_report(crypto_name, currency, days):
|
| 217 |
-
|
| 218 |
-
yield "⏳ Starting analysis...", None
|
| 219 |
|
| 220 |
crypto_inputs = {
|
| 221 |
"cryptocurrency_selection": crypto_name.lower(),
|
|
@@ -223,25 +222,29 @@ def generate_report(crypto_name, currency, days):
|
|
| 223 |
"days_selection": int(days),
|
| 224 |
}
|
| 225 |
|
| 226 |
-
|
| 227 |
-
|
|
|
|
| 228 |
"Fetching market data...",
|
| 229 |
"Fetching historical data...",
|
| 230 |
"Fetching sentiment...",
|
| 231 |
"Running analytics...",
|
| 232 |
"Generating trading strategy...",
|
| 233 |
-
"Producing final
|
| 234 |
-
]
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
# Run CrewAI (blocking)
|
| 238 |
result = crypto_analysis_crew.kickoff(inputs=crypto_inputs)
|
| 239 |
|
| 240 |
-
#
|
| 241 |
if isinstance(result, dict) and "final_output" in result:
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
yield "⚠️ Finished with raw output", str(result)
|
| 245 |
|
| 246 |
# ----------------------
|
| 247 |
# GRADIO APP
|
|
@@ -270,4 +273,5 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as app:
|
|
| 270 |
generate_report,
|
| 271 |
inputs=[crypto, currency, days],
|
| 272 |
outputs=[progress_message, report_output]
|
|
|
|
| 273 |
)
|
|
|
|
| 214 |
# ----------------------
|
| 215 |
|
| 216 |
def generate_report(crypto_name, currency, days):
|
| 217 |
+
import gradio as gr
|
|
|
|
| 218 |
|
| 219 |
crypto_inputs = {
|
| 220 |
"cryptocurrency_selection": crypto_name.lower(),
|
|
|
|
| 222 |
"days_selection": int(days),
|
| 223 |
}
|
| 224 |
|
| 225 |
+
progress = gr.Progress(track_tqdm=False)
|
| 226 |
+
|
| 227 |
+
steps = [
|
| 228 |
"Fetching market data...",
|
| 229 |
"Fetching historical data...",
|
| 230 |
"Fetching sentiment...",
|
| 231 |
"Running analytics...",
|
| 232 |
"Generating trading strategy...",
|
| 233 |
+
"Producing final report..."
|
| 234 |
+
]
|
| 235 |
+
|
| 236 |
+
# Loop over progress stages
|
| 237 |
+
for i, message in enumerate(steps, start=1):
|
| 238 |
+
progress(i / len(steps), message)
|
| 239 |
+
# We can't break up CrewAI tasks individually, but this at least updates UI
|
| 240 |
|
| 241 |
# Run CrewAI (blocking)
|
| 242 |
result = crypto_analysis_crew.kickoff(inputs=crypto_inputs)
|
| 243 |
|
| 244 |
+
# Return final result
|
| 245 |
if isinstance(result, dict) and "final_output" in result:
|
| 246 |
+
return result["final_output"]
|
| 247 |
+
return str(result)
|
|
|
|
| 248 |
|
| 249 |
# ----------------------
|
| 250 |
# GRADIO APP
|
|
|
|
| 273 |
generate_report,
|
| 274 |
inputs=[crypto, currency, days],
|
| 275 |
outputs=[progress_message, report_output]
|
| 276 |
+
show_progress=True
|
| 277 |
)
|