Skip to content

Commit 7174c0f

Browse files
committed
claud
1 parent 10e3080 commit 7174c0f

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎api/mcp/[...path].js‎

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,46 @@ ${contextSections}
368368
Please answer the user's question based on the provided documentation. If the documentation doesn't fully answer the question, let the user know what information is available and what might be missing.`;
369369

370370
// Call Claude API
371-
const message = await anthropic.messages.create({
372-
model: "claude-3-5-sonnet-20241022",
373-
max_tokens: 2048,
374-
system: systemPrompt,
375-
messages: [
376-
{
377-
role: "user",
378-
content: userMessage,
379-
},
380-
],
381-
});
371+
// Try models in order of preference
372+
const modelsToTry = [
373+
"claude-3-5-sonnet-20240620", // Stable Claude 3.5 Sonnet
374+
"claude-3-5-sonnet", // Alternative format
375+
"claude-3-sonnet-20240229", // Claude 3 Sonnet fallback
376+
];
377+
378+
let message;
379+
let lastError;
380+
381+
for (const modelName of modelsToTry) {
382+
try {
383+
message = await anthropic.messages.create({
384+
model: modelName,
385+
max_tokens: 2048,
386+
system: systemPrompt,
387+
messages: [
388+
{
389+
role: "user",
390+
content: userMessage,
391+
},
392+
],
393+
});
394+
break; // Success, exit loop
395+
} catch (error) {
396+
lastError = error;
397+
// Check if it's a model not found error (could be in message, error.error.message, etc.)
398+
const errorMessage = error.message || error.error?.message || JSON.stringify(error);
399+
if (errorMessage.includes("not_found") || errorMessage.includes("model:") || error.status === 404) {
400+
console.log(`Model ${modelName} not found, trying next...`);
401+
continue;
402+
}
403+
// For other errors, throw immediately
404+
throw error;
405+
}
406+
}
407+
408+
if (!message) {
409+
throw new Error(`None of the Claude models are available. Last error: ${lastError?.message || 'Unknown error'}`);
410+
}
382411

383412
const claudeResponse = message.content[0].text;
384413

‎docs/dev/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar_position: 1
88

99
Welcome developers, curious minds, and crawling AIs to the Juicebox protocol's documentation.
1010

11-
Juicebox is a payment processor and capital formation engine for tokenized fundraises, revenues, incentives, and financial operations. The "pay" and "cash out" function of the open internet.
11+
Juicebox is a payment processor and capital formation engine for tokenized fundraises, revenues, incentives, and financial operations. The "pay" and "cash out" functions of the open internet.
1212

1313
Think of it as a programmable vending machine: projects can configure how its tokens are issued when someone inserts coins, and set rules for how those coins can be distributed to preprogrammed addresses or reclaimed by the community.
1414

0 commit comments

Comments
 (0)