normalize_post_prompt

View as MarkdownOpen in Claude

Normalize a post-prompt body from either engine. Parses post_prompt_data with parse_post_prompt_data(), reads the log from call_log, raw_call_log, or raw_messages, and extracts the dialogue with dialogue_turns(), dropping the chat engine’s summary echo by comparing against the raw summary string.

Parameters

body
AnyRequired

The complete post-prompt request body.

Returns

NormalizedPostPrompt — Never raises. A body the function can’t make sense of yields one with empty fields.

Example

from signalwire.core.post_prompt import normalize_post_prompt
leg = normalize_post_prompt(raw_body)
if leg.dialogue:
store(leg.conversation_id, leg.medium, leg.summary, leg.dialogue)