Key Concepts
- Crew AI: A multi-agent framework for orchestrating autonomous AI agents.
- LLM (Large Language Model): Used for generating text and reasoning.
- Agents: Autonomous entities with specific roles, goals, and backstories.
- Tasks: Specific objectives assigned to agents.
- Tools: External resources (e.g., web search) that agents can use.
- Prompt Engineering: Crafting effective prompts to guide the LLM's behavior.
- Serper Dev Tool: A tool for accessing web search results.
- Ollama: A tool to run open-source large language models locally.
Building the First Agent (Property Researcher)
- Objective: Create an AI agent to research investment properties.
- Tools Used:
- Crew AI framework.
- Ollama to run the OpenHermes LLM locally.
- Langchain community for LLM integration.
- Serper Dev Tool for web searches.
- Steps:
- Import necessary libraries:
os,Agent,Task,Crewfromcrewai, andSerperDevToolfromcrewai_tools. Also importOllamafromlangchain_community.llms. - Define the agent:
- Role: Senior Property Researcher.
- Goal: Find promising investment properties.
- Backstory: Veteran property analyst specializing in retail properties in specific suburbs.
- LLM: OpenHermes (run locally using Ollama).
- Delegation: Set to
False.
- Instantiate the agent:
researcher = Agent(role=..., goal=..., backstory=..., llm=Ollama(model="openhermes"), allow_delegation=False).
- Import necessary libraries:
- Example: The agent is given the role of a "Senior Property Researcher" with the goal to "find promising investment properties."
Defining Tasks
- Objective: Define the specific task for the property researcher agent.
- Steps:
- Create a task:
- Description: Search the internet and find five promising real estate investment suburbs in Sydney, Australia. Highlight the mean, low, and max prices, rental yield, and potential factors.
- Expected Output: A detailed report of each suburb, including mean price, rental vacancy, rental yield, and background information.
- Agent: The previously defined
researcheragent.
- Instantiate the task:
task1 = Task(description=..., expected_output=..., agent=researcher).
- Create a task:
- Example: The task description instructs the agent to "search the internet and find five promising real estate investment suburbs in Sydney, Australia."
Setting Up the Crew
- Objective: Orchestrate the agent and task within a crew.
- Steps:
- Create a crew:
- Agents: A list containing the
researcheragent. - Tasks: A list containing the
task1. - Verbose: Set to
2for detailed output.
- Agents: A list containing the
- Instantiate the crew:
crew = Crew(agents=[researcher], tasks=[task1], verbose=2). - Kick off the crew:
task_output = crew.kickoff(). - Print the output:
print(task_output).
- Create a crew:
- Output File: The task output can be directed to a text file for easier access and management.
Giving the Crew Access to the Net (Using Tools)
- Objective: Enable the agent to access real-time information from the internet.
- Steps:
- Create a Search tool:
search_tool = SerperDevTool(). - Set the API key:
os.environ["SERPER_API_KEY"] = "YOUR_API_KEY". - Assign the tool to the agent:
researcher.tools = [search_tool].
- Create a Search tool:
- Note: An API key for Serper is required to use the web search tool.
Multitask and Multi-Agent Crews
- Objective: Expand the workflow to include a second agent and task for summarizing the research.
- Steps:
- Create a second agent (Writer):
- Role: Senior Property Analyst.
- Goal: Summarize property facts into a report for investors.
- Backstory: Real estate agent compiling property analytics.
- LLM: OpenHermes.
- Delegation: Set to
False.
- Create a second task (Summarization):
- Description: Summarize the property information for each suburb into a concise report.
- Expected Output: A formatted report with key details for each suburb.
- Agent: The newly defined
writeragent.
- Update the crew:
- Add the
writeragent to the list of agents. - Add the
task2to the list of tasks.
- Add the
- Kick off the crew:
task_output = crew.kickoff().
- Create a second agent (Writer):
- Example: The second agent, a "Senior Property Analyst," is tasked with summarizing the findings of the first agent into a report.
- Output: The final output includes both the initial research and the summarized report, each directed to separate text files.
Synthesis/Conclusion
The video demonstrates how to build an AI-powered investment property research bot using the Crew AI framework. By defining agents with specific roles, goals, and backstories, and assigning them tasks, the system can automate the process of finding and summarizing property data. The use of tools like the Serper Dev Tool allows the agents to access real-time information from the internet, while the multi-agent setup enables a more complex workflow with research and summarization steps. The key takeaway is that Crew AI provides a flexible and powerful platform for building autonomous AI systems that can perform complex tasks with minimal human intervention.
AI summaries can miss context or contain errors. Check important details against the original video.