Spaces:
Running
Running
Download src/services/github/get-copilot-usage.ts from imspsycho/copilot-api: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-usage.ts
- Command line
-
hf download hf://spaces/imspsycho/copilot-api@97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-usage.ts
-
curl -L -o get-copilot-usage.ts https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-usage.ts
1.17 kB
| import { GITHUB_API_BASE_URL, githubHeaders } from "~/lib/api-config" | |
| import { HTTPError } from "~/lib/error" | |
| import { state } from "~/lib/state" | |
| export const getCopilotUsage = async (): Promise<CopilotUsageResponse> => { | |
| const response = await fetch(`${GITHUB_API_BASE_URL}/copilot_internal/user`, { | |
| headers: githubHeaders(state), | |
| }) | |
| if (!response.ok) { | |
| throw new HTTPError("Failed to get Copilot usage", response) | |
| } | |
| return (await response.json()) as CopilotUsageResponse | |
| } | |
| export interface QuotaDetail { | |
| entitlement: number | |
| overage_count: number | |
| overage_permitted: boolean | |
| percent_remaining: number | |
| quota_id: string | |
| quota_remaining: number | |
| remaining: number | |
| unlimited: boolean | |
| } | |
| interface QuotaSnapshots { | |
| chat: QuotaDetail | |
| completions: QuotaDetail | |
| premium_interactions: QuotaDetail | |
| } | |
| interface CopilotUsageResponse { | |
| access_type_sku: string | |
| analytics_tracking_id: string | |
| assigned_date: string | |
| can_signup_for_limited: boolean | |
| chat_enabled: boolean | |
| copilot_plan: string | |
| organization_login_list: Array<unknown> | |
| organization_list: Array<unknown> | |
| quota_reset_date: string | |
| quota_snapshots: QuotaSnapshots | |
| } | |