CrewAI
CrewAI
是一个基于LangChain
和LLM(大语言模型)
的智能协作平台,旨在帮助团队高效地完成任务。
它提供了一个易于使用的接口,使团队成员可以轻松地创建和管理任务,并与其他团队成员协作完成任务。
就像公司有各个部门(销售、工程、营销)在领导下共同努力实现业务目标一样,CrewAI 可帮助创建一个由具有专门角色的 AI 代理组成的组织,协作完成复杂的任务。
CrewAI
:https://www.crewai.com/
CrewAI Docs
: https://docs.crewai.com/introduction
特点
- 基于角色的代理: 创建具有明确角色、专业知识和目标的专业代理 - 从研究人员到分析师到作家。
- 灵活的工具: 为代理配备自定义工具和 API,以便与外部服务和数据源进行交互。
- 智能协作: 代理们共同协作,分享见解并协调任务以实现复杂的目标。
- 灵活优先级设置: 支持高、中、低多种任务优先级,方便团队根据重要程度合理安排工作。
- 任务管理: 定义顺序或并行工作流,使用代理自动处理任务依赖关系。
安装
注意事项
确保系统上安装的 Python 版本满足
>=3.10
且<3.13
的要求。
uv安装方式
此方式适合快速验证和部署。
# uv管理器安装
# curl -LsSf https://astral.sh/uv/install.sh | sh
# 安装
uv tool install crewai
# 验证
uv tool list
# or -> crewai --version
# 更新
uv tool install crewai --upgrade
pip安装方式
适合熟悉后进阶自定义使用
注意:crewai_tools 依赖于 crewai ,所以需要先安装 crewai ,再安装 crewai_tools
详细文档可参考 这里
# 安装
pip install crewai;
pip install 'crewai[tools]'
# or
# pip install crewai crewai_tools
# 验证
crewai --version
创建项目
初始化项目
运行 crewai CLI
命令来初始化项目:
#初始化项目
crewai create crew [Project Name]
-
可能遇到的问题及解决办法
: <<'END' Error fetching provider data: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /BerriAI/litellm/main/model_prices_and_context_window.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9d9140cce0>: Failed to establish a new connection: [Errno 111] Connection refused')) END
此错误通常是由网络问题导致的,解决办法包括更换网络、更换代理,或者使用以下命令跳过提供商数据获取:
crewai create crew [Project Name] --skip_provider
项目结构
执行上述命令后,将创建一个具有如下结构的新项目:
// 例如:crewai create crew my_project
my_project/
├── .gitignore
├── knowledge/
├── pyproject.toml
├── README.md
├── .env
└── src/
└── my_project/
├── __init__.py
├── main.py
├── crew.py
├── tools/
│ ├── custom_tool.py
│ └── __init__.py
└── config/
├── agents.yaml
└── tasks.yaml
项目包含以下基本文件
文件(File) | 目的(Purpose) |
---|---|
agents.yaml | 定义你的 AI 代理及其角色 Define your AI agents and their roles |
tasks.yaml | 设置代理任务和工作流程 Set up agent tasks and workflows |
.env | 存储 API 密钥和环境变量 Store API keys and environment variables |
main.py | 项目切入点和执行流程 Project entry point and execution flow |
crew.py | 机组人员编排和协调 Crew orchestration and coordination |
tools/ | 自定义代理工具目录 Directory for custom agent tools |
knowledge/ | 知识库目录 Directory for knowledge base |
在项目创建完成后,首先需要编辑 agents.yaml
和 tasks.yaml
来定义工作人员的行为,并将 API 密钥等敏感信息
保存到 .env
文件中。
[⚠️注意] 记得在.env中配置LLM的相关api_key,例如:OPENAI_API_KEY=sk-xxxx
[⚠️注意] 记得在.env中配置LLM的相关api_key,例如:OPENAI_API_KEY=sk-xxxx
[⚠️注意] 记得在.env中配置LLM的相关api_key,例如:OPENAI_API_KEY=sk-xxxx
项目运行
# 进入项目目录(例如:cd my_project)
cd [ProjectPath]
# 初始化
crewai install
# 运行
crewai run
一切正常的话,将得到类似以下内容(以下是项目初始化后的默认案例
内容):
Running the Crew
warning: `VIRTUAL_ENV=/home/dev/Desktop/pCrewAgent/service` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
╭────────────────────────────────────────────────────────────────────────────── Crew Execution Started ───────────────────────────────────────────────────────────────────────────────╮
│ │
│ Crew Execution Started │
│ Name: crew │
│ ID: a3d18ca2-fb53-4087-895d-ac577677b01d │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Status: Executing Task...
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Status: Executing Task...
└── 🤖 Agent: AI LLMs Senior Data Researcher
Status: In Progress
# Agent: AI LLMs Senior Data Researcher
## Task: Conduct a thorough research about AI LLMs Make sure you find any interesting and relevant information given the current year is 2025.
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Status: Executing Task...
└── 🤖 Agent: AI LLMs Senior Data Researcher
Status: In Progress
└── 🧠 Thinking...
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Status: Executing Task...
└── 🤖 Agent: AI LLMs Senior Data Researcher
Status: In Progress
# Agent: AI LLMs Senior Data Researcher
## Final Answer:
1. **Advancements in Efficiency**: AI LLMs have improved significantly in their computational efficiency, reducing the energy consumption of model training and inference dramatically. New algorithms and hardware innovations have emerged that allow these models to operate effectively on smaller devices, such as smartphones and edge computing units.
2. **Multimodal Capabilities**: Many leading LLMs now effectively incorporate multimodal data—integrating text, images, and audio—enabling them to perform complex tasks across different types of media. This enhancement has allowed for richer interactions in applications such as virtual assistants and automated content generation.
3. **Enhanced Fine-Tuning Techniques**: The development of more sophisticated fine-tuning techniques, including adaptability to individual user preferences and contextual understanding, has led to models that perform exceptionally well in niche domains, improving user experience and relevance of outputs.
4. **Generative Abilities in Code**: AI LLMs have become adept at generating high-quality code and assisting in software development. This has revolutionized how programmers work, with AI tools that can not only suggest code snippets but also debug and optimize existing code bases.
5. **AI Ethics and Compliance**: With advancements in AI LLMs, there is a stronger focus on ethical AI practices. Regulatory frameworks are being established to guide the development and deployment of these models, ensuring they align with societal values while protecting user privacy and preventing misuse.
6. **Contextual Learning**: New paradigms of context-aware learning have been developed, where AI LLMs adapt based on the context of the interaction rather than relying solely on pre-trained data. This allows for more personalized and relevant responses in real-time interactions.
7. **Collaborative AI Models**: The rise of collaborative AI LLMs has been noted, where models can share learned knowledge from a wide variety of sources while ensuring that privacy and intellectual property concerns are addressed. This collective intelligence model enhances the robustness and accuracy of AI-generated outputs.
8. **Integration with Other Technologies**: AI LLMs are increasingly being integrated with other emerging technologies such as blockchain for secure data transactions and augmented reality for immersive experiences. This fusion is expected to lead to novel applications that bridge the gap between the digital and physical worlds.
9. **Global Language Support**: AI LLMs now offer much better support for a wide range of languages, dialects, and cultural contexts. This has expanded their usability to non-English speaking populations, making AI assistance more universally accessible.
10. **Long-Term Memory Features**: The incorporation of long-term memory features in LLMs allows these systems to retain interactions and knowledge over longer periods, thus creating an ongoing relationship with users that can provide increasingly relevant support over time.
These developments reflect the rapid evolution in the field of AI LLMs, showcasing their growing capabilities and potential impact on various industries and society as a whole.
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Status: Executing Task...
└── 🤖 Agent: AI LLMs Senior Data Researcher
Status: ✅ Completed
🚀 Crew: crew
└── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
Assigned to: AI LLMs Senior Data Researcher
Status: ✅ Completed
└── 🤖 Agent: AI LLMs Senior Data Researcher
Status: ✅ Completed
╭────────────────────────────────────────────────────────────────────────────────── Task Completion ──────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Task Completed │
│ Name: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf │
│ Agent: AI LLMs Senior Data Researcher │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Status: Executing Task...
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Status: Executing Task...
└── 🤖 Agent: AI LLMs Reporting Analyst
Status: In Progress
# Agent: AI LLMs Reporting Analyst
## Task: Review the context you got and expand each topic into a full section for a report. Make sure the report is detailed and contains any and all relevant information.
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Status: Executing Task...
└── 🤖 Agent: AI LLMs Reporting Analyst
Status: In Progress
└── 🧠 Thinking...
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Status: Executing Task...
└── 🤖 Agent: AI LLMs Reporting Analyst
Status: In Progress
# Agent: AI LLMs Reporting Analyst
## Final Answer:
# Detailed Report on Recent Advancements in AI LLMs
## 1. Advancements in Efficiency
Recent developments in AI LLMs have significantly enhanced their computational efficiency, leading to a marked decrease in energy consumption during model training and inference. Innovations in algorithms and hardware have played a crucial role in this transformation. For instance, researchers are now employing more advanced mathematical techniques and training strategies that optimize resource usage without compromising on model performance. This shift not only allows for faster processing times but also makes it feasible to deploy sophisticated LLMs on smaller devices, including smartphones and edge computing units. The implications of this advancement are profound, enabling broader accessibility and making it easier to integrate AI LLMs into everyday applications, thus democratizing advanced AI technologies.
## 2. Multimodal Capabilities
The integration of multimodal data—encompassing text, images, and audio—into AI LLMs represents a leap forward in machine learning capabilities. Many leading models now deftly handle complex tasks across various media formats, enabling richer, more interactive experiences. For example, virtual assistants can utilize voice commands, respond with relevant graphics, and pull from text resources, all in a single interaction. This capability enriches user engagement and opens new avenues for automated content generation, such as enhanced storytelling and multimedia presentations. Furthermore, the ability to understand and generate content across different modalities fosters a more holistic approach to AI development, catering to diverse user preferences and needs.
## 3. Enhanced Fine-Tuning Techniques
The landscape of fine-tuning techniques for AI LLMs has evolved, introducing sophisticated methods aimed at optimizing models for specific user preferences or contextual understanding. These enhancements allow for a more tailored user experience, improving the relevance and accuracy of model outputs in niche environments. By utilizing user feedback and interaction history, models can adapt their responses to better suit individual needs, resulting in increased satisfaction and efficiency. Such advancements also mean that domain-specific applications can leverage AI capabilities more effectively, whether in sectors like healthcare, finance, or entertainment.
## 4. Generative Abilities in Code
AI LLMs have dramatically transformed the software development landscape through their advanced generative capabilities. Today, these models can generate high-quality code efficiently, provide real-time assistance in coding tasks, and offer solutions for debugging and optimizing existing applications. For instance, programmers can rely on AI tools to suggest code snippets or troubleshoot issues, significantly speeding up development cycles and reducing errors. This evolution not only enhances productivity for developers but also empowers those with limited coding experience to create functional software, democratizing software development.
## 5. AI Ethics and Compliance
As AI LLMs evolve, the emphasis on ethical practices and regulatory compliance becomes increasingly critical. The introduction of regulatory frameworks aims to guide the responsible development and deployment of these models, ensuring alignment with societal values. Key issues being addressed include user privacy, bias mitigation, and mechanisms for preventing misuse. Organizations are increasingly prioritizing transparency, explaining how models make decisions and maintain data integrity. This focus on ethical considerations not only protects users but also fosters trust in AI technologies, which is vital for their widespread adoption.
## 6. Contextual Learning
Recent advancements in contextual learning paradigms allow AI LLMs to adapt their behaviors based on the context of interactions. This approach surpasses traditional methods that rely merely on pre-trained data, leading to more personalized and relevant responses. For example, a context-aware model can adjust its answers based on the user's previous queries or broader conversation themes, resulting in interactions that feel more intuitive and engaging. By implementing contextual learning, AI LLMs can significantly enhance user experiences by providing tailored responses that consider more than just keyword matching, ultimately fostering more meaningful engagement.
## 7. Collaborative AI Models
The emergence of collaborative AI LLMs acknowledges the potential of shared knowledge across systems. This collaborative model promotes the continuous learning of AI from diverse sources while addressing privacy and intellectual property concerns. By pooling knowledge, these models can produce outputs that are more robust and accurate, learning from a wider array of inputs than any single model could provide. This strategy enhances the prediction accuracy of AI applications and promotes an environment of shared innovation, where models collectively improve over time.
## 8. Integration with Other Technologies
AI LLMs are increasingly being integrated with a variety of emerging technologies, including blockchain for enhanced data security and augmented reality (AR) for immersive user experiences. Such integrations open new frontiers for applications, allowing for seamless interactions between the digital and physical realms. For instance, combining AI LLM capabilities with AR can lead to enhanced learning environments or more interactive gaming experiences. As these technologies converge, businesses are poised to leverage AI-driven solutions to create novel applications that cater to evolving consumer needs.
## 9. Global Language Support
One of the remarkable achievements in AI LLMs has been the substantial improvement in global language support. Models now cater to a diverse range of languages, dialects, and cultural contexts, promoting inclusivity and accessibility for non-English speaking populations. This broad support not only expands the usability of AI technologies but also aligns with efforts to ensure that AI benefits are distributed more equitably across societies. By accommodating various linguistic and cultural nuances, AI LLMs can provide assistance that resonates with users from different backgrounds, thereby enriching their overall experience.
## 10. Long-Term Memory Features
The integration of long-term memory features into AI LLMs provides a transformative experience for users, allowing these systems to retain interactions and knowledge over extended periods. This capability enables models to build ongoing relationships with users, delivering increasingly relevant support as they accumulate more context about user preferences and past interactions. Such developments empower AI systems to function as personalized assistants that evolve with the user's needs, ultimately enhancing satisfaction and trust in AI technologies over time.
These advancements in AI LLMs underscore the rapid evolution within this field, highlighting the broader implications for various industries and society. The potential impact of these developments is far-reaching, setting the stage for a future where AI is seamlessly integrated into daily life, delivering support that is efficient, personalized, and ethically sound.
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Status: Executing Task...
└── 🤖 Agent: AI LLMs Reporting Analyst
Status: ✅ Completed
🚀 Crew: crew
├── 📋 Task: ceff96c9-40c6-46cd-bd15-6502fa5bc7bf
│ Assigned to: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
│ └── 🤖 Agent: AI LLMs Senior Data Researcher
│
│ Status: ✅ Completed
└── 📋 Task: 96d8b4ec-411d-464d-89e9-34f2ec055a72
Assigned to: AI LLMs Reporting Analyst
Status: ✅ Completed
└── 🤖 Agent: AI LLMs Reporting Analyst
Status: ✅ Completed
╭────────────────────────────────────────────────────────────────────────────────── Task Completion ──────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Task Completed │
│ Name: 96d8b4ec-411d-464d-89e9-34f2ec055a72 │
│ Agent: AI LLMs Reporting Analyst │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────────────────────────────────── Crew Completion ──────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Crew Execution Completed │
│ Name: crew │
│ ID: a3d18ca2-fb53-4087-895d-ac577677b01d │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯