mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(sync): align ChatGPT and service tier parity
This commit is contained in:
@@ -24,7 +24,11 @@ pub(crate) async fn chatgpt_get_request<T: DeserializeOwned>(
|
||||
|
||||
// Make direct HTTP request to ChatGPT backend API with the token
|
||||
let client = code_core::http_client::build_http_client();
|
||||
let url = format!("{chatgpt_base_url}{path}");
|
||||
let url = format!(
|
||||
"{}/{}",
|
||||
chatgpt_base_url.trim_end_matches('/'),
|
||||
path.trim_start_matches('/')
|
||||
);
|
||||
|
||||
let token = auth.get_token_data().await?;
|
||||
let account_id = token.account_id.ok_or_else(|| {
|
||||
|
||||
@@ -768,7 +768,8 @@ impl ModelClient {
|
||||
include,
|
||||
service_tier: match self.config.service_tier {
|
||||
Some(ServiceTier::Fast) => Some("priority".to_string()),
|
||||
_ => None,
|
||||
Some(service_tier) => Some(service_tier.to_string()),
|
||||
None => None,
|
||||
},
|
||||
prompt_cache_key: Some(session_id_str.clone()),
|
||||
};
|
||||
@@ -1244,7 +1245,8 @@ impl ModelClient {
|
||||
include,
|
||||
service_tier: match self.config.service_tier {
|
||||
Some(ServiceTier::Fast) => Some("priority".to_string()),
|
||||
_ => None,
|
||||
Some(service_tier) => Some(service_tier.to_string()),
|
||||
None => None,
|
||||
},
|
||||
// Use a stable per-process cache key (session id). With store=false this is inert.
|
||||
prompt_cache_key: Some(session_id_str.clone()),
|
||||
|
||||
@@ -454,6 +454,7 @@ pub struct Config {
|
||||
/// Optional service tier preference for model requests.
|
||||
///
|
||||
/// `Some(Fast)` sends `service_tier=priority` to the Responses API.
|
||||
/// `Some(Flex)` sends `service_tier=flex` to the Responses API.
|
||||
/// `None` sends no override (legacy standard behavior).
|
||||
pub service_tier: Option<ServiceTier>,
|
||||
|
||||
@@ -1321,6 +1322,7 @@ impl Config {
|
||||
|
||||
let service_tier = match config_profile.service_tier.or(cfg.service_tier) {
|
||||
Some(ServiceTier::Fast) => Some(ServiceTier::Fast),
|
||||
Some(ServiceTier::Flex) => Some(ServiceTier::Flex),
|
||||
Some(ServiceTier::Standard) => None,
|
||||
None => None,
|
||||
};
|
||||
@@ -3433,6 +3435,23 @@ mod agent_merge_tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn service_tier_flex_preserves_override() -> anyhow::Result<()> {
|
||||
let code_home = TempDir::new()?;
|
||||
let cfg = toml::from_str::<ConfigToml>(r#"service_tier = "flex""#)?;
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides {
|
||||
cwd: Some(code_home.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
code_home.path().to_path_buf(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.service_tier, Some(ServiceTier::Flex));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn service_tier_standard_disables_override() -> anyhow::Result<()> {
|
||||
let code_home = TempDir::new()?;
|
||||
|
||||
@@ -1500,6 +1500,7 @@ pub enum ServiceTier {
|
||||
/// Legacy compatibility value for older local config files.
|
||||
Standard,
|
||||
Fast,
|
||||
Flex,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Display)]
|
||||
|
||||
@@ -123,6 +123,7 @@ pub enum ServiceTier {
|
||||
/// Legacy compatibility value for older local config files.
|
||||
Standard,
|
||||
Fast,
|
||||
Flex,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Display, JsonSchema, TS)]
|
||||
|
||||
@@ -23463,6 +23463,7 @@ Have we met every part of this goal and is there no further work to do?"#
|
||||
let persisted_service_tier = match (profile.as_deref(), self.config.service_tier) {
|
||||
(Some(_), None) => Some("standard"),
|
||||
(_, Some(ServiceTier::Fast)) => Some("fast"),
|
||||
(_, Some(ServiceTier::Flex)) => Some("flex"),
|
||||
(_, Some(ServiceTier::Standard)) => Some("standard"),
|
||||
(_, None) => None,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user