Download packages/cli/src/ui/utils/contextUsage.ts from SaylorTwift/gemini-cli: direct link, hf CLI and curl.
- Browser
- Download file 652 Bytes
-
https://huggingface.co/SaylorTwift/gemini-cli/resolve/main/packages/cli/src/ui/utils/contextUsage.ts
- Command line
-
hf download hf://SaylorTwift/gemini-cli/packages/cli/src/ui/utils/contextUsage.ts
-
curl -L -o contextUsage.ts https://huggingface.co/SaylorTwift/gemini-cli/resolve/main/packages/cli/src/ui/utils/contextUsage.ts
652 Bytes
| /** | |
| * @license | |
| * Copyright 2026 Google LLC | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| import { tokenLimit } from '@google/gemini-cli-core'; | |
| export function getContextUsagePercentage( | |
| promptTokenCount: number, | |
| model: string | undefined, | |
| ): number { | |
| if (!model || typeof model !== 'string' || model.length === 0) { | |
| return 0; | |
| } | |
| const limit = tokenLimit(model); | |
| if (limit <= 0) { | |
| return 0; | |
| } | |
| return promptTokenCount / limit; | |
| } | |
| export function isContextUsageHigh( | |
| promptTokenCount: number, | |
| model: string | undefined, | |
| threshold = 0.6, | |
| ): boolean { | |
| return getContextUsagePercentage(promptTokenCount, model) > threshold; | |
| } | |