mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
Revert "Add explicit self-serve business usage plan type"
This reverts commit 0a32bf8907.
This commit is contained in:
@@ -477,9 +477,6 @@ impl Client {
|
||||
crate::types::PlanType::Business => AccountPlanType::Business,
|
||||
crate::types::PlanType::Enterprise => AccountPlanType::Enterprise,
|
||||
crate::types::PlanType::Edu | crate::types::PlanType::Education => AccountPlanType::Edu,
|
||||
crate::types::PlanType::SelfServeBusinessUsage => {
|
||||
AccountPlanType::SelfServeBusinessUsage
|
||||
}
|
||||
crate::types::PlanType::Guest
|
||||
| crate::types::PlanType::FreeWorkspace
|
||||
| crate::types::PlanType::Quorum
|
||||
|
||||
@@ -81,6 +81,4 @@ pub enum PlanType {
|
||||
Enterprise,
|
||||
#[serde(rename = "edu")]
|
||||
Edu,
|
||||
#[serde(rename = "self_serve_business_usage_based")]
|
||||
SelfServeBusinessUsage,
|
||||
}
|
||||
|
||||
@@ -460,7 +460,9 @@ impl std::fmt::Display for UsageLimitReachedError {
|
||||
"You've hit your usage limit.{}",
|
||||
retry_suffix(self.resets_at.as_ref())
|
||||
),
|
||||
Some(PlanType::SelfServeBusinessUsage) => {
|
||||
Some(PlanType::Unknown(plan))
|
||||
if plan.eq_ignore_ascii_case("self_serve_business_usage_based") =>
|
||||
{
|
||||
match self
|
||||
.rate_limits
|
||||
.as_ref()
|
||||
|
||||
@@ -1397,7 +1397,6 @@ fn local_external_chatgpt_tokens(
|
||||
AccountPlanType::Business => "business".to_string(),
|
||||
AccountPlanType::Enterprise => "enterprise".to_string(),
|
||||
AccountPlanType::Edu => "edu".to_string(),
|
||||
AccountPlanType::SelfServeBusinessUsage => "self_serve_business_usage_based".to_string(),
|
||||
AccountPlanType::Unknown => "unknown".to_string(),
|
||||
});
|
||||
|
||||
|
||||
@@ -275,9 +275,6 @@ impl CodexAuth {
|
||||
.chatgpt_plan_type
|
||||
.map(|pt| match pt {
|
||||
InternalPlanType::Known(k) => map_known(&k),
|
||||
InternalPlanType::SelfServeBusinessUsage => {
|
||||
AccountPlanType::SelfServeBusinessUsage
|
||||
}
|
||||
InternalPlanType::Unknown(_) => AccountPlanType::Unknown,
|
||||
})
|
||||
.unwrap_or(AccountPlanType::Unknown)
|
||||
|
||||
@@ -39,7 +39,6 @@ impl IdTokenInfo {
|
||||
pub fn get_chatgpt_plan_type(&self) -> Option<String> {
|
||||
self.chatgpt_plan_type.as_ref().map(|t| match t {
|
||||
PlanType::Known(plan) => format!("{plan:?}"),
|
||||
PlanType::SelfServeBusinessUsage => "self_serve_business_usage_based".to_string(),
|
||||
PlanType::Unknown(s) => s.clone(),
|
||||
})
|
||||
}
|
||||
@@ -49,15 +48,15 @@ impl IdTokenInfo {
|
||||
self.chatgpt_plan_type,
|
||||
Some(PlanType::Known(
|
||||
KnownPlan::Team | KnownPlan::Business | KnownPlan::Enterprise | KnownPlan::Edu
|
||||
) | PlanType::SelfServeBusinessUsage)
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PlanType {
|
||||
Known(KnownPlan),
|
||||
SelfServeBusinessUsage,
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
@@ -72,46 +71,11 @@ impl PlanType {
|
||||
"business" => Self::Known(KnownPlan::Business),
|
||||
"enterprise" => Self::Known(KnownPlan::Enterprise),
|
||||
"education" | "edu" => Self::Known(KnownPlan::Edu),
|
||||
"self_serve_business_usage_based" => Self::SelfServeBusinessUsage,
|
||||
_ => Self::Unknown(raw.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for PlanType {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let value = match self {
|
||||
Self::Known(plan) => match plan {
|
||||
KnownPlan::Free => "free",
|
||||
KnownPlan::Go => "go",
|
||||
KnownPlan::Plus => "plus",
|
||||
KnownPlan::Pro => "pro",
|
||||
KnownPlan::Team => "team",
|
||||
KnownPlan::Business => "business",
|
||||
KnownPlan::Enterprise => "enterprise",
|
||||
KnownPlan::Edu => "edu",
|
||||
},
|
||||
Self::SelfServeBusinessUsage => "self_serve_business_usage_based",
|
||||
Self::Unknown(raw) => raw,
|
||||
};
|
||||
|
||||
serializer.serialize_str(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for PlanType {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let raw = String::deserialize(deserializer)?;
|
||||
Ok(Self::from_raw_value(&raw))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum KnownPlan {
|
||||
|
||||
@@ -16,9 +16,6 @@ pub enum PlanType {
|
||||
Business,
|
||||
Enterprise,
|
||||
Edu,
|
||||
#[serde(rename = "self_serve_business_usage_based")]
|
||||
#[ts(rename = "self_serve_business_usage_based")]
|
||||
SelfServeBusinessUsage,
|
||||
#[serde(other)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user