Skip to main content

Module sanitize

Module sanitize 

Source
Expand description

Strips the formatting a model wraps around its whole reply. Whether what is left is usable is the reply format’s question (reply), then the purpose’s own check (validate).

Functions§

sanitize_ambient_text
Removes, repeatedly, then trims: a code fence wrapping the whole text (optionally with a language tag), one matching pair of quotes wrapping it, and a conversational opener (“Yeah, let’s…”). A reply left with nothing but backticks (an empty fence) becomes “”, which callers already treat as no reply.