# ISessionTrimmingService

Namespace: **Wisej.AI.Services**

Assembly: **Wisej.AI** (3.5.0.0)

Provides functionality to trim messages in a session to reduce the number of tokens.

{% tabs %}
{% tab title="C#" %}

```csharp
public interface ISessionTrimmingService
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Interface ISessionTrimmingService
```

{% endtab %}
{% endtabs %}

## Properties

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) TrimmingPercentage

[Single](https://docs.microsoft.com/dotnet/api/system.single): Gets or sets the percentage of messages to remove (between 0.1 and 0.9).

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) TrimmingStrategy

[TrimmingStrategy](https://docs.wisej.com/ai/components/api/smartsession/wisej.ai.smartsession.trimmingstrategy): Gets or sets the strategy for handling context overflow.

## Methods

### ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FdLVsGEp1mKmjdHvG0Itk%2Finstance.png?alt=media\&token=0061ee96-c913-420d-aa2f-daf782ca6a1d) TrimAsync(session, messages)

Trims the messages in the *session* to reduce the number of tokens.

| Parameter                                                                                                                                                                                                                                 | Type                                                                                                               | Description                                                                        |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| **session**                                                                                                                                                                                                                               | [SmartSession](https://docs.wisej.com/ai/components/api/smartsession)                                              | The SmartSession to be trimmed.                                                    |
| **messages** ![](https://1941161015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFjp24h5m0lgli5swqzhO%2Fuploads%2FBPFc5AMUqwkzAJdlTYv8%2Fbadge-optional.svg?alt=media\&token=38bdb20d-14b6-4aba-816f-833f010523df) | [MessageCollection](https://docs.wisej.com/ai/components/api/smartsession/wisej.ai.smartsession.messagecollection) | Message collection to be trimmed. If null, it uses the messages in the *session* . |

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task).

## Implemented By

| Name                                                                                                          | Description                                                                          |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [DefaultSessionTrimmingService](https://docs.wisej.com/api?q=wisej.ai.services.defaultsessiontrimmingservice) | Provides functionality to trim messages in a session to reduce the number of tokens. |
