-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-connection.js
More file actions
68 lines (58 loc) · 2.35 KB
/
Copy pathtest-connection.js
File metadata and controls
68 lines (58 loc) · 2.35 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
// Quick test to verify your LangGraph deployment connection
// Run with: node test-connection.js
require('dotenv').config();
async function testConnection() {
console.log('🔍 Testing LangGraph deployment connection...\n');
// Check environment variables
const url = process.env.LANGGRAPH_URL;
const apiKey = process.env.LANGCHAIN_API_KEY || process.env.LANGSMITH_API_KEY;
console.log('📋 Configuration:');
console.log(` URL: ${url || '❌ MISSING'}`);
console.log(` API Key: ${apiKey ? `✅ ${apiKey.substring(0, 12)}...` : '❌ MISSING'}\n`);
if (!url || !apiKey) {
console.log('❌ Missing required environment variables!\n');
console.log('💡 Make sure your .env file has:');
console.log(' LANGGRAPH_URL=https://your-deployment-url.langchain.com');
console.log(' LANGCHAIN_API_KEY=lsv2_pt_your-api-key-here');
return;
}
try {
// Test basic connectivity
console.log('🚀 Testing connection...');
const testUrl = `${url.replace(/\/$/, '')}/runs`;
const response = await fetch(testUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
},
body: JSON.stringify({
assistant_id: 'agent',
input: {
messages: [{ role: 'human', content: 'Hello test' }]
}
})
});
if (response.ok) {
console.log('✅ Connection successful! Your deployment is working.\n');
console.log('🎉 You can now run: cd web && npm run dev');
} else {
const error = await response.text();
console.log(`❌ Connection failed: ${response.status}`);
console.log(` Response: ${error}\n`);
if (response.status === 403) {
console.log('💡 This is likely an API key issue. Make sure:');
console.log(' - Your API key starts with "lsv2_pt_"');
console.log(' - Your API key is valid and active');
} else if (response.status === 404) {
console.log('💡 This is likely a URL issue. Make sure:');
console.log(' - Your deployment URL is correct');
console.log(' - Your agent is named "agent" in the deployment');
}
}
} catch (error) {
console.log(`❌ Connection error: ${error.message}\n`);
console.log('💡 Check your internet connection and deployment URL');
}
}
testConnection();