MCPcopy Create free account
hub / github.com/anus-dev/ANUS / flashFallbackHandler

Function flashFallbackHandler

packages/cli/src/ui/App.tsx:389–468  ·  view source on GitHub ↗
(
      currentModel: string,
      fallbackModel: string,
      error?: unknown,
    )

Source from the content-addressed store, hash-verified

387 // Set up Flash fallback handler
388 useEffect(() => {
389 const flashFallbackHandler = async (
390 currentModel: string,
391 fallbackModel: string,
392 error?: unknown,
393 ): Promise<boolean> => {
394 let message: string;
395
396 if (
397 config.getContentGeneratorConfig().authType ===
398 AuthType.LOGIN_WITH_GOOGLE
399 ) {
400 // Use actual user tier if available; otherwise, default to FREE tier behavior (safe default)
401 const isPaidTier =
402 userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
403
404 // Check if this is a Pro quota exceeded error
405 if (error && isProQuotaExceededError(error)) {
406 if (isPaidTier) {
407 message = `⚡ You have reached your daily ${currentModel} quota limit.
408⚡ Automatically switching from ${currentModel} to ${fallbackModel} for the remainder of this session.
409⚡ To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
410 } else {
411 message = `⚡ You have reached your daily ${currentModel} quota limit.
412⚡ Automatically switching from ${currentModel} to ${fallbackModel} for the remainder of this session.
413⚡ To increase your limits, upgrade to a Anus Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-anus-code-assist
414⚡ Or you can utilize a Anus API Key. See: https://goo.gle/anus-cli-docs-auth#grok-api-key
415⚡ You can switch authentication methods by typing /auth`;
416 }
417 } else if (error && isGenericQuotaExceededError(error)) {
418 if (isPaidTier) {
419 message = `⚡ You have reached your daily quota limit.
420⚡ Automatically switching from ${currentModel} to ${fallbackModel} for the remainder of this session.
421⚡ To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
422 } else {
423 message = `⚡ You have reached your daily quota limit.
424⚡ Automatically switching from ${currentModel} to ${fallbackModel} for the remainder of this session.
425⚡ To increase your limits, upgrade to a Anus Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-anus-code-assist
426⚡ Or you can utilize a Anus API Key. See: https://goo.gle/anus-cli-docs-auth#grok-api-key
427⚡ You can switch authentication methods by typing /auth`;
428 }
429 } else {
430 if (isPaidTier) {
431 // Default fallback message for other cases (like consecutive 429s)
432 message = `⚡ Automatically switching from ${currentModel} to ${fallbackModel} for faster responses for the remainder of this session.
433⚡ Possible reasons for this are that you have received multiple consecutive capacity errors or you have reached your daily ${currentModel} quota limit
434⚡ To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
435 } else {
436 // Default fallback message for other cases (like consecutive 429s)
437 message = `⚡ Automatically switching from ${currentModel} to ${fallbackModel} for faster responses for the remainder of this session.
438⚡ Possible reasons for this are that you have received multiple consecutive capacity errors or you have reached your daily ${currentModel} quota limit
439⚡ To increase your limits, upgrade to a Anus Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-anus-code-assist
440⚡ Or you can utilize a Anus API Key. See: https://goo.gle/anus-cli-docs-auth#grok-api-key
441⚡ You can switch authentication methods by typing /auth`;
442 }
443 }
444
445 // Add message to UI history
446 addItem(

Callers

nothing calls this directly

Calls 7

isProQuotaExceededErrorFunction · 0.85
logFlashFallbackFunction · 0.85
setQuotaErrorOccurredMethod · 0.80
setModelMethod · 0.80
setFallbackModeMethod · 0.80

Tested by

no test coverage detected