This notebook demonstrates how to set up and leverage CAMEL’s ability to use
BaseMessage
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.
- BaseMessage: The base class for message objects used in the CAMEL chat system. It is designed to provide a consistent structure for the messages in the system and allow for easy conversion between different message types.
BaseMessage
class. The topics covered include:
- Introduction to the
BaseMessage
class. - Creating a
BaseMessage
instance. - Understanding the properties of the
BaseMessage
class. - Using the methods of the
BaseMessage
class. - Give message to
ChatAgent
📦 Installation
First, install the CAMEL package with all its dependencies:🔑 Setting Up API Keys
You’ll need to set up your API keys for OpenAI. This ensures that the tools can interact with external services securely.Give message to ChatAgent
directly
You can simply pass text message to ChatAgent
Give message to ChatAgent
via BaseMessage
For more complex message usage like multi-modal message, we suggest using BaseMessage
Creating a BaseMessage
Instance
To create a BaseMessage
instance, you need to provide the following arguments:
role_name
: The name of the user or assistant role.role_type
: The type of role, eitherRoleType.ASSISTANT
orRoleType.USER
.content
: The content of the message.meta_dict
: An metadata dictionary for the message.
video_bytes
: Optional bytes of a video associated with the message.image_list
: Optional list of PIL Image objects associated with the message.image_detail
: Detail level of the images associated with the message. Default is “auto”.video_detail
: Detail level of the videos associated with the message. Default is “low”.
BaseMessage
instance:
- Creating a user agent message:
- Creating an assistant agent message:
Using the Methods of the BaseMessage
Class
The BaseMessage
class offers several methods:
- Creating a new instance with updated content:
- Converting to an
OpenAIMessage
object:
- Converting to an
OpenAISystemMessage
object:
- Converting to an
OpenAIUserMessage
object:
- Converting to an
OpenAIAssistantMessage
object:
- Converting to a dictionary:
BaseMessage
instance into different message types depending on your needs.
Give BaseMessage
to ChatAgent
🌟 Highlights
This notebook has guided you through setting up and convertingBaseMessage
to different types of messages. These components play essential roles in the CAMEL chat system, facilitating the creation, management, and interpretation of messages with clarity.
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.
- BaseMessage: The base class for message objects used in the CAMEL chat system. It is designed to provide a consistent structure for the messages in the system and allow for easy conversion between different message types.
- 🐫 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