Spaces:
Runtime error
Runtime error
Commit
·
92cc30f
1
Parent(s):
8dd523e
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
from crewai import Agent, Task, Crew, Process
|
2 |
import gradio as gr
|
3 |
|
4 |
-
def run_crew():
|
5 |
-
# Define your agents
|
6 |
researcher = Agent(
|
7 |
role='Senior Research Analyst',
|
8 |
-
goal='Uncover cutting-edge developments
|
9 |
backstory="""You are a Senior Research Analyst at a leading tech think tank...""",
|
10 |
verbose=True,
|
11 |
allow_delegation=False
|
@@ -13,20 +13,29 @@ def run_crew():
|
|
13 |
|
14 |
writer = Agent(
|
15 |
role='Tech Content Strategist',
|
16 |
-
goal='Craft compelling content
|
17 |
backstory="""You are a renowned Tech Content Strategist...""",
|
18 |
verbose=True,
|
19 |
allow_delegation=False
|
20 |
)
|
21 |
|
22 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
task1 = Task(
|
24 |
-
description=
|
25 |
agent=researcher
|
26 |
)
|
27 |
|
28 |
task2 = Task(
|
29 |
-
description="
|
30 |
agent=writer
|
31 |
)
|
32 |
|
@@ -42,16 +51,13 @@ def run_crew():
|
|
42 |
result = crew.kickoff()
|
43 |
return result
|
44 |
|
45 |
-
|
46 |
-
""" Wrapper function for the button click. """
|
47 |
-
return run_crew()
|
48 |
-
|
49 |
iface = gr.Interface(
|
50 |
-
fn=
|
51 |
-
inputs=gr.inputs.
|
52 |
outputs="text",
|
53 |
title="AI Research and Writing Crew",
|
54 |
-
description="
|
55 |
)
|
56 |
|
57 |
iface.launch()
|
|
|
1 |
from crewai import Agent, Task, Crew, Process
|
2 |
import gradio as gr
|
3 |
|
4 |
+
def run_crew(topic):
|
5 |
+
# Define your agents
|
6 |
researcher = Agent(
|
7 |
role='Senior Research Analyst',
|
8 |
+
goal='Uncover cutting-edge developments',
|
9 |
backstory="""You are a Senior Research Analyst at a leading tech think tank...""",
|
10 |
verbose=True,
|
11 |
allow_delegation=False
|
|
|
13 |
|
14 |
writer = Agent(
|
15 |
role='Tech Content Strategist',
|
16 |
+
goal='Craft compelling content',
|
17 |
backstory="""You are a renowned Tech Content Strategist...""",
|
18 |
verbose=True,
|
19 |
allow_delegation=False
|
20 |
)
|
21 |
|
22 |
+
# Assign tasks based on the selected topic
|
23 |
+
if topic == "write short story":
|
24 |
+
task_description = "Write a captivating short story about a journey through a futuristic city."
|
25 |
+
elif topic == "write an article":
|
26 |
+
task_description = "Compose an insightful article on the latest trends in technology."
|
27 |
+
elif topic == "analyze stock":
|
28 |
+
task_description = "Perform a detailed analysis of recent trends in the stock market."
|
29 |
+
elif topic == "create a vacation":
|
30 |
+
task_description = "Plan a perfect vacation itinerary for a family trip to Europe."
|
31 |
+
|
32 |
task1 = Task(
|
33 |
+
description=task_description,
|
34 |
agent=researcher
|
35 |
)
|
36 |
|
37 |
task2 = Task(
|
38 |
+
description=f"Use the findings from the researcher's task to develop a comprehensive report on '{topic}'.",
|
39 |
agent=writer
|
40 |
)
|
41 |
|
|
|
51 |
result = crew.kickoff()
|
52 |
return result
|
53 |
|
54 |
+
# Gradio Interface with Dropdown for Topic Selection
|
|
|
|
|
|
|
55 |
iface = gr.Interface(
|
56 |
+
fn=run_crew,
|
57 |
+
inputs=gr.inputs.Dropdown(choices=["write short story", "write an article", "analyze stock", "create a vacation"], label="Select Topic"),
|
58 |
outputs="text",
|
59 |
title="AI Research and Writing Crew",
|
60 |
+
description="Select a topic and click the button to run the crew of AI agents."
|
61 |
)
|
62 |
|
63 |
iface.launch()
|