summaryrefslogtreecommitdiff
path: root/packages/cli/src/utils/modelCheck.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-06-07 11:12:30 -0700
committerGitHub <[email protected]>2025-06-07 11:12:30 -0700
commit6ea4479064a4275390ef96216f5d68bd27f65ae7 (patch)
tree439d88ee4a665562774c339d34dea121812fcf84 /packages/cli/src/utils/modelCheck.ts
parent680f4cdd61ab718d946afe0fd0d23828106bfda1 (diff)
Push model-switching logging into loadCliConfig (#815)
Diffstat (limited to 'packages/cli/src/utils/modelCheck.ts')
-rw-r--r--packages/cli/src/utils/modelCheck.ts23
1 files changed, 8 insertions, 15 deletions
diff --git a/packages/cli/src/utils/modelCheck.ts b/packages/cli/src/utils/modelCheck.ts
index 1634656e..913de8ce 100644
--- a/packages/cli/src/utils/modelCheck.ts
+++ b/packages/cli/src/utils/modelCheck.ts
@@ -9,12 +9,6 @@ import {
DEFAULT_GEMINI_FLASH_MODEL,
} from '../config/config.js';
-export interface EffectiveModelCheckResult {
- effectiveModel: string;
- switched: boolean;
- originalModelIfSwitched?: string;
-}
-
/**
* Checks if the default "pro" model is rate-limited and returns a fallback "flash"
* model if necessary. This function is designed to be silent.
@@ -26,10 +20,10 @@ export interface EffectiveModelCheckResult {
export async function getEffectiveModel(
apiKey: string,
currentConfiguredModel: string,
-): Promise<EffectiveModelCheckResult> {
+): Promise<string> {
if (currentConfiguredModel !== DEFAULT_GEMINI_MODEL) {
// Only check if the user is trying to use the specific pro model we want to fallback from.
- return { effectiveModel: currentConfiguredModel, switched: false };
+ return currentConfiguredModel;
}
const modelToTest = DEFAULT_GEMINI_MODEL;
@@ -59,17 +53,16 @@ export async function getEffectiveModel(
clearTimeout(timeoutId);
if (response.status === 429) {
- return {
- effectiveModel: fallbackModel,
- switched: true,
- originalModelIfSwitched: modelToTest,
- };
+ console.log(
+ `[INFO] Your configured model (${modelToTest}) was temporarily unavailable. Switched to ${fallbackModel} for this session.`,
+ );
+ return fallbackModel;
}
// For any other case (success, other error codes), we stick to the original model.
- return { effectiveModel: currentConfiguredModel, switched: false };
+ return currentConfiguredModel;
} catch (_error) {
clearTimeout(timeoutId);
// On timeout or any other fetch error, stick to the original model.
- return { effectiveModel: currentConfiguredModel, switched: false };
+ return currentConfiguredModel;
}
}