pub struct ModelSettings {
pub model: String,
pub inner: ModelSettingsInner,
}Expand description
Model settings configuration.
A ModelSettings always has a valid model string.
Use Option<ModelSettings> when no model is configured yet.
Fields§
§model: String§inner: ModelSettingsInnerImplementations§
Source§impl ModelSettings
impl ModelSettings
Sourcepub fn new(model: impl Into<String>) -> Self
pub fn new(model: impl Into<String>) -> Self
Create a new ModelSettings with the given model and default inner settings.
Sourcepub fn from_provider_model_str(s: &str) -> Result<Option<Self>, String>
pub fn from_provider_model_str(s: &str) -> Result<Option<Self>, String>
Parse a “provider/model” string (e.g. “anthropic/claude-sonnet-4”) into ModelSettings. Returns None if the format is invalid. For custom providers (prefixed with “custom_”), returns an OpenAICompatible provider with empty base_url/api_key — the caller must fill these from secrets/config. Parse “provider/model” string into ModelSettings. Returns Err with a descriptive message if the provider is not recognized. Returns Ok(None) if the input is empty or has no slash.
Sourcepub fn merge(&self, override_settings: &ModelSettings) -> Option<ModelSettings>
pub fn merge(&self, override_settings: &ModelSettings) -> Option<ModelSettings>
Merge base (workspace) model settings with agent/request-level overrides.
Provider resolution:
- If the override explicitly sets a provider (not the default OpenAI), the override’s provider and model are used.
- If only the base has a non-default provider and the override uses default OpenAI, the base’s provider AND model win — the override’s bare model name is ignored because it may not exist on the base provider.
- Otherwise, the override’s model wins if non-empty.
Scalar fields (temperature, max_tokens, etc.) use override if present, else base.
Returns None if the final model string is empty.
Trait Implementations§
Source§impl Clone for ModelSettings
impl Clone for ModelSettings
Source§fn clone(&self) -> ModelSettings
fn clone(&self) -> ModelSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelSettings
impl Debug for ModelSettings
Source§impl<'de> Deserialize<'de> for ModelSettings
impl<'de> Deserialize<'de> for ModelSettings
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ModelSettings
impl JsonSchema for ModelSettings
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more