Package org.mockserver.llm.realtime
Class RealtimeStreamingPhysics
java.lang.Object
org.mockserver.llm.realtime.RealtimeStreamingPhysics
Deterministic streaming-timing model for realtime WebSocket event codecs — the WebSocket-transport analogue
of the SSE
StreamingPhysics used by the HTTP LLM codecs.
It is intentionally simpler (and jitter-free) than the SSE physics so that emitted event sequences are
byte-for-byte reproducible in tests: every content delta is spaced by a uniform 1000 / tokensPerSecond
milliseconds, and the very first content delta additionally waits timeToFirstTokenMillis. Structural
events (session/response lifecycle, done markers) are emitted with no delay.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault emission rate (tokens per second) when none is configured. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RealtimeStreamingPhysicsdefaults()Physics with the default rate and no time-to-first-token delay.longintlongUniform per-delta delay in milliseconds, derived from the rate.
-
Field Details
-
DEFAULT_TOKENS_PER_SECOND
public static final int DEFAULT_TOKENS_PER_SECONDDefault emission rate (tokens per second) when none is configured.- See Also:
-
-
Constructor Details
-
RealtimeStreamingPhysics
public RealtimeStreamingPhysics(int tokensPerSecond, long timeToFirstTokenMillis)
-
-
Method Details
-
defaults
Physics with the default rate and no time-to-first-token delay. -
getTokensPerSecond
public int getTokensPerSecond() -
getTimeToFirstTokenMillis
public long getTimeToFirstTokenMillis() -
perTokenDelayMillis
public long perTokenDelayMillis()Uniform per-delta delay in milliseconds, derived from the rate.
-