微信扫码
与创始人交个朋友
我要投稿
“ 在工作流的每一个步骤,会涉及到不同的执行任务,每个执行任务对应的不同模型(有些是大语言模型,有些是垂直应用模型)和工具来完成,每一步的模型和工具可能都不一样,最终把这一系列的步骤串联起来,形成一条整合了多个工具和步骤的端到端工作流
Reflection-自我反思
Tool Use-工具调用
Planning-规划设计
Multi-agent collaboration-多智能体协同
网络搜索所有相关主题素材 ———> perplexity, metaso
整理,筛选根据自己认知增添内容———> ChatGPT4,llama 3
SEO 优化标题,优化表达,剔除错别字———> ChatGPT4
“
Reflection-自我反思
Tool Use-工具调用
Planning-规划设计
Multi-agent collaboration-多智能体协同
pip install crewai
import os
from crewai import Agent, Task, Crew
from crewai_tools import SerperDevTool
# 设置网络搜索工具serper 的 aoi 和模型 api
os.environ["SERPER_API_KEY"] = "Your Key" # serper.dev API key
os.environ["OPENAI_API_KEY"] = "Your Key"
# Loading Tools
search_tool = SerperDevTool()
role
角色,goal
目标,backstory
背景知识verbose
参数是设置是否详细回复,ture 就是回复更详细,细节更多,false 回复会更简洁allow_delegation
为 true 时, agent 会授权让其他 agent 来执行这项任务,为 false 就不授权其他 agent,就自己来执行tools
设置需要的工具,这里用的 serpermax_rpm
指每分钟支持的最大请求数 request per minutescache
设置是否支持缓存
# 定义 agents
researcher = Agent(
role='Senior Research Analyst',
goal='Uncover cutting-edge developments in AI and data science',
backstory=(
"You are a Senior Research Analyst at a leading tech think tank."
"Your expertise lies in identifying emerging trends and technologies in AI and data science."
"You have a knack for dissecting complex data and presenting actionable insights."
),
verbose=True,
allow_delegation=False,
tools=[search_tool],
max_rpm=100
)
writer = Agent(
role='Tech Content Strategist',
goal='Craft compelling content on tech advancements',
backstory=(
"You are a renowned Tech Content Strategist, known for your insightful and engaging articles on technology and innovation."
"With a deep understanding of the tech industry, you transform complex concepts into compelling narratives."
),
verbose=True,
allow_delegation=True,
tools=[search_tool],
cache=False, # Disable cache for this agent
)
description
参数,期待的输出expected_output
,设置需要的agent agent
,也可以设置human_input
,设置为 true 时,需要人类输入了才能继续执行下面的 task# 创建 task
task1 = Task(
description=(
"Conduct a comprehensive analysis of the latest advancements in AI in 2024."
"Identify key trends, breakthrough technologies, and potential industry impacts."
"Compile your findings in a detailed report."
"Make sure to check with a human if the draft is good before finalizing your answer."
),
expected_output='A comprehensive full report on the latest AI advancements in 2024, leave nothing out',
agent=researcher,
human_input=True,
)
task2 = Task(
description=(
"Using the insights from the researcher's report, develop an engaging blog post that highlights the most significant AI advancements."
"Your post should be informative yet accessible, catering to a tech-savvy audience."
"Aim for a narrative that captures the essence of these breakthroughs and their implications for the future."
),
expected_output='A compelling 3 paragraphs blog post formatted as markdown about the latest AI advancements in 2024',
agent=writer
)
# 创建 crew
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=2
)
# 调用 crew 进行回答
result = crew.kickoff()
print("######################")
print(result)
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-03-30
2024-04-26
2024-05-10
2024-04-12
2024-05-28
2024-05-14
2024-04-25
2024-07-18
2024-04-26
2024-05-06
2024-12-22
2024-12-21
2024-12-21
2024-12-21
2024-12-21
2024-12-20
2024-12-20
2024-12-19