TextCompressor

TextCompressor(*args, **kwargs)

Defines a protocol for text compression to optimize agent interactions.

Parameters:
NameDescription
*args
**kwargs

Instance Methods

compress_text

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.
To calculate the number of saved tokens, the dictionary should include ‘origin_tokens’ and ‘compressed_tokens’ keys.

Parameters:
NameDescription
textType: str
**compression_params