avatarLaxfed Paulacy

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2433

Abstract

hljs-keyword">from</span> crewai import Agent, Task, Crew

<span class="hljs-comment"># Create Agents with goal, role, backstory, and tools</span> idea_analyst = Agent( <span class="hljs-attribute">role</span>=<span class="hljs-string">"Senior Idea Analyst"</span>, goal= <span class="hljs-string">"Understand and expand upon the essence of ideas..."</span>, <span class="hljs-attribute">background_story</span>=<span class="hljs-string">"You're recognized as a thought leader..."</span>, <span class="hljs-attribute">verbose</span>=<span class="hljs-literal">True</span>, tools=[ SearchTools.search_internet, BrowserTools.scrape_and_summarize_website ] )

<span class="hljs-comment"># Create the tasks that will produce a fully formed idea proposal</span> expand_idea_task = Task( <span class="hljs-attribute">description</span>=<span class="hljs-string">"THIS IS A GREAT IDEA! Analyze it and conduct..."</span>, <span class="hljs-attribute">agent</span>=idea_analyst )

<span class="hljs-comment"># Create the crew that will produce a fully formed idea proposal</span> crew = Crew( agents=[idea_analyst, communications_strategist], # Other agents can be added tasks=[expand_idea_task, refine_idea_task], # Other tasks can be added <span class="hljs-attribute">verbose</span>=<span class="hljs-literal">True</span> )

final_improved_idea = crew.kickoff() # returns the final idea proposal</pre></div><p id="dc36">The above code snippet showcases the creation of agents, tasks, and the assembly of a crew to achieve a specific goal. This example illustrates the basic setup in CrewAI and the power it holds in customizing AI agent teams.</p><h2 id="a5a3">Customizing CrewAI</h2><p id="f928">CrewAI’s potential goes beyond the basic setup, allowing for extensive customization. For instance, you can mix and match different AI brains (LLMs) in your crew, integrate with external systems, and craft your own tools.</p><div id="90f0"><pre><span class="hljs-keyword">from</span> langchain.chat_models <span class="hljs-keyword">import</span> ChatOpenAI <span class="hljs-keyword">from</span> langchain.llms <span class="hljs-keyword">import</span> Ollama <span class="hljs-keyword">from</span> langchain.tools.yahoo_finance_news <span class="hljs-keyword">import</span> YahooFinanceNewsTool

stock_analyst = Agent( <span class="hljs-keyword">role</span>="Senior Stock Analyst", goal= "Report on stocks and analysis wit

Options

h suggestions ...", background_story="You're recognized as a major trader...", llm = Ollama(model="openhermes2.5-mistral"), # <span class="hljs-keyword">Using</span> <span class="hljs-keyword">local</span> model <span class="hljs-keyword">with</span> Ollama tools=[ YahooFinanceNewsTool() ], # <span class="hljs-keyword">Using</span> a LangChain tool <span class="hljs-keyword">verbose</span>=<span class="hljs-keyword">True</span> )</pre></div><p id="2d6f">In the above example, we see how CrewAI allows for the creation of specialized agents with unique roles and tools, tailored to specific tasks or objectives.</p><h2 id="339f">Understanding the Workings of CrewAI</h2><p id="e2ea">Behind the scenes, each CrewAI agent is essentially a LangChain agent, enhanced with a ReActSingleInputOutputParser, specially modified to support role-playing, incorporate a memory mechanism, and integrate with LangChain’s tools. Crews serve as a framework that encapsulates agents and tasks, facilitating their sequential execution of work.</p><h2 id="7cc1">Real Use Cases and Future Developments</h2><p id="1ba5">CrewAI has practical applications, from building landing pages to conducting complex idea analysis. It is set to evolve further, introducing more intricate processes and continuing to redefine the landscape of AI teamwork.</p><p id="6205">In conclusion, CrewAI stands as a powerful tool to assemble AI agents into cohesive, high-performing teams, offering practicality, adaptability, and user-friendly integration and customization options.</p><div id="8dee" class="link-block"> <a href="https://readmedium.com/langchain-can-benchmarking-agents-help-with-tool-use-a2c6b1ea30d8"> <div> <div> <h2>LANGCHAIN — Can Benchmarking Agents Help with Tool Use?</h2> <div><h3>The most dangerous phrase in the language is, ‘We’ve always done it this way.’ — Grace Hopper</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*nu7ZXSdSXeo6aCLEJYoZpg.jpeg)"></div> </div> </div> </a> </div><p id="582f">By exploring the core components and code snippets of CrewAI, you can begin to understand and harness the potential of AI agent teams within the LangChain framework.</p></article></body>

LANGCHAIN — Unleashed Future of AI Agent Teams?

Without requirements or design, programming is the art of adding bugs to an empty text file. — Louis Srygley

AI agents are becoming increasingly integral in problem-solving, creativity, and innovation. CrewAI, a multi-agent framework built on top of LangChain, is at the forefront of this transformation, enabling engineers to harness the collective power of AI agents. In this article, we’ll delve into the core components of CrewAI and explore code snippets to build and customize AI agent teams.

Components of CrewAI

CrewAI is built on the principle of simplicity through modularity, featuring the following main components:

  • Agents: Dedicated team members, each with their role, background story, goal, and memory.
  • Tools: Equipment used by agents to perform tasks efficiently.
  • Tasks: Small, focused missions for agents to accomplish.
  • Process: Workflow or strategy the crew follows to complete tasks.
  • Crew: Container layer where agents, tasks, and a process meet to carry out work.

By breaking down the intricate world of agents into these modular components, CrewAI makes it approachable, manageable, and fun to work with.

Building with CrewAI

Let’s explore the idea of a crew that can build a landing page from a single-line idea. We’ll start by creating agents, defining tasks, and then assembling them into a crew.

from crewai import Agent, Task, Crew

# Create Agents with goal, role, backstory, and tools
idea_analyst = Agent(
 role="Senior Idea Analyst",
 goal= "Understand and expand upon the essence of ideas...",
 background_story="You're recognized as a thought leader...",
 verbose=True,
 tools=[
   SearchTools.search_internet,
   BrowserTools.scrape_and_summarize_website
 ]
)

# Create the tasks that will produce a fully formed idea proposal
expand_idea_task = Task(
 description="THIS IS A GREAT IDEA! Analyze it and conduct...",
 agent=idea_analyst
)

# Create the crew that will produce a fully formed idea proposal
crew = Crew(
 agents=[idea_analyst, communications_strategist], # Other agents can be added
 tasks=[expand_idea_task, refine_idea_task], # Other tasks can be added
 verbose=True
)

final_improved_idea = crew.kickoff() # returns the final idea proposal

The above code snippet showcases the creation of agents, tasks, and the assembly of a crew to achieve a specific goal. This example illustrates the basic setup in CrewAI and the power it holds in customizing AI agent teams.

Customizing CrewAI

CrewAI’s potential goes beyond the basic setup, allowing for extensive customization. For instance, you can mix and match different AI brains (LLMs) in your crew, integrate with external systems, and craft your own tools.

from langchain.chat_models import ChatOpenAI
from langchain.llms import Ollama
from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool

stock_analyst = Agent(
 role="Senior Stock Analyst",
 goal= "Report on stocks and analysis with suggestions ...",
 background_story="You're recognized as a major trader...",
 llm = Ollama(model="openhermes2.5-mistral"), # Using local model with Ollama
 tools=[ YahooFinanceNewsTool() ], # Using a LangChain tool
 verbose=True
)

In the above example, we see how CrewAI allows for the creation of specialized agents with unique roles and tools, tailored to specific tasks or objectives.

Understanding the Workings of CrewAI

Behind the scenes, each CrewAI agent is essentially a LangChain agent, enhanced with a ReActSingleInputOutputParser, specially modified to support role-playing, incorporate a memory mechanism, and integrate with LangChain’s tools. Crews serve as a framework that encapsulates agents and tasks, facilitating their sequential execution of work.

Real Use Cases and Future Developments

CrewAI has practical applications, from building landing pages to conducting complex idea analysis. It is set to evolve further, introducing more intricate processes and continuing to redefine the landscape of AI teamwork.

In conclusion, CrewAI stands as a powerful tool to assemble AI agents into cohesive, high-performing teams, offering practicality, adaptability, and user-friendly integration and customization options.

By exploring the core components and code snippets of CrewAI, you can begin to understand and harness the potential of AI agent teams within the LangChain framework.

Langchain
Agent
ChatGPT
AI
Unleashed
Recommended from ReadMedium