mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
## Summary Adds /personality selector in the TUI, which leverages the new core interface in #9644 Notes: - We are doing some of our own state management for model_info loading here, but not sure if that's ideal. open to opinions on simpler approach, but would like to avoid blocking on a larger refactor - Right now, the `/personality` selector just hides when the model doesn't support it. we can update this behavior down the line ## Testing - [x] Tested locally - [x] Added snapshot tests
47 lines
1.5 KiB
Rust
47 lines
1.5 KiB
Rust
use std::sync::Arc;
|
|
|
|
use codex_app_server_protocol::Model;
|
|
use codex_app_server_protocol::ReasoningEffortOption;
|
|
use codex_core::ThreadManager;
|
|
use codex_core::config::Config;
|
|
use codex_core::models_manager::manager::RefreshStrategy;
|
|
use codex_protocol::openai_models::ModelPreset;
|
|
use codex_protocol::openai_models::ReasoningEffortPreset;
|
|
|
|
pub async fn supported_models(thread_manager: Arc<ThreadManager>, config: &Config) -> Vec<Model> {
|
|
thread_manager
|
|
.list_models(config, RefreshStrategy::OnlineIfUncached)
|
|
.await
|
|
.into_iter()
|
|
.filter(|preset| preset.show_in_picker)
|
|
.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,
|
|
supports_personality: preset.supports_personality,
|
|
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()
|
|
}
|