collab: Make account age-related fields required in LlmTokenClaims
(#26959)
This PR makes the account age-related fields required in `LlmTokenClaims`. We've also removed the account age check from the LLM token issuance endpoint, instead having it solely be enforced in the `POST /completion` endpoint. This change will be safe to deploy at ~8:01PM EDT. Release Notes: - N/A
This commit is contained in:
parent
0851842d2c
commit
cd5d7e82d0
3 changed files with 4 additions and 26 deletions
|
@ -4047,8 +4047,6 @@ async fn get_llm_api_token(
|
|||
|
||||
let flags = db.get_user_flags(session.user_id()).await?;
|
||||
let has_language_models_feature_flag = flags.iter().any(|flag| flag == "language-models");
|
||||
let has_bypass_account_age_check_feature_flag =
|
||||
flags.iter().any(|flag| flag == "bypass-account-age-check");
|
||||
|
||||
if !session.is_staff() && !has_language_models_feature_flag {
|
||||
Err(anyhow!("permission denied"))?
|
||||
|
@ -4065,17 +4063,6 @@ async fn get_llm_api_token(
|
|||
}
|
||||
|
||||
let has_llm_subscription = session.has_llm_subscription(&db).await?;
|
||||
|
||||
// This check is now handled in the `perform_completion` endpoint. We can remove the check here once the tokens have
|
||||
// had ~1 hour to cycle.
|
||||
let bypass_account_age_check =
|
||||
has_llm_subscription || has_bypass_account_age_check_feature_flag;
|
||||
if !bypass_account_age_check {
|
||||
if Utc::now().naive_utc() - user.account_created_at() < MIN_ACCOUNT_AGE_FOR_LLM_USE {
|
||||
Err(anyhow!("account too young"))?
|
||||
}
|
||||
}
|
||||
|
||||
let billing_preferences = db.get_billing_preferences(user.id).await?;
|
||||
|
||||
let token = LlmTokenClaims::create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue