Call models endpoint in models manager (#7616)

- Introduce `with_remote_overrides` and update
`refresh_available_models`
- Put `auth_manager` instead of `auth_mode` on `models_manager`
- Remove `ShellType` and `ReasoningLevel` to use already existing
structs
This commit is contained in:
Ahmed Ibrahim
2025-12-04 18:28:03 -08:00
committed by GitHub
parent 6736d1828d
commit 7b359c9c8e
13 changed files with 329 additions and 88 deletions

View File

@@ -86,28 +86,24 @@ pub enum ModelVisibility {
None,
}
/// Reasoning support level reported by the backend.
#[derive(
Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, TS, JsonSchema, EnumIter, Display,
)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum ReasoningLevel {
None,
Minimal,
Low,
Medium,
High,
XHigh,
}
/// Shell execution capability for a model.
#[derive(
Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, TS, JsonSchema, EnumIter, Display,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
TS,
JsonSchema,
EnumIter,
Display,
Hash,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ShellType {
pub enum ConfigShellToolType {
Default,
Local,
UnifiedExec,
@@ -126,9 +122,9 @@ pub struct ModelInfo {
pub display_name: String,
#[serde(default)]
pub description: Option<String>,
pub default_reasoning_level: ReasoningLevel,
pub supported_reasoning_levels: Vec<ReasoningLevel>,
pub shell_type: ShellType,
pub default_reasoning_level: ReasoningEffort,
pub supported_reasoning_levels: Vec<ReasoningEffort>,
pub shell_type: ConfigShellToolType,
#[serde(default = "default_visibility")]
pub visibility: ModelVisibility,
pub minimal_client_version: ClientVersion,
@@ -147,3 +143,28 @@ pub struct ModelsResponse {
fn default_visibility() -> ModelVisibility {
ModelVisibility::None
}
// convert ModelInfo to ModelPreset
impl From<ModelInfo> for ModelPreset {
fn from(info: ModelInfo) -> Self {
ModelPreset {
id: info.slug.clone(),
model: info.slug,
display_name: info.display_name,
description: info.description.unwrap_or_default(),
default_reasoning_effort: info.default_reasoning_level,
supported_reasoning_efforts: info
.supported_reasoning_levels
.into_iter()
.map(|level| ReasoningEffortPreset {
effort: level,
// todo: add description for each reasoning effort
description: level.to_string(),
})
.collect(),
is_default: false, // default is the highest priority available model
upgrade: None, // no upgrade available (todo: think about it)
show_in_picker: info.visibility == ModelVisibility::List,
}
}
}