cicboy commited on
Commit
56f4bfd
Β·
1 Parent(s): aa67901

update gradio UI

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -155,29 +155,32 @@ import time
155
  import gradio as gr
156
 
157
  def generate_blog(topic, tone, progress=gr.Progress(track_tqdm=True)):
 
158
  progress(0, desc="Starting collaborative report generation...")
159
- yield "🧭 Starting collaborative report generation...\n"
160
 
161
  # Step 1️⃣ Research Lead
162
  progress(0.25, desc="Research Lead generating outline...")
163
  plan_result = crew.tasks[0].run(inputs={"topic": topic, "tone": tone})
164
  yield f"### 🧠 Research Lead (Outline)\n{plan_result.output_text}\n\n---\n"
 
165
 
166
  # Step 2️⃣ Technical Writer
167
  progress(0.50, desc="Technical Writer drafting content...")
168
  write_result = crew.tasks[1].run(inputs={"topic": topic, "tone": tone}, context=[plan_result])
169
  yield f"### ✍️ Technical Writer (Draft)\n{write_result.output_text}\n\n---\n"
 
170
 
171
  # Step 3️⃣ Data Verifier
172
  progress(0.75, desc="Fact-checking underway...")
173
  fact_result = crew.tasks[2].run(inputs={"topic": topic, "tone": tone}, context=[write_result])
174
  yield f"### πŸ” Data Verifier (Fact-Checking)\n{fact_result.output_text}\n\n---\n"
 
175
 
176
  # Step 4️⃣ Editor-in-Chief
177
  progress(1.0, desc="Final editing and polish...")
178
  edit_result = crew.tasks[3].run(inputs={"topic": topic, "tone": tone}, context=[fact_result])
179
- yield f"### 🧾 Editor-in-Chief (Final Blog)\n{edit_result.output_text}"
180
-
181
 
182
  # Build Gradio Interface
183
  css = """
@@ -231,18 +234,13 @@ with gr.Blocks(css=css) as demo:
231
  value="academic"
232
  )
233
  fetch_btn = gr.Button("🌐 Fetch & Summarize Context", variant="secondary") # Rag Search
234
- context_output = gr.Markdown(label="πŸ“š Retrieved Context Summary")
235
- plan_output = gr.Markdown(label="πŸ“˜ Research Outline")
236
- write_output = gr.Markdown(label="πŸ“ Draft Report")
237
- fact_output = gr.Markdown(label="πŸ” Fact-Checked Version")
238
- edit_output = gr.Markdown(label="βœ… Final Blog") # Rag Search
239
-
240
 
241
  run_button = gr.Button("πŸš€ Generate Blog", variant="primary")
242
- output = gr.Textbox(label="πŸ“° Generated Blog Post", elem_id="output-box", lines=25, interactive=False, show_label=False)
243
 
244
  fetch_btn.click(fetch_context, inputs=[topic], outputs=[context_output]) # Rag Search
245
- run_button.click(generate_blog, inputs=[topic, tone], outputs=[plan_output, write_output, fact_output, edit_output])
246
 
247
  #Launch app
248
  if __name__=="__main__":
 
155
  import gradio as gr
156
 
157
  def generate_blog(topic, tone, progress=gr.Progress(track_tqdm=True)):
158
+ # initialize progress bar
159
  progress(0, desc="Starting collaborative report generation...")
160
+ yield "### 🧭 Starting Collaborative Report\n"
161
 
162
  # Step 1️⃣ Research Lead
163
  progress(0.25, desc="Research Lead generating outline...")
164
  plan_result = crew.tasks[0].run(inputs={"topic": topic, "tone": tone})
165
  yield f"### 🧠 Research Lead (Outline)\n{plan_result.output_text}\n\n---\n"
166
+ time.sleep(0.3)
167
 
168
  # Step 2️⃣ Technical Writer
169
  progress(0.50, desc="Technical Writer drafting content...")
170
  write_result = crew.tasks[1].run(inputs={"topic": topic, "tone": tone}, context=[plan_result])
171
  yield f"### ✍️ Technical Writer (Draft)\n{write_result.output_text}\n\n---\n"
172
+ time.sleep(0.3)
173
 
174
  # Step 3️⃣ Data Verifier
175
  progress(0.75, desc="Fact-checking underway...")
176
  fact_result = crew.tasks[2].run(inputs={"topic": topic, "tone": tone}, context=[write_result])
177
  yield f"### πŸ” Data Verifier (Fact-Checking)\n{fact_result.output_text}\n\n---\n"
178
+ time.sleep(0.3)
179
 
180
  # Step 4️⃣ Editor-in-Chief
181
  progress(1.0, desc="Final editing and polish...")
182
  edit_result = crew.tasks[3].run(inputs={"topic": topic, "tone": tone}, context=[fact_result])
183
+ yield f"### 🧾 Editor-in-Chief (Final Blog)\n{edit_result.output_text}\n\nβœ… **Report Complete!**"
 
184
 
185
  # Build Gradio Interface
186
  css = """
 
234
  value="academic"
235
  )
236
  fetch_btn = gr.Button("🌐 Fetch & Summarize Context", variant="secondary") # Rag Search
237
+ context_output = gr.Markdown(label="πŸ“š Retrieved Context Summary") # Rag Search
 
 
 
 
 
238
 
239
  run_button = gr.Button("πŸš€ Generate Blog", variant="primary")
240
+ final_output = gr.Textbox(label="πŸ“° Generated Blog Post", elem_id="output-box")
241
 
242
  fetch_btn.click(fetch_context, inputs=[topic], outputs=[context_output]) # Rag Search
243
+ run_button.click(generate_blog, inputs=[topic, tone], outputs=[final_output])
244
 
245
  #Launch app
246
  if __name__=="__main__":