Table of Contents

Class StreamDiagnosticsBuilder

Namespace
Mythosia.AI.Models.Streaming
Assembly
Mythosia.AI.Abstractions.dll

Fluent configurator for service-level streaming diagnostics. Each On* method registers an independent callback — only what you call gets wired up. Used by service.WithStreamDiagnostics(d => d.OnRawLine(...).OnComplete(...)). New diagnostic hooks can be added here in future versions without breaking existing callers, since adding methods to a class is purely additive.

public class StreamDiagnosticsBuilder
Inheritance
StreamDiagnosticsBuilder
Inherited Members

Methods

OnComplete(Action<StreamDiagnostics>)

Fires exactly once when the SSE reader exits — both on normal completion and on failure. Receives a StreamDiagnostics snapshot with lines read, characters accumulated, elapsed time, and the last raw line. Wire to telemetry to detect "stream died after N chunks" patterns.

public StreamDiagnosticsBuilder OnComplete(Action<StreamDiagnostics> callback)

Parameters

callback Action<StreamDiagnostics>

Returns

StreamDiagnosticsBuilder

OnRawLine(Action<string>)

Fires for every raw SSE line received from the response, before any provider-specific parsing. Wire to a Debug-level logger to see exactly what the server sent — useful when a self-hosted backend produces non-standard or truncated SSE lines.

public StreamDiagnosticsBuilder OnRawLine(Action<string> callback)

Parameters

callback Action<string>

Returns

StreamDiagnosticsBuilder