CrewAI
-
Techradar
Assess
-
Recommendation
Continue with assessment
NOTE: The use of CrewAI is under review.
Overview
CrewAI is a framework designed to coordinate role-playing, autonomous AI agents. It facilitates collaborative intelligence, enabling agents to work together efficiently on complex tasks.
Core Concepts
Agents
An agent is an autonomous unit programmed to:
- Perform tasks
- Make decisions
- Communicate with other agents
Think of an agent as a member of a team, with specific skills and a particular job to do. Agents can have different roles like 'Researcher', 'Writer', or 'Customer Support', each contributing to the overall goal of the crew.
Tools
- CrewAI comes with a number of tools, details of these can be found in the docs
- In addition to these tools, CrewAI supports all Langchain tools
SerperDevTool
Integrates with Serper, an external service that allows you to search Google.
ScrapeWebsiteTool
Allows your agent to access a given URL and extract its contents
Scrape any website:
Using the website_url property, restricts the scrape to a specific website:
WebsiteSearchTool
- RAG over a website
- Semantic search over the contents of a website
Custom tools
- Load customer data
- Tap into previous conversations etc…
Assigning tools
- Tools can be assigned to either an Agent or a Task
- If you give the tool to an agent, that agent can use the tool for any task
- If you give the tool to a task, the agent will only use that specific tool when performing that task
- Task tools override agent tools.
- For example, if an agent has 10 tools and a task has 3 tools, the agent will only use the 3 tools defined in the task
Tasks
Tasks can specify additional rules including:
- requiring human input
- output formats (JSON, File etc)
- set a callback
- set a context
- …
output as a JSON file | |
---|---|
human input required and asyncronous | |
---|---|
Context
To enable a task to use the output from other tasks use the context property:
Memory
The ability for the agent to remember what it has done, learn from it and apply that knowledge to future executions.
Memory System Components
-
Long term memory
- Exists even after the crew finishes
- This memory is stored in a local DB
- Can be used in future tasks
- Leads to self-improving agents
-
Short term memory
- Only exists during a crew execution
- Every time you kickoff a crew this memory is blank
- Memory - knowledge, activities and learnings are shared between all agents in the crew
- This is shared during the crew execution, before providing ‘task completion’
-
Entity memory
- Only exists during the crew execution
- Stores the subjects that are being discussed
- for example a specific company, the entity could store what it knows about that company in the entity memory
-
Contextual Memory
- Maintains the context of interactions by combining ShortTermMemory, LongTermMemory, and EntityMemory, aiding in the coherence and relevance of agent responses over a sequence of tasks or a conversation.
Enabling memory for the crew
- Enabling memory for the crew is simple. Just set memory=True when defining the crew:
Approaches / Tips
Role playing
Roles, goals and back story should be focused. Use specific keywords to refine output.
Focus
Use multiple agents each with a specific focused role.
Tools
Using too many tools can overload the LLM. Only provide the tools absolutely required for the task.
Collaboration
Allow the agents to talk to each other. This produces a better outcome.
Guardrails
CrewAI puts guardrails in place at the framework level (Further research is required around this).
QA Agent
- It is recommended to add a quality assurance agent at the end of the chain.
- This can improve the output significantly
For example: