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
BaseMessageclass. - Creating a
BaseMessageinstance. - Understanding the properties of the
BaseMessageclass. - Using the methods of the
BaseMessageclass. - 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.ASSISTANTorRoleType.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
OpenAIMessageobject:
- Converting to an
OpenAISystemMessageobject:
- Converting to an
OpenAIUserMessageobject:
- Converting to an
OpenAIAssistantMessageobject:
- 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

