mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-09 12:51:09 -07:00
refactor(cli): code review cleanup fix for tab+tab (#18967)
This commit is contained in:
29
packages/cli/src/ui/utils/contextUsage.ts
Normal file
29
packages/cli/src/ui/utils/contextUsage.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
Reference in New Issue
Block a user