> ## 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.text_compressors.TextCompressor

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

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

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

Defines a protocol for text compression to optimize agent interactions.

<b>Parameters:</b>

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

### Instance Methods

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

#### compress\_text

```python theme={null}
compress_text(
    self,
    text: str,
    **compression_params
) -> dict[str, Any]
```

This method takes a string as input and returns a dictionary containing the compressed text and other
relevant information. The compressed text should be stored under the 'compressed\_text' key in the dictionary.<br />To calculate the number of saved tokens, the dictionary should include 'origin\_tokens' and 'compressed\_tokens' keys.

<b>Parameters:</b>

| Name                   | Description   |
| ---------------------- | ------------- |
| `text`                 | **Type:** str |
| `**compression_params` |               |

<br />
