cicboy commited on
Commit
5ddd7f1
·
1 Parent(s): 6aedb51

update gradio UI

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -151,25 +151,23 @@ def fetch_context(topic):
151
  return summary
152
 
153
  # Define Gradio Handler
154
- import time
155
- from datetime import datetime
156
  def generate_blog(topic, tone, progress=gr.Progress(track_tqdm=True)):
157
  progress(0, desc="Starting collaborative report generation...")
158
  yield "### 🧭 Starting Collaborative Report\n"
159
 
160
- # Run the entire crew sequentially and stream outputs
161
- stream = crew.kickoff_stream(inputs={"topic": topic, "tone": tone})
162
 
163
- # Stream each agent’s output as it arrives
164
- for event in stream:
165
- role = event.get("agent", "Agent")
166
- output = event.get("output", "")
167
- if output:
168
- timestamp = datetime.now().strftime("[%H:%M:S]")
169
- yield f"{timestamp} 🧩 **{role}**\n{output}\n\n---\n"
170
 
171
- progress(1.0, desc="Finalizing report...")
172
- yield "✅ **All agents have completed their work! Final blog generated.**"
173
 
174
  # Build Gradio Interface
175
  css = """
 
151
  return summary
152
 
153
  # Define Gradio Handler
 
 
154
  def generate_blog(topic, tone, progress=gr.Progress(track_tqdm=True)):
155
  progress(0, desc="Starting collaborative report generation...")
156
  yield "### 🧭 Starting Collaborative Report\n"
157
 
158
+ # Run the entire multi-agent workflow once (non-streaming)
159
+ result = crew.kickoff(inputs={"topic": topic, "tone": tone})
160
 
161
+ # Try to extract clean text output
162
+ if hasattr(result, "output"):
163
+ final_output = result.output
164
+ elif hasattr(result, "final_output"):
165
+ final_output = result.final_output
166
+ else:
167
+ final_output = str(result)
168
 
169
+ progress(1.0, desc="Completed.")
170
+ yield f"✅ **Collaborative Report Generated Successfully!**\n\n{final_output}"
171
 
172
  # Build Gradio Interface
173
  css = """