mirror of
https://github.com/openai/codex.git
synced 2026-11-03 00:21:31 +00:00
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:
1 parent
6736d1828d
commit
7b359c9c8e
13 files changed
+329
-88
No files matched your search
@@ -393,7 +393,7 @@ fn make_chatwidget_manual() -> (
|
||||
active_cell: None,
|
||||
config: cfg.clone(),
|
||||
auth_manager: auth_manager.clone(),
|
||||
models_manager: Arc::new(ModelsManager::new(auth_manager.get_auth_mode())),
|
||||
models_manager: Arc::new(ModelsManager::new(auth_manager)),
|
||||
session_header: SessionHeader::new(cfg.model),
|
||||
initial_user_message: None,
|
||||
token_info: None,
|
||||
@@ -431,7 +431,7 @@ fn make_chatwidget_manual() -> (
|
||||
fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
||||
chat.auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||
chat.models_manager = Arc::new(ModelsManager::new(chat.auth_manager.get_auth_mode()));
|
||||
chat.models_manager = Arc::new(ModelsManager::new(chat.auth_manager.clone()));
|
||||
}
|
||||
|
||||
pub(crate) fn make_chatwidget_manual_with_sender() -> (
|
||||
|
||||
@@ -1513,6 +1513,8 @@ mod tests {
|
||||
use crate::exec_cell::CommandOutput;
|
||||
use crate::exec_cell::ExecCall;
|
||||
use crate::exec_cell::ExecCell;
|
||||
use codex_core::AuthManager;
|
||||
use codex_core::CodexAuth;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::ConfigToml;
|
||||
@@ -1520,7 +1522,6 @@ mod tests {
|
||||
use codex_core::config::types::McpServerTransportConfig;
|
||||
use codex_core::openai_models::models_manager::ModelsManager;
|
||||
use codex_core::protocol::McpAuthStatus;
|
||||
use codex_login::AuthMode;
|
||||
use codex_protocol::parse_command::ParsedCommand;
|
||||
use dirs::home_dir;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -2325,7 +2326,9 @@ mod tests {
|
||||
#[test]
|
||||
fn reasoning_summary_block() {
|
||||
let config = test_config();
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let cell = new_reasoning_summary_block(
|
||||
"**High level reasoning**\n\nDetailed reasoning goes here.".to_string(),
|
||||
@@ -2342,7 +2345,9 @@ mod tests {
|
||||
#[test]
|
||||
fn reasoning_summary_block_returns_reasoning_cell_when_feature_disabled() {
|
||||
let config = test_config();
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let cell =
|
||||
new_reasoning_summary_block("Detailed reasoning goes here.".to_string(), &model_family);
|
||||
@@ -2357,7 +2362,9 @@ mod tests {
|
||||
config.model = "gpt-3.5-turbo".to_string();
|
||||
config.model_supports_reasoning_summaries = Some(true);
|
||||
config.model_reasoning_summary_format = Some(ReasoningSummaryFormat::Experimental);
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
assert_eq!(
|
||||
@@ -2377,7 +2384,9 @@ mod tests {
|
||||
#[test]
|
||||
fn reasoning_summary_block_falls_back_when_header_is_missing() {
|
||||
let config = test_config();
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let cell = new_reasoning_summary_block(
|
||||
"**High level reasoning without closing".to_string(),
|
||||
@@ -2391,7 +2400,9 @@ mod tests {
|
||||
#[test]
|
||||
fn reasoning_summary_block_falls_back_when_summary_is_missing() {
|
||||
let config = test_config();
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let cell = new_reasoning_summary_block(
|
||||
"**High level reasoning without closing**".to_string(),
|
||||
@@ -2413,7 +2424,9 @@ mod tests {
|
||||
#[test]
|
||||
fn reasoning_summary_block_splits_header_and_summary_when_present() {
|
||||
let config = test_config();
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(AuthMode::ApiKey)));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
|
||||
let models_manager = Arc::new(ModelsManager::new(auth_manager));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let cell = new_reasoning_summary_block(
|
||||
"**High level plan**\n\nWe should fix the bug next.".to_string(),
|
||||
|
||||
Reference in new issue
Block a user