Deep learning intelligent agents are revolutionizing the concept of machine and technology around us. Cognitive systems are able to reason, decide, operate and even solve problems without human interferences. Unlike other forms of AI that mainly involve set programmed routines, autonomous agents can work on their own, or learn when to take action, and learn from operations that they come across. This new concept has the potential to change businesses and industries in a way where mundane repetitive tasks and the even the most sophisticated decision making processes can be improved. And as we progress further, these agents are expected to pose an even greater influence on the future of the AI and its usage .
CAMEL AI introduces a revolutionary framework designed for autonomous cooperation among communicative agents, enhancing their ability to solve complex tasks with minimal human intervention. By employing innovative role-playing techniques, CAMEL fosters efficient collaboration, paving the way for advanced applications in conversational AI and multi-agent systems.
Camel (“Communicative Agents for Mind Exploration of Large Scale Language Model Society”) AI is an advanced framework focused on the development and research of communicative, autonomous agents. Designed to explore the interactions and collaboration between AI systems, it aims to reduce the need for human intervention in task execution. With an emphasis on studying the behaviors, capabilities, and potential risks of multi-agent systems, CAMEL AI is an open-source initiative that encourages collaboration and innovation within the AI research community.
The CAMEL framework consists of several core modules essential for building and managing multi-agent systems:
In the following hands on tutorial, we create a multi agent system using CAMEL AI to automate fetching of locations of Coffee shops in a specific area along with the prices of coffee in these shops followed by crafting of promotional campaigns for each of these stores.
!pip install 'camel-ai[all]'
We will start with installing the CAMEL AI Python package.
import os
os.environ['OPENAI_API_KEY'] = ''
os.environ['GOOGLE_API_KEY'] =''
os.environ['TAVILY_API_KEY']=''
We will be needing the API Keys for Open AI, Google Maps (used for searching cafe locations) and Tavily (utilized for search functionality) here and hence we define them here.
from camel.agents.chat_agent import ChatAgent
from camel.messages.base import BaseMessage
from camel.models import ModelFactory
from camel.societies.workforce import Workforce
from camel.tasks.task import Task
from camel.toolkits import (
FunctionTool,
GoogleMapsToolkit,
SearchToolkit,
)
from camel.types import ModelPlatformType, ModelType
import nest_asyncio
nest_asyncio.apply()
We import all the necessary libraries here.
Additionally, nest_asyncio library is imported as well. In certain interactive environments (like Jupyter notebooks), an event loop might already be running (e.g., for the notebook’s interactivity). Without nest_asyncio, if we try to run another asynchronous task (execution of the agents in the next steps), it would throw an error because we cant run one event loop within another. By calling nest_asyncio.apply(), we allow nested asyncio operations that is running of multiple asynchronous tasks within an existing event loop.
def main():
#Define the Model for the Agent as well. Default model is "gpt-4o-mini" and model platform type is OpenAI
coffee_guide_agent_model = ModelFactory.create(
model_platform=ModelPlatformType.DEFAULT,
model_type=ModelType.DEFAULT,
)
#Define the Coffee Guide Agent with the pre-defined model and Google Maps Tool and Prompt
coffee_guide_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Cafe Specialist",
content="You are a Cafe Specialist",
),
model=coffee_guide_agent_model,
tools=GoogleMapsToolkit().get_tools()
)
#Define the web search tool for the Agent using Tavily (we need to define the Tavily API Key beforehand)
search_toolkit = SearchToolkit()
search_tools = [
FunctionTool(search_toolkit.tavily_search)]
#Define the Model for the Agent as well. Default model is "gpt-4o-mini" and model platform type is OpenAI
search_agent_model = ModelFactory.create(
model_platform=ModelPlatformType.DEFAULT,
model_type=ModelType.DEFAULT)
#Define the Coffee Craft Agent with the pre-defined model and tools and Prompt
coffee_craft_agent = ChatAgent(
system_message=BaseMessage.make_assistant_message(
role_name="Web searching agent",
content="You can CRAFT PROMOTIONAL CAMPAIGNs SPECIFICALLY FOR each of the CAFEs Based on its unique features",
),
model=search_agent_model,
tools=search_tools,
)
#Define the workforce that can take case of multiple agents
workforce = Workforce('A Cafe Recommender')
workforce.add_single_agent_worker(
"Cafe Specialist",
worker=coffee_guide_agent).add_single_agent_worker(
"Web searching agent",
worker=coffee_craft_agent)
# specify the task to be solved Defining the exact task needed
human_task = Task(
content=(
"Tell me about 2 major coffee shops with their details in Manhattan along with their locations and price of Cappuccino there. Also craft a PROMOTIONAL CAMPAIGN SPECIFICALLY FOR each of THE CAFEs Based on its unique features."
),
id='0',
)
task = workforce.process_task(human_task)
print('Final Result of Original task:\n', task.result)
The above code defines two agents: a coffee_guide_agent and a coffee_craft_agent , each with its respective model and tools (like Google Maps and Tavily for web searching). These agents are added to a Workforce that manages tasks.
In the Task, the exact problem to be solved is defined specifically like – “Tell me about 2 major coffee shops with their details in Manhattan along with their locations and price of Cappuccino there. Also craft a PROMOTIONAL CAMPAIGN SPECIFICALLY FOR each of THE CAFEs Based on its unique features.”.
The workforce is tasked with solving this problem. The task is processed by the workforce, and the final result is printed.
print(main())
Worker node 131955740124080 (Cafe Specialist) get task 0.0: Worker <131955740124080> should find and provide details about 2 major coffee shops in Manhattan, including their locations and the price of a Cappuccino. ====== Reply from Worker node 131955740124080 (Cafe Specialist): Worker node 131955740124464 (Web searching agent) get task 0.1: Worker <131955740124464> should conduct a web search to gather unique features of each cafe and craft a promotional campaign specifically for each based on those features. ====== Reply from Worker node 131955740124464 (Web searching agent):
### Major Coffee Shops in Manhattan 1. **Stumptown Coffee Roasters** - **Location:** 30 W 8th St, New York, NY 10011 - **Price of Cappuccino:** Approximately $5.00 - **Details:** Stumptown is known for its high-quality coffee and unique brewing methods. The atmosphere is cozy, making it a great spot for coffee lovers. 2. **Blue Bottle Coffee** - **Location:** 1 Rockefeller Plaza, New York, NY 10020 - **Price of Cappuccino:** Approximately $5.50 - **Details:** Blue Bottle is famous for its freshly roasted beans and meticulous brewing process. The shop has a modern aesthetic and offers a variety of coffee options. --- ### Promotional Campaigns #### For Stumptown Coffee Roasters **Campaign Name:** "Brewed to Perfection" **Unique Features:** - High-Quality Coffee: Known for unique roasting techniques that highlight distinct flavors. - Variety of Brewing Methods: Offers traditional espresso, pour-over, and cold brew. - Cozy Atmosphere: A welcoming space for coffee lovers to relax and enjoy. **Campaign Elements:** 1. **Social Media Challenge:** Encourage customers to share their favorite Stumptown brew methods on Instagram with the hashtag #BrewedToPerfection. 2. **Tasting Events:** Host monthly tasting events where customers can sample different brewing methods and learn about the unique flavors of Stumptown's coffee. 3. **Loyalty Program:** Introduce a loyalty program that rewards customers with free drink after a certain number of purchases, promoting repeat visits. 4. **Email Marketing:** Send out a monthly newsletter featuring brewing tips, new arrivals, and exclusive discounts for subscribers. --- #### For Blue Bottle Coffee **Campaign Name:** "Freshly Brewed Experience" **Unique Features:** - Commitment to Freshness: Beans are roasted in small batches and served within 48 hours. - Signature Blends: Offers a curated selection of unique blends with distinct flavor profiles. - Seasonal Offerings: Features location-specific and seasonal drinks and pastries. **Campaign Elements:** 1. **Freshness Guarantee:** Promote a campaign that guarantees customers the freshest coffee experience, with a satisfaction guarantee for first-time buyers. 2. **Seasonal Menu Launch:** Introduce a seasonal menu with limited-time offerings, encouraging customers to visit and try new flavors. 3. **Coffee Subscription Service:** Launch a subscription service that delivers freshly roasted coffee to customers’ doors, highlighting the freshness aspect. 4. **Interactive Workshops:** Organize workshops where customers can learn about the coffee-making process, from bean selection to brewing techniques, enhancing their appreciation for the craft. --- Both campaigns aim to leverage the unique features of each café to attract and retain customers, creating a community around their love for coffee.
As we can see from the output above, the first agent coffee_guide_agent helps in fetching and providing details about 2 major coffee shops – namely Stumptown Coffee Roasters & Blue Bottle Coffee in Manhattan, including their locations and the price of cappuccinos there.
Once the system identifies these coffee shops, the second agent, coffee_craft_agent, conducts a web search using the provided “search tools” to gather unique features of each cafe. It then crafts a promotional campaign for each cafe based on those features. As shown in the output above, the agent has created separate promotional campaigns for both Stumptown Coffee Roasters and Blue Bottle Coffee.
CAMEL AI is a major advancement in autonomous, communicative agents. It offers a robust framework for exploring multi-agent systems. CAMEL AI emphasizes minimal human intervention and scalability. Its open-source nature fosters innovation and encourages collaboration across the research community. The system’s core modules focus on task automation, memory management, and agent collaboration. CAMEL AI has the potential to revolutionize industries, from synthetic data generation to advanced model integrations. As it evolves, its ability to adapt and improve autonomously will drive further advancements in AI technology.
A. Multi-agent systems in CAMEL AI involve multiple AI agents working together to solve complex problems. They leverage collaboration and coordination to perform tasks efficiently.
A. Core modules in CAMEL AI include Models, Messages, Memory, Tools, Prompts, Tasks, Workforce, and Society, each serving a specific function for managing multi-agent systems.
A. Yes, CAMEL AI supports integration with over 20 advanced model platforms, both commercial and open-source, enhancing its flexibility and application potential.
A. The Workforce module is designed to build and manage teams of agents, enabling collaborative tasks and coordination between multiple agents within the system.
A. The Messages module handles communication protocols between agents, while the Tools module provides integrations for specialized tasks, such as web searching or using Google Maps
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.