Skip to content
2 min read · 348 words

Interface: GenerationStats

Defined in: lib/types/dispatch_runner.ts:250

Provider-agnostic generation accounting for a single completed generation, emitted via DispatchExecutorHelpers.reportGenerationStats.

Remarks

Every field is optional so each battery supplies only what its wire format reports — OpenAI Chat Completions surfaces token counts (its usage block) but no wall-clock durations; Ollama's native /api/chat surfaces both token counts and nanosecond durations on its terminal chunk.

Durations are carried in their native nanosecond unit (the Ns suffix is load-bearing) and are never normalised here — normalising to milliseconds would be lossy and providers without durations would gain meaningless zeros. raw preserves the full provider-native stats object verbatim for forward-compatibility, so a subscriber can read a field this shape has not yet promoted to a typed member.

Extended by

Properties

PropertyTypeDescriptionDefined in
completionTokens?numberTokens in the completion / output (OpenAI usage.completion_tokens, Ollama eval_count).lib/types/dispatch_runner.ts:254
evalDurationNs?numberTime spent generating the response in nanoseconds (Ollama eval_duration).lib/types/dispatch_runner.ts:264
finishReason?stringWhy generation stopped (Ollama done_reason, OpenAI finish_reason).lib/types/dispatch_runner.ts:266
loadDurationNs?numberTime spent loading the model in nanoseconds (Ollama load_duration).lib/types/dispatch_runner.ts:260
model?stringModel identifier the provider echoed back.lib/types/dispatch_runner.ts:268
promptEvalDurationNs?numberTime spent evaluating the prompt in nanoseconds (Ollama prompt_eval_duration).lib/types/dispatch_runner.ts:262
promptTokens?numberTokens in the prompt / input (OpenAI usage.prompt_tokens, Ollama prompt_eval_count).lib/types/dispatch_runner.ts:252
provider?stringStable provider discriminator (e.g. 'ollama', 'openai_chat_completions').lib/types/dispatch_runner.ts:270
raw?Record<string, unknown>Full provider-native stats object, verbatim, for forward-compatibility.lib/types/dispatch_runner.ts:272
totalDurationNs?numberTotal wall-clock generation time in nanoseconds (Ollama total_duration).lib/types/dispatch_runner.ts:258
totalTokens?numberTotal tokens, when the provider reports a combined figure.lib/types/dispatch_runner.ts:256