Creating Your First Agent
You can also check this cookbook in colab here.
⭐ Star us on GitHub, join our Discord, or follow us on X
This notebook demonstrates how to set up and leverage CAMEL’s ability to use ChatAgent()
class.
In this notebook, you’ll explore:
-
CAMEL: A powerful multi-agent framework that enables Retrieval-Augmented Generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.
-
ChatAgent(): The class is a cornerstone of CAMEL.
Philosophical Bits
The ChatAgent()
class is a cornerstone of CAMEL 🐫. We design our agent with the spirit to answer the following question:
Can we design an autonomous communicative agent capable of steering the conversation toward task completion with minimal human supervision?
In our current implementation, we consider agents with the following key features:
-
Role: along with the goal and content specification, this sets the initial state of an agent, guiding the agent to take actions during the sequential interaction.
-
Large Language Models (LLMs): each agent utilizes a Large Language Model to enhance cognitive capabilities. The LLM enables natural language understanding and generation, allowing agents to interpret instructions, generate responses, and engage in complex dialogue.
-
Memory: in-context memory and external memory which allows the agent to infer and learn in a more grounded approach.
-
Tools: a set of functions that our agents can utilize to interact with the external world; essentially this gives embodiments to our agents.
-
Communication: our framework allows flexible and scalable communication between agents. This is fundamental for the critical research question.
-
Reasoning: we will equip agents with different planning and reward (critic) learning abilities, allowing them to optimize task completion in a more guided approach.
📦 Installation
🔑 Setting Up API Keys
You’ll need to set up your API keys for OpenAI.
Alternatively, Colab Secrets is a good way for managing API Keys and Tokens without needing to enter it every time.
Furthermore, you could use the secrets across Colab notebooks.
It needs just two simple steps:
- Add the API key or token to the Colab Secrets
- Grant the secret access to the current notebook
- Access the secret by uncommenting the following codeblock.
Quick Start
Let’s first play with a ChatAgent
instance by simply initialize it with a system message and interact with user messages.
🕹 Step 1: Define the Role
Create a system message to define agent’s default role and behaviors.
🕹 Step 2: Set up the Model
Use ModelFactory
to set up the backend model for agent, for more detailed model settings, please go to our model documentation.
Set ChatAgent
🕹 Step 3: Interact with the Agent with .step()
Advanced Features
🔧 Tool Usage
For more detailed tool settings, please go to our tools cookbook.
🧠 Memory
By default our agent is initialized with ChatHistoryMemory
, allowing agents to do in-context learning, though restricted by the finite window length.
Assume that you have followed the setup in Quick Start. Let’s first check what is inside its brain.
You may update/alter the agent’s memory with any externally provided message in the format of BaseMessage
; for example, use one new user message:
You can connect the agent with external database (as long-term memory) in which they can access and retrieve at each step. For more detailed memory settings, please go to our memory documentation.
Miscs
-
Setting the agent to its initial state.
-
Set the output language for the agent.
-
The
ChatAgent
class offers several useful initialization options, includingmodel_type
,model_config
,memory
,message_window_size
,token_limit
,output_language
,tools
, andresponse_terminators
.
Check chat_agent.py for detailed usage guidance.
🌟 Highlights
This notebook has guided you through setting up and exploring The CAMEL ChatAgent()
and it’s features.
Key tools utilized in this notebook include:
-
CAMEL: A powerful multi-agent framework that enables Retrieval-Augmented Generation and multi-agent role-playing scenarios, allowing for sophisticated AI-driven tasks.
-
ChatAgent(): The class is a cornerstone of CAMEL.
That’s everything: Got questions about 🐫 CAMEL-AI? Join us on Discord! Whether you want to share feedback, explore the latest in multi-agent systems, get support, or connect with others on exciting projects, we’d love to have you in the community! 🤝
Check out some of our other work:
-
🐫 Creating Your First CAMEL Agent free Colab
-
Graph RAG Cookbook free Colab
-
🧑⚖️ Create A Hackathon Judge Committee with Workforce free Colab
-
🔥 3 ways to ingest data from websites with Firecrawl & CAMEL free Colab
-
🦥 Agentic SFT Data Generation with CAMEL and Mistral Models, Fine-Tuned with Unsloth free Colab
Thanks from everyone at 🐫 CAMEL-AI
⭐ Star us on GitHub, join our Discord, or follow us on X