charantejapolavarapu commited on
Commit
0d70ddf
·
verified ·
1 Parent(s): c31a629

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -18
app.py CHANGED
@@ -1,30 +1,77 @@
1
  import gradio as gr
 
2
 
3
- def planner(query):
4
- return f"Plan for: {query}"
 
 
 
 
 
 
 
 
5
 
6
- def researcher(query):
7
- return f"Research collected for: {query}"
 
8
 
9
- def writer(research):
10
- return f"Final Report:\n\n{research}"
11
 
12
- def multi_agent(query):
13
- plan = planner(query)
14
- research = researcher(plan)
15
- result = writer(research)
16
- return result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  demo = gr.Interface(
19
- fn=multi_agent,
20
  inputs=gr.Textbox(
21
- label="Enter your topic"
22
- ),
23
- outputs=gr.Textbox(
24
- label="Generated Report"
25
  ),
26
- title="Multi-Agent AI System",
27
- description="Planner Researcher → Writer"
 
 
 
 
 
28
  )
29
 
30
  demo.launch()
 
1
  import gradio as gr
2
+ import time
3
 
4
+ class PlannerAgent:
5
+ def run(self, query):
6
+ return {
7
+ "goal": query,
8
+ "tasks": [
9
+ "Understand the topic",
10
+ "Collect important information",
11
+ "Generate final report"
12
+ ]
13
+ }
14
 
15
+ class ResearchAgent:
16
+ def run(self, plan):
17
+ topic = plan["goal"]
18
 
19
+ research = f"""
20
+ Topic: {topic}
21
 
22
+ Key Points:
23
+ Definition and overview
24
+ Major applications
25
+ Advantages
26
+ Challenges
27
+ • Future scope
28
+ """
29
+ return research
30
+
31
+ class WriterAgent:
32
+ def run(self, research):
33
+ report = f"""
34
+ # AI Generated Report
35
+
36
+ {research}
37
+
38
+ Conclusion:
39
+ This report summarizes the important aspects of the topic and provides a concise overview.
40
+ """
41
+ return report
42
+
43
+ planner = PlannerAgent()
44
+ researcher = ResearchAgent()
45
+ writer = WriterAgent()
46
+
47
+ def multi_agent_workflow(query):
48
+
49
+ if not query.strip():
50
+ return "Please enter a topic."
51
+
52
+ plan = planner.run(query)
53
+ time.sleep(1)
54
+
55
+ research = researcher.run(plan)
56
+ time.sleep(1)
57
+
58
+ final_report = writer.run(research)
59
+
60
+ return final_report
61
 
62
  demo = gr.Interface(
63
+ fn=multi_agent_workflow,
64
  inputs=gr.Textbox(
65
+ lines=2,
66
+ placeholder="Enter any topic..."
 
 
67
  ),
68
+ outputs=gr.Markdown(),
69
+ title="Multi-Agent AI Research Assistant",
70
+ description="""
71
+ Planner Agent → Research Agent → Writer Agent
72
+
73
+ Enter a topic and the agents will collaborate to generate a report.
74
+ """
75
  )
76
 
77
  demo.launch()