data/api/streaming
library
Functions
-
applyCacheBreakpoints(List<Map<String, dynamic>> messages, CacheConfig config)
→ List<Map<String, dynamic>>
-
Apply cache breakpoints to a list of message maps destined for the API.
-
applyCacheToSystem(List<Map<String, dynamic>> systemBlocks)
→ List<Map<String, dynamic>>
-
Apply cache control to a system prompt (list of system content blocks).
-
collectStreamToMessage(Stream<StreamUpdate> stream, {void onUpdate(StreamUpdate update)?})
→ Future<Message>
-
Consume a Stream<StreamUpdate> and assemble the final Message.
-
convertProviderStream(Stream<StreamEvent> providerStream)
→ Stream<StreamUpdate>
-
Convert the existing StreamEvent (from api_provider.dart) sequence
into the higher-level StreamUpdate sequence used by this module.
-
encodeImageContent(List<int> bytes, String mediaType)
→ Map<String, dynamic>
-
Encode raw image bytes for Anthropic API submission.
-
encodePdfContent(List<int> bytes)
→ Map<String, dynamic>
-
Encode raw PDF bytes for Anthropic API submission.
-
isNonRetryableStatus(int statusCode)
→ bool
-
Determine if an HTTP status code should NOT be retried.
-
isRetryableStatus(int statusCode)
→ bool
-
Determine if an HTTP status code is retryable.
-
mediaTypeFromBytes(List<int> bytes)
→ String?
-
Detect image media type from magic bytes.
-
mediaTypeFromExtension(String extension)
→ String?
-
Detect image media type from file extension.
-
parseStreamEventType(String raw)
→ StreamEventType?
-
Map raw SSE event type strings to StreamEventType.
-
processStream(Stream<List<int>> byteStream)
→ Stream<StreamUpdate>
-
Convenience: process a byte stream and yield StreamUpdates directly.
-
processStreamWithAssembler(Stream<List<int>> byteStream)
→ (Stream<StreamUpdate>, StreamAssembler)
-
Process an HTTP streaming response byte stream into StreamUpdates.
-
withStreamRetry<T>(Future<T> fn(), {int maxRetries = 3, Duration initialDelay = const Duration(seconds: 1), Duration maxDelay = const Duration(seconds: 30), bool shouldRetry(Object error)?})
→ Future<T>
-
Execute an async operation with exponential backoff and jitter.