Auto-Generated
Format Helpers
Provider-agnostic SSE content extraction and manipulation
Utility functions for extracting and setting text content in provider-specific SSE event formats and full response bodies.
from rdakt_ai import extract_sse_content, set_sse_content, extract_response_contentextract_sse_content
Extract text content from a parsed SSE event data dict.
def extract_sse_content(data: dict) -> str | NoneHandles all three provider formats:
| Provider | Path |
|---|---|
| OpenAI | choices[0].delta.content |
| Anthropic | delta.text (for content_block_delta events) |
| Gemini | candidates[0].content.parts[0].text |
Returns None if no text content is found.
set_sse_content
Set text content in a parsed SSE event data dict.
def set_sse_content(data: dict, content: str) -> dictModifies the dict in-place and returns it. Detects the provider format automatically.
extract_response_content
Extract text content from a full (non-streaming) response body.
def extract_response_content(body: dict) -> str | NoneHandles:
- OpenAI:
choices[0].message.content - Anthropic:
content[0].text - Gemini:
candidates[0].content.parts[0].text