Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
collab: Limit free tier usage across all models (#25573)
Marshall Bowers3a3621f2d8f1
diff --git a/crates/collab/src/llm.rs b/crates/collab/src/llm.rsindex b79931818e2..c8eadeacd8d 100644--- a/crates/collab/src/llm.rs+++ b/crates/collab/src/llm.rs@@ -451,19 +451,19 @@ async fn check_usage_limit(return Ok(());}+ let user_id = UserId::from_proto(claims.user_id);let model = state.db.model(provider, model_name)?;let usage = state.db- .get_usage(- UserId::from_proto(claims.user_id),- provider,- model_name,- Utc::now(),- )+ .get_usage(user_id, provider, model_name, Utc::now()).await?;let free_tier = claims.free_tier_monthly_spending_limit();- if usage.spending_this_month >= free_tier {+ let spending_this_month = state+ .db+ .get_user_spending_for_month(user_id, Utc::now())+ .await?;+ if spending_this_month >= free_tier {if !claims.has_llm_subscription {return Err(Error::http(StatusCode::PAYMENT_REQUIRED,