Skip to content

Text Utils

Utility functions for text processing in Gen AI applications.

normalize_text(text)

Normalizes line endings to a single newline and strips outer whitespace.

CRLF and CR line endings are converted to a single newline. Internal whitespace, blank lines, and Unicode are preserved.

Parameters:

Name Type Description Default
text str

The text to normalize.

required

Returns:

Name Type Description
str str

The normalized text.