- Make Config.model optional and centralize default-selection logic in ModelsManager, including a default_model helper (with codex-auto-balanced when available) so sessions now carry an explicit chosen model separate from the base config. - Resolve `model` once in `core` and `tui` from config. Then store the state of it on other structs. - Move refreshing models to be before resolving the default model
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
use std::sync::Arc;
|
|
|
|
use codex_app_server_protocol::Model;
|
|
use codex_app_server_protocol::ReasoningEffortOption;
|
|
use codex_core::ConversationManager;
|
|
use codex_core::config::Config;
|
|
use codex_protocol::openai_models::ModelPreset;
|
|
use codex_protocol::openai_models::ReasoningEffortPreset;
|
|
|
|
pub async fn supported_models(
|
|
conversation_manager: Arc<ConversationManager>,
|
|
config: &Config,
|
|
) -> Vec<Model> {
|
|
conversation_manager
|
|
.list_models(config)
|
|
.await
|
|
.into_iter()
|
|
.map(model_from_preset)
|
|
.collect()
|
|
}
|
|
|
|
fn model_from_preset(preset: ModelPreset) -> Model {
|
|
Model {
|
|
id: preset.id.to_string(),
|
|
model: preset.model.to_string(),
|
|
display_name: preset.display_name.to_string(),
|
|
description: preset.description.to_string(),
|
|
supported_reasoning_efforts: reasoning_efforts_from_preset(
|
|
preset.supported_reasoning_efforts,
|
|
),
|
|
default_reasoning_effort: preset.default_reasoning_effort,
|
|
is_default: preset.is_default,
|
|
}
|
|
}
|
|
|
|
fn reasoning_efforts_from_preset(
|
|
efforts: Vec<ReasoningEffortPreset>,
|
|
) -> Vec<ReasoningEffortOption> {
|
|
efforts
|
|
.iter()
|
|
.map(|preset| ReasoningEffortOption {
|
|
reasoning_effort: preset.effort,
|
|
description: preset.description.to_string(),
|
|
})
|
|
.collect()
|
|
}
|