collab: Defer account age check to POST /completion endpoint (#26956)

This PR defers the account age check to the `POST /completion` endpoint
instead of doing it when an LLM token is generated.

This will allow us to lift the account age restriction for using Edit
Prediction.

Note: We're still temporarily performing the account age check when
issuing the LLM token until this change is deployed and the LLM tokens
have had a chance to cycle.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-03-17 18:42:29 -04:00 committed by GitHub
parent 1397e01735
commit 0851842d2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 2 deletions

View file

@ -4036,7 +4036,7 @@ async fn accept_terms_of_service(
}
/// The minimum account age an account must have in order to use the LLM service.
const MIN_ACCOUNT_AGE_FOR_LLM_USE: chrono::Duration = chrono::Duration::days(30);
pub const MIN_ACCOUNT_AGE_FOR_LLM_USE: chrono::Duration = chrono::Duration::days(30);
async fn get_llm_api_token(
_request: proto::GetLlmToken,
@ -4066,6 +4066,8 @@ 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 {