-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-simple.js
More file actions
76 lines (61 loc) · 2.31 KB
/
Copy pathdebug-simple.js
File metadata and controls
76 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Simple debug script to test Anthropic API directly
import Anthropic from '@anthropic-ai/sdk';
import fs from 'fs';
// Read database file directly to get API key
const dbPath = './data/database.sqlite';
let apiKey = process.env.ANTHROPIC_API_KEY;
console.log('=== ANTHROPIC CLAUDE MODEL DEBUGGER ===\n');
if (!apiKey) {
console.log('⚠️ No ANTHROPIC_API_KEY in environment variables');
console.log('⚠️ Checking if database exists at:', dbPath);
if (fs.existsSync(dbPath)) {
console.log('✅ Database file exists');
console.log('📝 You need to check Settings page in the app for your API key');
} else {
console.log('❌ Database file not found');
}
console.log('\n🔑 Please enter your Anthropic API key manually for testing:');
console.log(' Or set it as environment variable: ANTHROPIC_API_KEY=sk-ant-...');
process.exit(1);
}
console.log('✅ API Key found:', apiKey.substring(0, 15) + '...');
console.log('📦 SDK Version: 0.95.2\n');
const client = new Anthropic({ apiKey });
// Test models one by one
const modelsToTest = [
'claude-3-5-sonnet-20241022', // Current in code
'claude-3-5-sonnet-latest', // Alias
'claude-3-5-sonnet-20240620', // Previous version
'claude-3-opus-20240229', // Different tier
'claude-3-sonnet-20240229', // Older 3.0
];
console.log('=== TESTING MODELS ===\n');
for (const modelName of modelsToTest) {
console.log(`Testing: ${modelName}`);
try {
const stream = await client.messages.stream({
model: modelName,
max_tokens: 50,
messages: [{ role: 'user', content: 'Say "test successful"' }],
});
let response = '';
for await (const chunk of stream) {
if (chunk.type === 'content_block_delta' && chunk.delta.type === 'text_delta') {
response += chunk.delta.text;
}
}
console.log(`✅ SUCCESS! Model works!`);
console.log(` Response: ${response.trim()}`);
console.log(`\n🎯 WORKING MODEL FOUND: ${modelName}`);
console.log(` Update server/services/llm.ts line 176 to use this model name.\n`);
break;
} catch (error) {
console.log(`❌ FAILED`);
console.log(` Error: ${error.message}`);
if (error.status) {
console.log(` HTTP Status: ${error.status}`);
}
console.log('');
}
}
console.log('=== DIAGNOSIS COMPLETE ===');