> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.messages.base

<a id="camel.messages.base" />

<a id="camel.messages.base.BaseMessage" />

## BaseMessage

```python theme={"system"}
class BaseMessage:
```

Base class for message objects used in CAMEL chat system.

**Parameters:**

* **role\_name** (str): The name of the user or assistant role.
* **role\_type** (RoleType): The type of role, either :obj:`RoleType. ASSISTANT` or :obj:`RoleType.USER`.
* **meta\_dict** (Optional\[Dict\[str, Any]]): Additional metadata dictionary for the message.
* **content** (str): The content of the message.
* **video\_bytes** (Optional\[bytes]): Optional bytes of a video associated with the message. (default: :obj:`None`)
* **image\_list** (Optional\[List\[Union\[Image.Image, str]]]): Optional list of PIL Image objects or image URLs (strings) associated with the message. (default: :obj:`None`)
* **image\_detail** (`Literal["auto", "low", "high"]`): Detail level of the images associated with the message. (default: :obj:`auto`)
* **video\_detail** (`Literal["auto", "low", "high"]`): Detail level of the videos associated with the message. (default: :obj:`auto`)
* **parsed** (Optional\[Union\[Type\[BaseModel], dict]]): Optional object which is parsed from the content. (default: :obj:`None`)
* **reasoning\_content** (Optional\[str]): Optional reasoning trace associated with the message. (default: :obj:`None`)

<a id="camel.messages.base.BaseMessage.make_user_message" />

### make\_user\_message

```python theme={"system"}
def make_user_message(
    cls,
    role_name: str,
    content: str,
    meta_dict: Optional[Dict[str, str]] = None,
    video_bytes: Optional[bytes] = None,
    image_list: Optional[List[Union[Image.Image, str]]] = None,
    image_detail: Union[OpenAIVisionDetailType, str] = OpenAIVisionDetailType.AUTO,
    video_detail: Union[OpenAIVisionDetailType, str] = OpenAIVisionDetailType.LOW
):
```

Create a new user message.

**Parameters:**

* **role\_name** (str): The name of the user role.
* **content** (str): The content of the message.
* **meta\_dict** (Optional\[Dict\[str, str]]): Additional metadata dictionary for the message.
* **video\_bytes** (Optional\[bytes]): Optional bytes of a video associated with the message.
* **image\_list** (Optional\[List\[Union\[Image.Image, str]]]): Optional list of PIL Image objects or image URLs (strings) associated with the message.
* **image\_detail** (Union\[OpenAIVisionDetailType, str]): Detail level of the images associated with the message.
* **video\_detail** (Union\[OpenAIVisionDetailType, str]): Detail level of the videos associated with the message.

**Returns:**

BaseMessage: The new user message.

<a id="camel.messages.base.BaseMessage.make_assistant_message" />

### make\_assistant\_message

```python theme={"system"}
def make_assistant_message(
    cls,
    role_name: str,
    content: str,
    meta_dict: Optional[Dict[str, str]] = None,
    video_bytes: Optional[bytes] = None,
    image_list: Optional[List[Union[Image.Image, str]]] = None,
    image_detail: Union[OpenAIVisionDetailType, str] = OpenAIVisionDetailType.AUTO,
    video_detail: Union[OpenAIVisionDetailType, str] = OpenAIVisionDetailType.LOW
):
```

Create a new assistant message.

**Parameters:**

* **role\_name** (str): The name of the assistant role.
* **content** (str): The content of the message.
* **meta\_dict** (Optional\[Dict\[str, str]]): Additional metadata dictionary for the message.
* **video\_bytes** (Optional\[bytes]): Optional bytes of a video associated with the message.
* **image\_list** (Optional\[List\[Union\[Image.Image, str]]]): Optional list of PIL Image objects or image URLs (strings) associated with the message.
* **image\_detail** (Union\[OpenAIVisionDetailType, str]): Detail level of the images associated with the message.
* **video\_detail** (Union\[OpenAIVisionDetailType, str]): Detail level of the videos associated with the message.

**Returns:**

BaseMessage: The new assistant message.

<a id="camel.messages.base.BaseMessage.make_system_message" />

### make\_system\_message

```python theme={"system"}
def make_system_message(
    cls,
    content: str,
    role_name: str = 'System',
    meta_dict: Optional[Dict[str, str]] = None
):
```

Create a new system message.

**Parameters:**

* **content** (str): The content of the system message.
* **role\_name** (str): The name of the system role. (default: :obj:`"System"`)
* **meta\_dict** (Optional\[Dict\[str, str]]): Additional metadata dictionary for the message.

**Returns:**

BaseMessage: The new system message.

<a id="camel.messages.base.BaseMessage.create_new_instance" />

### create\_new\_instance

```python theme={"system"}
def create_new_instance(self, content: str):
```

Create a new instance of the :obj:`BaseMessage` with updated
content.

**Parameters:**

* **content** (str): The new content value.

**Returns:**

BaseMessage: The new instance of :obj:`BaseMessage`.

<a id="camel.messages.base.BaseMessage.__add__" />

### **add**

```python theme={"system"}
def __add__(self, other: Any):
```

Addition operator override for :obj:`BaseMessage`.

**Parameters:**

* **other** (Any): The value to be added with.

**Returns:**

Union\[BaseMessage, Any]: The result of the addition.

<a id="camel.messages.base.BaseMessage.__mul__" />

### **mul**

```python theme={"system"}
def __mul__(self, other: Any):
```

Multiplication operator override for :obj:`BaseMessage`.

**Parameters:**

* **other** (Any): The value to be multiplied with.

**Returns:**

Union\[BaseMessage, Any]: The result of the multiplication.

<a id="camel.messages.base.BaseMessage.__len__" />

### **len**

```python theme={"system"}
def __len__(self):
```

**Returns:**

int: The length of the content.

<a id="camel.messages.base.BaseMessage.__contains__" />

### **contains**

```python theme={"system"}
def __contains__(self, item: str):
```

Contains operator override for :obj:`BaseMessage`.

**Parameters:**

* **item** (str): The item to check for containment.

**Returns:**

bool: :obj:`True` if the item is contained in the content,
:obj:`False` otherwise.

<a id="camel.messages.base.BaseMessage.extract_text_and_code_prompts" />

### extract\_text\_and\_code\_prompts

```python theme={"system"}
def extract_text_and_code_prompts(self):
```

**Returns:**

Tuple\[List\[TextPrompt], List\[CodePrompt]]: A tuple containing a
list of text prompts and a list of code prompts extracted
from the content.

<a id="camel.messages.base.BaseMessage.from_sharegpt" />

### from\_sharegpt

```python theme={"system"}
def from_sharegpt(
    cls,
    message: ShareGPTMessage,
    function_format: Optional[FunctionCallFormatter[Any, Any]] = None,
    role_mapping = None
):
```

Convert ShareGPT message to BaseMessage or FunctionCallingMessage.
Note tool calls and responses have an 'assistant' role in CAMEL

**Parameters:**

* **message** (ShareGPTMessage): ShareGPT message to convert.
* **function\_format** (FunctionCallFormatter, optional): Function call formatter to use. (default: :obj:`HermesFunctionFormatter()`.
* **role\_mapping** (Dict\[str, List\[str, RoleType]], optional): Role mapping to use. Defaults to a CAMEL specific mapping.

**Returns:**

BaseMessage: Converted message.

<a id="camel.messages.base.BaseMessage.to_sharegpt" />

### to\_sharegpt

```python theme={"system"}
def to_sharegpt(self, function_format: Optional[FunctionCallFormatter] = None):
```

Convert BaseMessage to ShareGPT message

**Parameters:**

* **function\_format** (FunctionCallFormatter): Function call formatter to use. Defaults to Hermes.

<a id="camel.messages.base.BaseMessage.to_openai_message" />

### to\_openai\_message

```python theme={"system"}
def to_openai_message(self, role_at_backend: OpenAIBackendRole):
```

Converts the message to an :obj:`OpenAIMessage` object.

**Parameters:**

* **role\_at\_backend** (OpenAIBackendRole): The role of the message in OpenAI chat system.

**Returns:**

OpenAIMessage: The converted :obj:`OpenAIMessage` object.

<a id="camel.messages.base.BaseMessage.to_openai_system_message" />

### to\_openai\_system\_message

```python theme={"system"}
def to_openai_system_message(self):
```

**Returns:**

OpenAISystemMessage: The converted :obj:`OpenAISystemMessage`
object.

<a id="camel.messages.base.BaseMessage.to_openai_user_message" />

### to\_openai\_user\_message

```python theme={"system"}
def to_openai_user_message(self):
```

**Returns:**

OpenAIUserMessage: The converted :obj:`OpenAIUserMessage` object.

<a id="camel.messages.base.BaseMessage.to_openai_assistant_message" />

### to\_openai\_assistant\_message

```python theme={"system"}
def to_openai_assistant_message(self):
```

**Returns:**

OpenAIAssistantMessage: The converted :obj:`OpenAIAssistantMessage`
object.

<a id="camel.messages.base.BaseMessage.to_dict" />

### to\_dict

```python theme={"system"}
def to_dict(self):
```

**Returns:**

dict: The converted dictionary.
