Serializes only non-default fields to a JSONValue object.
Minimum probability threshold.
Mirostat strategy (0=off,1=v1,2=v2).
Mirostat learning rate.
Mirostat target entropy.
Context window size; 0 = model default.
Max tokens to generate; 0 = unlimited.
Tokens considered for repeat penalty.
Penalty for repeated tokens.
Random seed; 0 = random.
Stop sequences; empty = disabled.
Sampling temperature (0 = deterministic).
Top-K sampling; 0 = disabled.
Nucleus sampling threshold.
OllamaOptions opts; opts.temperature = 0.8f; opts.num_ctx = 4096; opts.stop = ["<|end|>", "\n\n"];
// Default options serialize to an empty JSON object OllamaOptions def; auto j0 = def.toJson(); assert(j0.type == JSONType.object); assert(j0.objectNoRef.length == 0, "Default OllamaOptions should be empty"); // Only set fields appear in output OllamaOptions opts; opts.temperature = 0.5f; // 0.5 is exactly representable in float and double opts.top_k = 40; opts.num_ctx = 4096; opts.stop = ["<|end|>"]; auto j = opts.toJson(); assert(j["temperature"].type == JSONType.float_); assert(j["temperature"].floating == 0.5); // exact double comparison assert(j["top_k"].integer == 40); assert(j["num_ctx"].integer == 4096); assert(j["stop"].arrayNoRef[0].str == "<|end|>"); assert("top_p" !in j); assert("min_p" !in j); assert("repeat_penalty" !in j); assert("mirostat" !in j); // temperature = 0.0 is a valid explicit value and must be included OllamaOptions zeroTemp; zeroTemp.temperature = 0.0f; auto jz = zeroTemp.toJson(); assert("temperature" in jz); assert(jz["temperature"].floating == 0.0);
Typed options for controlling model generation behavior.
Only non-default (explicitly set) fields are serialized to JSON. Float fields use float.nan as the "unset" sentinel; integer fields use 0.