navada-edge-cli 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/agent.js +13 -2
- package/package.json +1 -1
package/lib/agent.js
CHANGED
|
@@ -485,8 +485,19 @@ async function chat(userMessage, conversationHistory = []) {
|
|
|
485
485
|
{ role: 'user', content: userMessage },
|
|
486
486
|
];
|
|
487
487
|
|
|
488
|
-
// Stream the response
|
|
489
|
-
let response
|
|
488
|
+
// Stream the response — fall back to Grok if Anthropic fails (billing, rate limit, etc.)
|
|
489
|
+
let response;
|
|
490
|
+
try {
|
|
491
|
+
response = await streamAnthropic(effectiveKey, messages, tools);
|
|
492
|
+
} catch (e) {
|
|
493
|
+
const errMsg = e.message || '';
|
|
494
|
+
// If billing/rate limit/auth error, fall back to free tier
|
|
495
|
+
if (errMsg.includes('400') || errMsg.includes('401') || errMsg.includes('429') || errMsg.includes('usage limits')) {
|
|
496
|
+
console.log(ui.warn('Anthropic API unavailable, falling back to Grok free tier...'));
|
|
497
|
+
return grokChat(userMessage, conversationHistory);
|
|
498
|
+
}
|
|
499
|
+
throw e;
|
|
500
|
+
}
|
|
490
501
|
|
|
491
502
|
// Handle tool use loop
|
|
492
503
|
let iterations = 0;
|
package/package.json
CHANGED