|
@@ -1,7 +1,10 @@
|
|
# crewAI
|
|
# crewAI
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
## Usage
|
|
## Usage
|
|
|
|
|
|
|
|
+
|
|
```
|
|
```
|
|
pip install crewai
|
|
pip install crewai
|
|
pip install duckduckgo-search
|
|
pip install duckduckgo-search
|
|
@@ -14,8 +17,9 @@ os.environ["OPENAI_API_KEY"] = "YOUR KEY"
|
|
from langchain.tools import DuckDuckGoSearchRun
|
|
from langchain.tools import DuckDuckGoSearchRun
|
|
search_tool = DuckDuckGoSearchRun()
|
|
search_tool = DuckDuckGoSearchRun()
|
|
|
|
|
|
|
|
+# 定义一个拥有 DuckDuckGoSearchRun 搜索归纳功能的 Agent
|
|
researcher = Agent(
|
|
researcher = Agent(
|
|
- role='Senior Research Analyst',
|
|
|
|
|
|
+ role='Senior Research Analyst', # 高级研究分析师
|
|
goal='Uncover cutting-edge developments in AI and data science in',
|
|
goal='Uncover cutting-edge developments in AI and data science in',
|
|
backstory="""You work at a leading tech think tank.
|
|
backstory="""You work at a leading tech think tank.
|
|
Your expertise lies in identifying emerging trends.
|
|
Your expertise lies in identifying emerging trends.
|
|
@@ -23,12 +27,12 @@ researcher = Agent(
|
|
actionable insights.""",
|
|
actionable insights.""",
|
|
verbose=True,
|
|
verbose=True,
|
|
allow_delegation=False,
|
|
allow_delegation=False,
|
|
- tools=[search_tool],
|
|
|
|
- llm=ChatOpenAI(model_name="gpt-3.5", temperature=0.7)
|
|
|
|
|
|
+ tools=[search_tool]
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+# 定义一个
|
|
writer = Agent(
|
|
writer = Agent(
|
|
- role='Tech Content Strategist',
|
|
|
|
|
|
+ role='Tech Content Strategist', # 技术内容策略师
|
|
goal='Craft compelling content on tech advancements',
|
|
goal='Craft compelling content on tech advancements',
|
|
backstory="""You are a renowned Content Strategist, known for
|
|
backstory="""You are a renowned Content Strategist, known for
|
|
your insightful and engaging articles.
|
|
your insightful and engaging articles.
|
|
@@ -38,7 +42,7 @@ writer = Agent(
|
|
# (optional) llm=ollama_llm
|
|
# (optional) llm=ollama_llm
|
|
)
|
|
)
|
|
|
|
|
|
-# Create tasks for your agents
|
|
|
|
|
|
+# 任务一,通过 DuckDuckGoSearchRun 搜索引擎归纳关键词
|
|
task1 = Task(
|
|
task1 = Task(
|
|
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
|
|
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
|
|
Identify key trends, breakthrough technologies, and potential industry impacts.
|
|
Identify key trends, breakthrough technologies, and potential industry impacts.
|
|
@@ -46,6 +50,7 @@ task1 = Task(
|
|
agent=researcher
|
|
agent=researcher
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+# 任务二,基于任务一的归纳,写一篇博客
|
|
task2 = Task(
|
|
task2 = Task(
|
|
description="""Using the insights provided, develop an engaging blog
|
|
description="""Using the insights provided, develop an engaging blog
|
|
post that highlights the most significant AI advancements.
|
|
post that highlights the most significant AI advancements.
|
|
@@ -55,14 +60,14 @@ task2 = Task(
|
|
agent=writer
|
|
agent=writer
|
|
)
|
|
)
|
|
|
|
|
|
-# 多个agent,多个task,最后返回结果
|
|
|
|
|
|
+# 定义
|
|
crew = Crew(
|
|
crew = Crew(
|
|
agents=[researcher, writer],
|
|
agents=[researcher, writer],
|
|
tasks=[task1, task2],
|
|
tasks=[task1, task2],
|
|
verbose=2, # You can set it to 1 or 2 to different logging levels
|
|
verbose=2, # You can set it to 1 or 2 to different logging levels
|
|
)
|
|
)
|
|
|
|
|
|
-# Get your crew to work!
|
|
|
|
|
|
+# 执行
|
|
result = crew.kickoff()
|
|
result = crew.kickoff()
|
|
|
|
|
|
print("######################")
|
|
print("######################")
|