Skip to content

GenerationOptions

Options that control generation behavior across all response methods.

Interface

ts
interface GenerationOptions {
  temperature?: number;
  maximumResponseTokens?: number;
  sampling?: SamplingMode;
}
PropertyTypeDescription
temperaturenumberControls randomness. Higher = more varied.
maximumResponseTokensnumberMax tokens in the response.
samplingSamplingModeSampling strategy.

Usage

ts
await session.respond("prompt", {
  options: {
    temperature: 0.8,
    maximumResponseTokens: 500,
    sampling: SamplingMode.greedy(),
  },
});

SamplingMode

SamplingMode.greedy()

Deterministic sampling — always picks the most likely token.

ts
static greedy(): SamplingMode

SamplingMode.random()

Stochastic sampling with optional constraints.

ts
static random(options?: {
  top?: number;
  seed?: number;
  probabilityThreshold?: number;
}): SamplingMode
ParameterDescription
topTop-K: only consider the K most likely tokens
seedRandom seed for reproducible output
probabilityThresholdTop-P / nucleus: cumulative probability threshold

SamplingModeType

ts
type SamplingModeType = "greedy" | "random"

Released under the Apache 2.0 License.