pub struct ModelOptions {
pub temperature: Option<f32>,
pub max_tokens: Option<u32>,
pub extra: BTreeMap<String, Value>,
pub headers: BTreeMap<String, String>,
pub structured: Option<Value>,
}Expand description
Model options for one conversation.
Common parameters are provided as typed fields (temperature / max tokens,
where None means vendor default); vendor-specific or framework-unknown
parameters go into extra and request headers go
into headers — both are passed through to the
vendor verbatim, so users can reach new parameters and endpoint
requirements without waiting for a framework update:
use molo::ModelOptions;
let mut options = ModelOptions::default();
options.extra.insert("top_p".into(), serde_json::json!(0.9));
options.headers.insert("x-trace-id".into(), "abc-123".into());§Explicit settings win
When an extra key names a parameter the framework also manages
(temperature / max_tokens / response_format), the extra value is
the one sent: an explicitly written wire field is a deliberate override,
and the typed field is dropped for that request instead of being merged
(merging would emit the JSON key twice).
The request envelope is not a parameter: extra entries named messages /
tools (the conversation the framework is driving), stream /
stream_options (the delivery shape) and model (bound at provider
construction and reported in run summaries — a per-request override would
make those summaries name a model that did not answer) are ignored, since
they would replace the request rather than tune it.
Fields§
§temperature: Option<f32>Sampling temperature; None means vendor default.
max_tokens: Option<u32>Maximum number of tokens for the reply; None means vendor default.
extra: BTreeMap<String, Value>Vendor extension parameters: keys are wire request field names, serialized into the request body verbatim.
headers: BTreeMap<String, String>Extra HTTP request headers, sent by HTTP providers alongside the headers the framework sets itself.
For endpoints that require more than the request body: gateways and
proxies commonly route or trace by header (a tenant / project id, a
gateway token, an x-trace-id), and some vendors authenticate with a
header name of their own (api-key, x-api-key).
use molo::ModelOptions;
let mut options = ModelOptions::default();
options.headers.insert("api-key".into(), "secret".into());
options.headers.insert("x-trace-id".into(), "abc-123".into());§Semantics
- Names / values are taken as given (HTTP matches names
case-insensitively); an entry that is not a valid HTTP header is
reported by the provider as
ProviderError::Protocolrather than dropped silently, since a header that quietly never arrives is worse than a failed request. - An explicit
Authorizationwins over the provider’s api key: the endpoint sees the caller’s value and the provider does not add a bearer token of its own (twoAuthorizationheaders would be ambiguous — see the adapter’s request construction).Content-Typeis likewise the caller’s when set. - Transport-framing headers stay framework-owned:
Content-Length/Transfer-Encoding/Connection/Host/Upgradedescribe the request the framework actually sends, so entries with those names are ignored (a staleContent-Lengthcorrupts the framing of the body). - Values are masked in
Debugoutput (names stay visible), so a credential carried in a header does not leak through{:?}logging; the map itself still prints plainly for deliberate inspection.
Providers that do not speak HTTP ignore this field.
structured: Option<Value>Structured output: the final answer must be JSON conforming to this
JSON Schema document (the serialized RootSchema produced by
schemars, or a hand-written schema).
Two layers of semantics:
- Provider side: compatible endpoints receive it via
response_formatto best-effort constrain the model (the OpenAI-compatiblejson_schemashape; unsupported endpoints ignore it or error); - Agent side: the final answer is validated framework-side, and on mismatch the validation error is fed back to the model for a retry (counted against the turn budget by the agent runtime’s structured output support).
None = free-form text reply.
Trait Implementations§
Source§impl Clone for ModelOptions
impl Clone for ModelOptions
Source§fn clone(&self) -> ModelOptions
fn clone(&self) -> ModelOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more