Hello World to CrewAI
Previously we tried agent programming framework LangGraph. In this post, let’s say Hello to CrewAI. According to CrewAI website, it is “Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.”
TLDR: for sequential tasks, CrewAI is more intuitive to setup, especially on task, passing data between agents.
CrewAI Concepts
Steps
We are following this sample.
Setup LLM
import os
from dotenv import load_dotenv
load_dotenv()
from langchain_openai import AzureChatOpenAI
# Choose the LLM that will drive the agent
llm = AzureChatOpenAI(azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"), temperature=0, streaming=True)
Setup search tool
CrewAI supports langchain tools API.
from langchain_community.utilities import BingSearchAPIWrapper
from typing import Dict, List, Optional, Type, Union
from langchain_core.callbacks import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
class BingSearchInput(BaseModel):
"""Input for the Bing search tool."""
query: str = Field(description="search query to look up")
class BingSearchResults(BaseTool):
"""Tool that queries the Bing Search API and gets back json."""
name: str = "bing_search_results_json"
description: str = (
"A search engine optimized for comprehensive, accurate, and trusted results. "
"Useful for when you need to answer questions about current events. "
"Input should be a search query."
)
api_wrapper: BingSearchAPIWrapper = Field(default_factory=BingSearchAPIWrapper)
max_results: int = 5
args_schema: Type[BaseModel] = BingSearchInput
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> Union[List[Dict], str]:
"""Use the tool."""
try:
return self.api_wrapper.results(
query,
self.max_results,
)
except Exception as e:
return repr(e)
async def _arun(
self,
query: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> Union[List[Dict], str]:
"""Use the tool asynchronously."""
try:
return await self.api_wrapper.results_async(
query,
self.max_results,
)
except Exception as e:
return repr(e)
Setup Crew
from crewai import Agent, Task, Crew, Process
Define tool
tools = [BingSearchResults(max_results=2)]
Define agents
# Define your agents with roles and goals
recruitment_specialist = Agent(
role='Recruitment Specialist',
goal='Find suitable job candidates for various positions within the company',
backstory="""You are a recruitment specialist with expertise in identifying and attracting top talent
across various industries and roles.""",
llm=llm,
verbose=True,
allow_delegation=True,
tools=tools
)
hr_communicator = Agent(
role='HR Communications Coordinator',
goal='Communicate job openings and company culture to potential applicants',
backstory="""As an HR communications coordinator, you excel at crafting compelling job descriptions
and showcasing the company's values and culture to attract the right candidates.""",
llm=llm,
verbose=True,
allow_delegation=True
)
Define tasks
# Create tasks for your agents
task1 = Task(
description="""Identify current job openings in the field of software development using the available tool.
Focus on roles suitable for candidates with 1-3 years of experience.""",
agent=recruitment_specialist
)
task2 = Task(
description="""Based on the job openings identified, create engaging job descriptions and a recruitment
social media post. Emphasize the company's commitment to innovation and a supportive work environment.""",
agent=hr_communicator
)
Run
# Instantiate your crew with a sequential process (by default tasks are executed sequentially)
crew = Crew(
agents=[recruitment_specialist, hr_communicator],
tasks=[task1, task2],
verbose=2,
process=Process.sequential
)
# Kick off the crew to start on it's tasks
result = crew.kickoff()
print("######################")
print(result)
Result
[DEBUG]: Working Agent: Recruitment Specialist
[INFO]: Starting Task: Identify current job openings in the field of software development using the available tool.
Focus on roles suitable for candidates with 1-3 years of experience.
> Entering new CrewAgentExecutor chain...
Use Tool: bing_search_results_json, Input: "software development job openings for candidates with 1-3 years of experience"
[{'snippet': 'Browse 2,839,118 <b>1 YEAR EXPERIENCE SOFTWARE</b> DEVELOPER <b>jobs</b> ($90k-$151k) from companies near you with <b>job</b> <b>openings</b> that are hiring now and <b>1</b>-click apply! ... Top <b>3</b> Skills: <b>1</b>. <b>1</b> <b>year</b> <b>of experience</b> in Java /J2EE <b>development</b>, concurrency, middleware, and/or ... States with the most <b>job</b> <b>openings</b> for <b>1 Year Experience Software</b> Developer <b>jobs</b> include ...', 'title': '$90k-$151k 1 Year Experience Software Developer Jobs - ZipRecruiter', 'link': 'https://www.ziprecruiter.com/Jobs/1-Year-Experience-Software-Developer'}, {'snippet': '<b>Software</b> Engineer. Applied Test Systems 2.6. Butler, PA 16002. $90,000 - $110,000 a <b>year</b>. Full-time. Monday to Friday + 2. Easily apply. Embedded C++ <b>software</b> <b>development</b> <b>experience</b>. Create and support new or existing Microsoft Windows based <b>software</b> and embedded microprocessor machine control….', 'title': 'Software Developer Jobs, Employment | Indeed.com', 'link': 'https://www.indeed.com/q-Software-Developer-jobs.html'}]
Final Answer: Based on my search using the bing_search_results_json tool, I found several job openings in the field of software development suitable for candidates with 1-3 years of experience. One such opening is for 1 Year Experience Software Developer jobs on ZipRecruiter, with a salary range of $90k-$151k. Another opening is for a Software Engineer at Applied Test Systems in Butler, PA, with a salary range of $90,000 - $110,000 per year. These are just a few examples, and there are likely many more opportunities available.
> Finished chain.
[DEBUG]: [Recruitment Specialist] Task output: Based on my search using the bing_search_results_json tool, I found several job openings in the field of software development suitable for candidates with 1-3 years of experience. One such opening is for 1 Year Experience Software Developer jobs on ZipRecruiter, with a salary range of $90k-$151k. Another opening is for a Software Engineer at Applied Test Systems in Butler, PA, with a salary range of $90,000 - $110,000 per year. These are just a few examples, and there are likely many more opportunities available.
[DEBUG]: Working Agent: HR Communications Coordinator
[INFO]: Starting Task: Based on the job openings identified, create engaging job descriptions and a recruitment
social media post. Emphasize the company's commitment to innovation and a supportive work environment.
> Entering new CrewAgentExecutor chain...
Use Tool: Delegate work to co-worker
Coworker: Recruitment Specialist
Task: Create engaging job descriptions and a recruitment social media post for the software development positions
Context: Based on my search using the bing_search_results_json tool, I found several job openings in the field of software development suitable for candidates with 1-3 years of experience. One such opening is for 1 Year Experience Software Developer jobs on ZipRecruiter, with a salary range of $90k-$151k. Another opening is for a Software Engineer at Applied Test Systems in Butler, PA, with a salary range of $90,000 - $110,000 per year. These are just a few examples, and there are likely many more opportunities available. The job descriptions and social media post should emphasize the company's commitment to innovation and a supportive work environment.
> Entering new CrewAgentExecutor chain...
Use Tool: bing_search_results_json
{
"search_query": "software development job descriptions",
"num_results": 1
}
[{'snippet': 'Typing.com is a free<b> typing</b> program that offers engaging lessons, tests, and games for students of all skill levels. It also includes digital citizenship, coding, and career prep curriculum, as well as district and school management tools for teachers and admins.', 'title': 'Learn to Type | Type Better | Type Faster - Typing.com', 'link': 'https://www.typing.com/'}, {'snippet': 'TypingClub is a web-based program that teaches you how to<b> type</b> with fun and interactive lessons, games, videos and challenges. You can choose from different<b> typing</b> plans, languages and accessibility options, and track your progress with stars, badges and playback.', 'title': 'Learn Touch Typing Free - TypingClub', 'link': 'https://www.typingclub.com/'}]
Final Answer:
Job Description: Software Developer
We are seeking a talented and motivated Software Developer to join our innovative team. As a Software Developer, you will be responsible for designing, coding, and modifying software applications according to client specifications. You will collaborate with cross-functional teams to develop high-quality software solutions that meet customer needs.
Responsibilities:
- Develop software applications using programming languages such as Java, C++, or Python
- Collaborate with business analysts and software architects to understand client requirements and translate them into technical specifications
- Write clean, efficient, and maintainable code
- Conduct thorough testing and debugging of software applications
- Collaborate with cross-functional teams to ensure software solutions meet customer needs
- Stay up-to-date with industry trends and technologies to continuously improve software development processes
Requirements:
- Bachelor's degree in Computer Science or a related field
- 1-3 years of experience in software development
- Proficiency in programming languages such as Java, C++, or Python
- Strong problem-solving and analytical skills
- Excellent communication and teamwork abilities
- Ability to work independently and meet deadlines
We offer a competitive salary range of $90,000 - $151,000 per year, commensurate with experience and qualifications. In addition, we provide a supportive work environment that fosters innovation and professional growth.
If you are passionate about software development and want to be part of a dynamic team, we would love to hear from you. Apply now and take the next step in your career!
Social Media Post:
Join our innovative team as a Software Developer! We are looking for talented individuals with 1-3 years of experience in software development. If you have a passion for coding and want to work in a supportive and innovative environment, this is the perfect opportunity for you. Competitive salary range of $90k-$151k per year. Apply now and take the next step in your career! #softwaredeveloper #coding #innovation #careeropportunity
> Finished chain.
Job Description: Software Developer
We are seeking a talented and motivated Software Developer to join our innovative team. As a Software Developer, you will be responsible for designing, coding, and modifying software applications according to client specifications. You will collaborate with cross-functional teams to develop high-quality software solutions that meet customer needs.
Responsibilities:
- Develop software applications using programming languages such as Java, C++, or Python
- Collaborate with business analysts and software architects to understand client requirements and translate them into technical specifications
- Write clean, efficient, and maintainable code
- Conduct thorough testing and debugging of software applications
- Collaborate with cross-functional teams to ensure software solutions meet customer needs
- Stay up-to-date with industry trends and technologies to continuously improve software development processes
Requirements:
- Bachelor's degree in Computer Science or a related field
- 1-3 years of experience in software development
- Proficiency in programming languages such as Java, C++, or Python
- Strong problem-solving and analytical skills
- Excellent communication and teamwork abilities
- Ability to work independently and meet deadlines
We offer a competitive salary range of $90,000 - $151,000 per year, commensurate with experience and qualifications. In addition, we provide a supportive work environment that fosters innovation and professional growth.
If you are passionate about software development and want to be part of a dynamic team, we would love to hear from you. Apply now and take the next step in your career!
Social Media Post:
Join our innovative team as a Software Developer! We are looking for talented individuals with 1-3 years of experience in software development. If you have a passion for coding and want to work in a supportive and innovative environment, this is the perfect opportunity for you. Competitive salary range of $90k-$151k per year. Apply now and take the next step in your career! #softwaredeveloper #coding #innovation #careeropportunity
Final Answer:
Job Description: Software Developer
We are seeking a talented and motivated Software Developer to join our innovative team. As a Software Developer, you will be responsible for designing, coding, and modifying software applications according to client specifications. You will collaborate with cross-functional teams to develop high-quality software solutions that meet customer needs.
Responsibilities:
- Develop software applications using programming languages such as Java, C++, or Python
- Collaborate with business analysts and software architects to understand client requirements and translate them into technical specifications
- Write clean, efficient, and maintainable code
- Conduct thorough testing and debugging of software applications
- Collaborate with cross-functional teams to ensure software solutions meet customer needs
- Stay up-to-date with industry trends and technologies to continuously improve software development processes
Requirements:
- Bachelor's degree in Computer Science or a related field
- 1-3 years of experience in software development
- Proficiency in programming languages such as Java, C++, or Python
- Strong problem-solving and analytical skills
- Excellent communication and teamwork abilities
- Ability to work independently and meet deadlines
We offer a competitive salary range of $90,000 - $151,000 per year, commensurate with experience and qualifications. In addition, we provide a supportive work environment that fosters innovation and professional growth.
If you are passionate about software development and want to be part of a dynamic team, we would love to hear from you. Apply now and take the next step in your career!
Social Media Post:
Join our innovative team as a Software Developer! We are looking for talented individuals with 1-3 years of experience in software development. If you have a passion for coding and want to work in a supportive and innovative environment, this is the perfect opportunity for you. Competitive salary range of $90k-$151k per year. Apply now and take the next step in your career! #softwaredeveloper #coding #innovation #careeropportunity
> Finished chain.
[DEBUG]: [HR Communications Coordinator] Task output: Job Description: Software Developer
We are seeking a talented and motivated Software Developer to join our innovative team. As a Software Developer, you will be responsible for designing, coding, and modifying software applications according to client specifications. You will collaborate with cross-functional teams to develop high-quality software solutions that meet customer needs.
Responsibilities:
- Develop software applications using programming languages such as Java, C++, or Python
- Collaborate with business analysts and software architects to understand client requirements and translate them into technical specifications
- Write clean, efficient, and maintainable code
- Conduct thorough testing and debugging of software applications
- Collaborate with cross-functional teams to ensure software solutions meet customer needs
- Stay up-to-date with industry trends and technologies to continuously improve software development processes
Requirements:
- Bachelor's degree in Computer Science or a related field
- 1-3 years of experience in software development
- Proficiency in programming languages such as Java, C++, or Python
- Strong problem-solving and analytical skills
- Excellent communication and teamwork abilities
- Ability to work independently and meet deadlines
We offer a competitive salary range of $90,000 - $151,000 per year, commensurate with experience and qualifications. In addition, we provide a supportive work environment that fosters innovation and professional growth.
If you are passionate about software development and want to be part of a dynamic team, we would love to hear from you. Apply now and take the next step in your career!
Social Media Post:
Join our innovative team as a Software Developer! We are looking for talented individuals with 1-3 years of experience in software development. If you have a passion for coding and want to work in a supportive and innovative environment, this is the perfect opportunity for you. Competitive salary range of $90k-$151k per year. Apply now and take the next step in your career! #softwaredeveloper #coding #innovation #careeropportunity
######################
Job Description: Software Developer
We are seeking a talented and motivated Software Developer to join our innovative team. As a Software Developer, you will be responsible for designing, coding, and modifying software applications according to client specifications. You will collaborate with cross-functional teams to develop high-quality software solutions that meet customer needs.
Responsibilities:
- Develop software applications using programming languages such as Java, C++, or Python
- Collaborate with business analysts and software architects to understand client requirements and translate them into technical specifications
- Write clean, efficient, and maintainable code
- Conduct thorough testing and debugging of software applications
- Collaborate with cross-functional teams to ensure software solutions meet customer needs
- Stay up-to-date with industry trends and technologies to continuously improve software development processes
Requirements:
- Bachelor's degree in Computer Science or a related field
- 1-3 years of experience in software development
- Proficiency in programming languages such as Java, C++, or Python
- Strong problem-solving and analytical skills
- Excellent communication and teamwork abilities
- Ability to work independently and meet deadlines
We offer a competitive salary range of $90,000 - $151,000 per year, commensurate with experience and qualifications. In addition, we provide a supportive work environment that fosters innovation and professional growth.
If you are passionate about software development and want to be part of a dynamic team, we would love to hear from you. Apply now and take the next step in your career!
Social Media Post:
Join our innovative team as a Software Developer! We are looking for talented individuals with 1-3 years of experience in software development. If you have a passion for coding and want to work in a supportive and innovative environment, this is the perfect opportunity for you. Competitive salary range of $90k-$151k per year. Apply now and take the next step in your career! #softwaredeveloper #coding #innovation #careeropportunity