| 402 | // Sampler parameters. When the request omits a value, fall back to the |
| 403 | // model card's sampling defaults (spec §3.3); when the card doesn't |
| 404 | // supply one either, use the hard-coded default. |
| 405 | SamplerCfg parse_request_sampler(const json & body, |
| 406 | const SamplingDefaults & defaults) { |
| 407 | SamplerCfg sampler; |
| 408 | sampler.temp = body.value( |
| 409 | "temperature", defaults.has_temperature ? defaults.temperature : 0.0f); |
| 410 | sampler.top_p = body.value( |
| 411 | "top_p", defaults.has_top_p ? defaults.top_p : 1.0f); |
| 412 | sampler.top_k = body.value( |
| 413 | "top_k", defaults.has_top_k ? defaults.top_k : 0); |
| 414 | if (body.contains("seed")) { |
| 415 | sampler.seed = body["seed"].get<uint64_t>(); |
| 416 | } |
| 417 | |
| 418 | // OpenAI-style additive penalties. |
| 419 | sampler.freq_pen = body.value("frequency_penalty", 0.0f); |
| 420 | sampler.pres_pen = body.value( |
no outgoing calls
no test coverage detected