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

# autogen.agentchat.contrib.capabilities.transforms.MessageTransform

<h2 id="autogen.agentchat.contrib.capabilities.transforms.MessageTransform" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">MessageTransform</span>
</h2>

```python theme={null}
MessageTransform(*args, **kwargs)
```

Defines a contract for message transformation.<br />Classes implementing this protocol should provide an `apply_transform` method
that takes a list of messages and returns the transformed list.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### apply\_transform

```python theme={null}
apply_transform(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]
```

Applies a transformation to a list of messages.<br />

<b>Parameters:</b>

| Name       | Description                                                                                      |
| ---------- | ------------------------------------------------------------------------------------------------ |
| `messages` | A list of dictionaries representing messages.<br /><br />**Type:** list\[dict\[str, typing.Any]] |

<b>Returns:</b>

| Type                          | Description                                                     |
| ----------------------------- | --------------------------------------------------------------- |
| list\[dict\[str, typing.Any]] | A new list of dictionaries containing the transformed messages. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_logs

```python theme={null}
get_logs(
    self,
    pre_transform_messages: list[dict[str, Any]],
    post_transform_messages: list[dict[str, Any]]
) -> tuple[str, bool]
```

Creates the string including the logs of the transformation

Alongside the string, it returns a boolean indicating whether the transformation had an effect or not.<br />

<b>Parameters:</b>

| Name                      | Description                                                                                                                |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `pre_transform_messages`  | A list of dictionaries representing messages before the transformation.<br /><br />**Type:** list\[dict\[str, typing.Any]] |
| `post_transform_messages` | A list of dictionaries representig messages after the transformation.<br /><br />**Type:** list\[dict\[str, typing.Any]]   |

<b>Returns:</b>

| Type              | Description                                                                                                |
| ----------------- | ---------------------------------------------------------------------------------------------------------- |
| tuple\[str, bool] | A tuple with a string with the logs and a flag indicating whether the transformation had an effect or not. |

<br />
