collab: Clarify naming around free tier spending limits (#18936)
This PR renames the `MONTHLY_SPENDING_LIMIT` constant to `FREE_TIER_MONTHLY_SPENDING_LIMIT` to clarify it. This will help distinguish it from the user's specified limit on their paid monthly spending. Release Notes: - N/A
This commit is contained in:
parent
817a41c4dc
commit
f1053ff525
2 changed files with 7 additions and 5 deletions
|
@ -29,7 +29,7 @@ use crate::db::{
|
||||||
UpdateBillingSubscriptionParams,
|
UpdateBillingSubscriptionParams,
|
||||||
};
|
};
|
||||||
use crate::llm::db::LlmDatabase;
|
use crate::llm::db::LlmDatabase;
|
||||||
use crate::llm::MONTHLY_SPENDING_LIMIT;
|
use crate::llm::FREE_TIER_MONTHLY_SPENDING_LIMIT;
|
||||||
use crate::rpc::ResultExt as _;
|
use crate::rpc::ResultExt as _;
|
||||||
use crate::{AppState, Error, Result};
|
use crate::{AppState, Error, Result};
|
||||||
|
|
||||||
|
@ -703,7 +703,8 @@ async fn update_stripe_subscription(
|
||||||
let subscription_id = SubscriptionId::from_str(&subscription.stripe_subscription_id)
|
let subscription_id = SubscriptionId::from_str(&subscription.stripe_subscription_id)
|
||||||
.context("failed to parse subscription ID")?;
|
.context("failed to parse subscription ID")?;
|
||||||
|
|
||||||
let monthly_spending_over_free_tier = monthly_spending.saturating_sub(MONTHLY_SPENDING_LIMIT);
|
let monthly_spending_over_free_tier =
|
||||||
|
monthly_spending.saturating_sub(FREE_TIER_MONTHLY_SPENDING_LIMIT);
|
||||||
|
|
||||||
let new_quantity = (monthly_spending_over_free_tier.0 as f32 / 100.).ceil();
|
let new_quantity = (monthly_spending_over_free_tier.0 as f32 / 100.).ceil();
|
||||||
Subscription::update(
|
Subscription::update(
|
||||||
|
|
|
@ -438,8 +438,9 @@ fn normalize_model_name(known_models: Vec<String>, name: String) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The maximum monthly spending an individual user can reach before they have to pay.
|
/// The maximum monthly spending an individual user can reach on the free tier
|
||||||
pub const MONTHLY_SPENDING_LIMIT: Cents = Cents::from_dollars(5);
|
/// before they have to pay.
|
||||||
|
pub const FREE_TIER_MONTHLY_SPENDING_LIMIT: Cents = Cents::from_dollars(5);
|
||||||
|
|
||||||
/// The maximum lifetime spending an individual user can reach before being cut off.
|
/// The maximum lifetime spending an individual user can reach before being cut off.
|
||||||
const LIFETIME_SPENDING_LIMIT: Cents = Cents::from_dollars(1_000);
|
const LIFETIME_SPENDING_LIMIT: Cents = Cents::from_dollars(1_000);
|
||||||
|
@ -462,7 +463,7 @@ async fn check_usage_limit(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if state.config.is_llm_billing_enabled() {
|
if state.config.is_llm_billing_enabled() {
|
||||||
if usage.spending_this_month >= MONTHLY_SPENDING_LIMIT {
|
if usage.spending_this_month >= FREE_TIER_MONTHLY_SPENDING_LIMIT {
|
||||||
if !claims.has_llm_subscription.unwrap_or(false) {
|
if !claims.has_llm_subscription.unwrap_or(false) {
|
||||||
return Err(Error::http(
|
return Err(Error::http(
|
||||||
StatusCode::PAYMENT_REQUIRED,
|
StatusCode::PAYMENT_REQUIRED,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue