adk-multi-agent / app.py
charantejapolavarapu's picture
Update app.py
0d70ddf verified
Raw
History Blame Contribute Delete
1.51 kB
import gradio as gr
import time
class PlannerAgent:
def run(self, query):
return {
"goal": query,
"tasks": [
"Understand the topic",
"Collect important information",
"Generate final report"
]
}
class ResearchAgent:
def run(self, plan):
topic = plan["goal"]
research = f"""
Topic: {topic}
Key Points:
• Definition and overview
• Major applications
• Advantages
• Challenges
• Future scope
"""
return research
class WriterAgent:
def run(self, research):
report = f"""
# AI Generated Report
{research}
Conclusion:
This report summarizes the important aspects of the topic and provides a concise overview.
"""
return report
planner = PlannerAgent()
researcher = ResearchAgent()
writer = WriterAgent()
def multi_agent_workflow(query):
if not query.strip():
return "Please enter a topic."
plan = planner.run(query)
time.sleep(1)
research = researcher.run(plan)
time.sleep(1)
final_report = writer.run(research)
return final_report
demo = gr.Interface(
fn=multi_agent_workflow,
inputs=gr.Textbox(
lines=2,
placeholder="Enter any topic..."
),
outputs=gr.Markdown(),
title="Multi-Agent AI Research Assistant",
description="""
Planner Agent → Research Agent → Writer Agent
Enter a topic and the agents will collaborate to generate a report.
"""
)
demo.launch()