Download src/lib/api/operation-usage.ts from asnannp/DocDoeAI: direct link, hf CLI and curl.
- Browser
- Download file 831 Bytes
-
https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/operation-usage.ts
- Command line
-
hf download hf://spaces/asnannp/DocDoeAI/src/lib/api/operation-usage.ts
-
curl -L -o operation-usage.ts https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/operation-usage.ts
831 Bytes
| import { apiGet } from "@/lib/api/client"; | |
| export type OperationUsageItem = { | |
| operation: string; | |
| period: "day" | "month"; | |
| used: number; | |
| limit: number; | |
| remaining: number; | |
| allowed: boolean; | |
| }; | |
| export type OperationUsageStatus = { | |
| tier: "free" | "popular" | "premium"; | |
| entitlement_status: | |
| | "free" | |
| | "trial" | |
| | "active" | |
| | "past_due" | |
| | "cancel_at_period_end" | |
| | "expired"; | |
| usage_policy_key: string; | |
| items: OperationUsageItem[]; | |
| }; | |
| export function getOperationUsage() { | |
| return apiGet<OperationUsageStatus>("/users/me/operation-usage"); | |
| } | |
| export function formatStudyChatUsage(item: OperationUsageItem | null) { | |
| if (!item) return null; | |
| return item.allowed | |
| ? `${item.remaining} AI questions remaining today` | |
| : "AI help limit reached · verified PYQ and correction still work"; | |
| } | |