Skip to main content

Module normalize

Module normalize 

Source
Expand description

Provider-Neutral Output Normalization

PSP-5 Phase 4: Extracts structured content (JSON objects, JSON arrays) from raw LLM responses regardless of provider-specific formatting quirks.

Supported extraction strategies (tried in order):

  1. Fenced JSON code block: json ...
  2. Generic fenced code block: ... containing JSON
  3. Direct JSON: response body starts with { or [
  4. Embedded JSON: first { to last matching } in wrapper text

The module is provider-agnostic by design. Provider family classification is available for diagnostics and telemetry but does not change extraction behavior.

Structs§

NormalizationError
Error returned when normalization cannot extract a JSON body.
NormalizedOutput
Result of a successful normalization.

Enums§

ExtractionMethod
Which extraction strategy succeeded.
ProviderFamily
Provider family for diagnostics and telemetry.

Functions§

extract_and_deserialize
Convenience: extract JSON and deserialize into T in one step.
extract_json
Extract a JSON body from a raw LLM response.