Description of the feature request:
I propose creating a TrimWhitespaceProcessor and adding it to the genai_processors/contrib/ directory. This processor would remove leading and trailing whitespace from incoming text-based ProcessorParts, which is a common text normalization task.
Proposed API:
- Location: genai_processors/contrib/trim_whitespace_processor.py
- Class: TrimWhitespaceProcessor
- Inherits from: PartProcessor
- Logic:
- If the part is text (is_text(part.mimetype)), it should apply .strip() to the text content.
- If the part is not text, it should be yielded unchanged.
What problem are you trying to solve with this feature?
Raw text data often contains extraneous whitespace, which can lead to issues in downstream processing:
- Inconsistent Matching: Text-based lookups or comparisons can fail. For example, "COMPLETE" would not
match "COMPLETE ".
- Tokenization Inefficiency: Language models may treat " text" and "text" as different tokens, leading
to inconsistent outputs and wasted resources.
- Silent Bugs: Conditional logic that depends on exact string matches can fail unexpectedly.
Adding a TrimWhitespaceProcessor provides a simple, reusable component to build more robust and reliable text-processing pipelines.
Any other information you'd like to share?
No response
Description of the feature request:
I propose creating a
TrimWhitespaceProcessorand adding it to thegenai_processors/contrib/directory. This processor would remove leading and trailing whitespace from incoming text-based ProcessorParts, which is a common text normalization task.Proposed API:
What problem are you trying to solve with this feature?
Raw text data often contains extraneous whitespace, which can lead to issues in downstream processing:
match "COMPLETE ".
to inconsistent outputs and wasted resources.
Adding a
TrimWhitespaceProcessorprovides a simple, reusable component to build more robust and reliable text-processing pipelines.Any other information you'd like to share?
No response