Spaces:
Sleeping
Sleeping
update gradio UI
Browse files
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
|
| 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 |
-
|
| 243 |
|
| 244 |
fetch_btn.click(fetch_context, inputs=[topic], outputs=[context_output]) # Rag Search
|
| 245 |
-
run_button.click(generate_blog, inputs=[topic, tone], outputs=[
|
| 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__":
|