Use more types/constants from zed_llm_client (#28909)

This PR makes it so we use more types and constants from the
`zed_llm_client` crate to avoid duplicating information.

Also updates the current usage endpoint to use limits derived from the
`Plan`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-16 16:58:00 -04:00 committed by GitHub
parent 78c856cb75
commit 3fef3cc392
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 9 deletions

View file

@ -1020,8 +1020,20 @@ async fn get_current_usage(
return Ok(Json(empty_usage));
};
let model_requests_limit = Some(500);
let edit_prediction_limit = Some(2000);
let plan = match usage.plan {
SubscriptionKind::ZedPro => zed_llm_client::Plan::ZedPro,
SubscriptionKind::ZedProTrial => zed_llm_client::Plan::ZedProTrial,
SubscriptionKind::ZedFree => zed_llm_client::Plan::Free,
};
let model_requests_limit = match plan.model_requests_limit() {
zed_llm_client::UsageLimit::Limited(limit) => Some(limit),
zed_llm_client::UsageLimit::Unlimited => None,
};
let edit_prediction_limit = match plan.edit_predictions_limit() {
zed_llm_client::UsageLimit::Limited(limit) => Some(limit),
zed_llm_client::UsageLimit::Unlimited => None,
};
Ok(Json(GetCurrentUsageResponse {
model_requests: UsageCounts {