Input Transformer
Modules concerning the input transformers used in Gen AI applications.
FilterEmptyInputTransformer()
Bases: BaseInputTransformer
An input transformer that filters out empty or whitespace-only message contents.
This transformer removes any message content that is an empty string or contains only whitespace characters.
transform(messages)
Transforms the input messages by filtering out empty or whitespace-only contents.
This method filters out any content within a message that is an empty string or contains only whitespace characters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list[Message]
|
The input messages for the language model. |
required |
Returns:
| Type | Description |
|---|---|
list[Message]
|
list[Message]: The transformed input messages with empty/whitespace contents removed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the message has no non-empty contents. |
IdentityInputTransformer()
Bases: BaseInputTransformer
An input transformer that transforms the input messages of a language model into an identity function.
This transformer simply returns the input messages as is.
transform(messages)
Transforms the input messages of a language model with an identity function.
This method simply returns the input messages as is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list[Message]
|
The input messages for the language model. |
required |
Returns:
| Type | Description |
|---|---|
list[Message]
|
list[Message]: The transformed input messages for the language model. |