Expand description
Shared utilities for LLM request/response processing
This module provides common functions used across multiple providers to eliminate duplicate code and reduce allocations.
Functionsยง
- estimate_
token_ count - Estimate token count from string (rough approximation)
- extract_
reasoning_ content - Extract reasoning content from text (for providers that support reasoning)
- format_
llm_ error - Create a consistent error message for LLM errors
- parse_
chat_ request_ openai_ format - Parse chat request from OpenAI-compatible format
- parse_
response_ openai_ format - Parse response from OpenAI-compatible format
- parse_
stream_ event_ openai_ format - Parse stream event from OpenAI-compatible format
- truncate_
to_ token_ limit - Truncate string to approximate token limit
- validate_
model_ string - Validate that a model string is not empty and reasonable