eaglelandsonce commited on
Commit
8dd523e
1 Parent(s): d2ca388

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -1,7 +1,8 @@
1
- from crewai import *
2
  import gradio as gr
3
 
4
  def run_crew():
 
5
  researcher = Agent(
6
  role='Senior Research Analyst',
7
  goal='Uncover cutting-edge developments in AI and data science',
@@ -9,6 +10,7 @@ def run_crew():
9
  verbose=True,
10
  allow_delegation=False
11
  )
 
12
  writer = Agent(
13
  role='Tech Content Strategist',
14
  goal='Craft compelling content on tech advancements',
@@ -16,30 +18,40 @@ def run_crew():
16
  verbose=True,
17
  allow_delegation=False
18
  )
 
 
19
  task1 = Task(
20
  description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024...""",
21
  agent=researcher
22
  )
 
23
  task2 = Task(
24
  description="""Using the insights from the researcher's report, develop an engaging blog post...""",
25
  agent=writer
26
  )
 
 
27
  crew = Crew(
28
  agents=[researcher, writer],
29
  tasks=[task1, task2],
30
  verbose=2,
31
  process=Process.sequential
32
  )
 
 
33
  result = crew.kickoff()
34
  return result
35
 
 
 
 
36
 
37
  iface = gr.Interface(
38
- fn=run_crew,
39
- inputs=[],
40
  outputs="text",
41
  title="AI Research and Writing Crew",
42
- description="Run a crew of AI agents to perform research and writing tasks."
43
  )
44
 
45
  iface.launch()
 
1
+ from crewai import Agent, Task, Crew, Process
2
  import gradio as gr
3
 
4
  def run_crew():
5
+ # Define your agents with roles and goals
6
  researcher = Agent(
7
  role='Senior Research Analyst',
8
  goal='Uncover cutting-edge developments in AI and data science',
 
10
  verbose=True,
11
  allow_delegation=False
12
  )
13
+
14
  writer = Agent(
15
  role='Tech Content Strategist',
16
  goal='Craft compelling content on tech advancements',
 
18
  verbose=True,
19
  allow_delegation=False
20
  )
21
+
22
+ # Create tasks for your agents
23
  task1 = Task(
24
  description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024...""",
25
  agent=researcher
26
  )
27
+
28
  task2 = Task(
29
  description="""Using the insights from the researcher's report, develop an engaging blog post...""",
30
  agent=writer
31
  )
32
+
33
+ # Instantiate your crew with a sequential process
34
  crew = Crew(
35
  agents=[researcher, writer],
36
  tasks=[task1, task2],
37
  verbose=2,
38
  process=Process.sequential
39
  )
40
+
41
+ # Get your crew to work!
42
  result = crew.kickoff()
43
  return result
44
 
45
+ def wrapper():
46
+ """ Wrapper function for the button click. """
47
+ return run_crew()
48
 
49
  iface = gr.Interface(
50
+ fn=wrapper,
51
+ inputs=gr.inputs.Button(label="Run Crew"), # Button input
52
  outputs="text",
53
  title="AI Research and Writing Crew",
54
+ description="Click the button to run the crew of AI agents."
55
  )
56
 
57
  iface.launch()