mirror of
https://github.com/openai/codex.git
synced 2026-11-02 00:18:52 +00:00
load models from disk and set a ttl and etag (#7722)
# External (non-OpenAI) Pull Request Requirements Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed: https://github.com/openai/codex/blob/main/docs/contributing.md If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes. Include a link to a bug report or enhancement request.
This commit is contained in:
@@ -127,7 +127,7 @@ async fn handle_model_migration_prompt_if_needed(
|
||||
auth_mode: Option<AuthMode>,
|
||||
models_manager: Arc<ModelsManager>,
|
||||
) -> Option<AppExitInfo> {
|
||||
let available_models = models_manager.available_models.read().await.clone();
|
||||
let available_models = models_manager.list_models().await;
|
||||
let upgrade = available_models
|
||||
.iter()
|
||||
.find(|preset| preset.model == config.model)
|
||||
@@ -139,12 +139,12 @@ async fn handle_model_migration_prompt_if_needed(
|
||||
migration_config_key,
|
||||
}) = upgrade
|
||||
{
|
||||
if !migration_prompt_allows_auth_mode(auth_mode, migration_config_key) {
|
||||
if !migration_prompt_allows_auth_mode(auth_mode, migration_config_key.as_str()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let target_model = target_model.to_string();
|
||||
let hide_prompt_flag = migration_prompt_hidden(config, migration_config_key);
|
||||
let hide_prompt_flag = migration_prompt_hidden(config, migration_config_key.as_str());
|
||||
if !should_show_model_migration_prompt(
|
||||
&config.model,
|
||||
&target_model,
|
||||
@@ -154,7 +154,7 @@ async fn handle_model_migration_prompt_if_needed(
|
||||
return None;
|
||||
}
|
||||
|
||||
let prompt_copy = migration_copy_for_config(migration_config_key);
|
||||
let prompt_copy = migration_copy_for_config(migration_config_key.as_str());
|
||||
match run_model_migration_prompt(tui, prompt_copy).await {
|
||||
ModelMigrationOutcome::Accepted => {
|
||||
app_event_tx.send(AppEvent::PersistModelMigrationPromptAcknowledged {
|
||||
|
||||
@@ -2053,7 +2053,7 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
fn lower_cost_preset(&self) -> Option<ModelPreset> {
|
||||
let models = self.models_manager.available_models.try_read().ok()?;
|
||||
let models = self.models_manager.try_list_models().ok()?;
|
||||
models
|
||||
.iter()
|
||||
.find(|preset| preset.model == NUDGE_MODEL_SLUG)
|
||||
@@ -2162,14 +2162,16 @@ impl ChatWidget {
|
||||
let current_model = self.config.model.clone();
|
||||
let presets: Vec<ModelPreset> =
|
||||
// todo(aibrahim): make this async function
|
||||
if let Ok(models) = self.models_manager.available_models.try_read() {
|
||||
models.clone()
|
||||
} else {
|
||||
self.add_info_message(
|
||||
"Models are being updated; please try /model again in a moment.".to_string(),
|
||||
None,
|
||||
);
|
||||
return;
|
||||
match self.models_manager.try_list_models() {
|
||||
Ok(models) => models,
|
||||
Err(_) => {
|
||||
self.add_info_message(
|
||||
"Models are being updated; please try /model again in a moment."
|
||||
.to_string(),
|
||||
None,
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let mut items: Vec<SelectionItem> = Vec::new();
|
||||
|
||||
@@ -956,9 +956,11 @@ fn active_blob(chat: &ChatWidget) -> String {
|
||||
}
|
||||
|
||||
fn get_available_model(chat: &ChatWidget, model: &str) -> ModelPreset {
|
||||
chat.models_manager
|
||||
.available_models
|
||||
.blocking_read()
|
||||
let models = chat
|
||||
.models_manager
|
||||
.try_list_models()
|
||||
.expect("models lock available");
|
||||
models
|
||||
.iter()
|
||||
.find(|&preset| preset.model == model)
|
||||
.cloned()
|
||||
|
||||
Reference in New Issue
Block a user