Pipeline your multi-agent application with TaskingAI and CrewAI

June 14, 2024
Patrick Chen

What is Multi-Agent?

In artificial intelligence, the term "multi-agent" pertains to systems where multiple autonomous entities, referred to as agents, operate within a shared environment. These agents, which can be software programs or robots, make independent decisions to pursue specific objectives. They may cooperate to achieve a common goal or compete against one another in various scenarios. Multi-agent systems are utilized in contexts requiring collective behavior or strategic competition, such as in complex simulations, cooperative robotics, or interactive gaming environments.

What is CrewAI?

CrewAI is an advanced framework designed for managing autonomous AI agents in a collaborative setting. It allows users to create teams of AI agents, each equipped with unique tools and assigned specific sub-tasks. This enables the agents to work together efficiently to complete complex tasks, leveraging their combined intelligence and capabilities.

The benefit of Integrating TaskingAI with CrewAI

Integrating TaskingAI with CrewAI brings together the strengths of both systems to enhance AI agent performance. TaskingAI specializes in developing AI agents and standardizing APIs from various model providers and third-party plugin providers into one cohesive API, while CrewAI focuses on a narrower range of model and plugin providers and excels in facilitating collaborative intelligence among agents.

CrewAI users can benefit from TaskingAI through the following two means:

  1. Using TaskingAI as a gateway to integrate additional model providers into CrewAI, broadening the capabilities of the agent crews.
  2. Directly importing agents developed with TaskingAI as crew members in CrewAI (Recommended).

How to Integrate

Background:

CrewAI supports third-party models (must be compatible with standard OpenAI API schema) by specifying OpenAI base URL and OpenAI API keys. And TaskingAI will return OpenAI-API-formatted responses if the API call is made to 'https://oapi.tasking.ai'.

Example:

CrewAI uses a simple two-agent crew as a straightforward example to understand its framework. Here we will take the same example and check how to integrate TaskingAI in this example.In this example, the crew consists of two agents: a researcher responsible for researching the latest technologies, and a writer capable of transforming complex concepts into compelling narratives. Together, the crew will be able to write engaging blog posts about recent significant AI advancements.

1import os
2from crewai import Agent, Task, Crew, Process
3from crewai_tools import SerperDevTool
4from langchain_openai import ChatOpenAI
5os.environ["OPENAI_API_KEY"] = "$$YOUR_TASKINGAI_API_KEY"
6
7researcher_llm = ChatOpenAI(
8    model = "$$TASKINGAI_ASSISTANT_ID_FOR_RESEARCHER",
9    base_url = "http://oapi.tasking.ai")
10    
11writer_llm = ChatOpenAI(
12    model = "$$TASKINGAI_ASSISTANT_ID_FOR_WRITER",
13    base_url = "http://oapi.tasking.ai")
14
15# Define your agents with roles and goals
16researcher = Agent(
17  role='Senior Research Analyst',
18  goal='Uncover cutting-edge developments in AI and data science',
19  backstory="""You work at a leading tech think tank.
20  Your expertise lies in identifying emerging trends.
21  You have a knack for dissecting complex data and presenting actionable insights.""",
22  verbose=True,
23  allow_delegation=False,
24  llm=researcher_llm
25)
26writer = Agent(
27  role='Tech Content Strategist',
28  goal='Craft compelling content on tech advancements',
29  backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
30  You transform complex concepts into compelling narratives.""",
31  verbose=True,
32  allow_delegation=True,
33  llm=writer_llm
34)
35
36# Create tasks for your agents
37task1 = Task(
38  description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
39  Identify key trends, breakthrough technologies, and potential industry impacts.""",
40  expected_output="Full analysis report in bullet points",
41  agent=researcher
42)
43
44task2 = Task(
45  description="""Using the insights provided, develop an engaging blog
46  post that highlights the most significant AI advancements.
47  Your post should be informative yet accessible, catering to a tech-savvy audience.
48  Make it sound cool, avoid complex words so it doesn't sound like AI.""",
49  expected_output="Full blog post of at least 4 paragraphs",
50  agent=writer
51)
52
53# Instantiate your crew with a sequential process
54crew = Crew(
55  agents=[researcher, writer],
56  tasks=[task1, task2],
57  verbose=2, # You can set it to 1 or 2 to different logging levels
58)
59
60# Get your crew to work!
61result = crew.kickoff()
62
63print("######################")
64print(result)

In summary, the integration of TaskingAI with CrewAI offers a powerful synergy that enhances the capabilities of autonomous AI agents in collaborative settings. By combining TaskingAI's expertise in developing AI agents and standardizing APIs with CrewAI's focus on collaborative intelligence, developers can create highly efficient and versatile AI teams. As a result, the combined framework supports more robust, intelligent, and coordinated AI-driven solutions, whether for research, content creation, or other complex tasks. Embracing this integration can lead to more innovative and effective outcomes in various applications of artificial intelligence.

Previous post
No items
No items

On this page

©️ 2024 TaskingAI All Copyright Reserved