-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-multi-provider.js
More file actions
83 lines (72 loc) · 2.8 KB
/
test-multi-provider.js
File metadata and controls
83 lines (72 loc) · 2.8 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
77
78
79
80
81
82
83
#!/usr/bin/env node
/**
* Quick test script to verify multi-provider functionality
*/
import { UniversalAIClient, AIProvider } from './packages/core/dist/src/ai/index.js';
async function testProviders() {
console.log('🧪 Testing Multi-Provider Functionality\n');
// Test 1: Environment configuration
console.log('📋 Test 1: Environment Configuration Detection');
try {
const envClient = UniversalAIClient.fromEnvironment();
const info = envClient.getProviderInfo();
console.log(`✅ Provider: ${info.provider}`);
console.log(`✅ Model: ${info.model}\n`);
} catch (error) {
console.log(`❌ Environment config error: ${error.message}\n`);
}
// Test 1.5: Proxy configuration test
console.log('📋 Test 1.5: Proxy Configuration Detection');
try {
const { ProxyUtils } = await import('./packages/core/dist/src/utils/proxyUtils.js');
console.log(`✅ Proxy configured: ${ProxyUtils.isProxyConfigured()}`);
const proxyUrl = ProxyUtils.getProxyUrl();
if (proxyUrl) {
console.log(`✅ Proxy URL: ${proxyUrl}`);
}
console.log(`✅ SSL skip: ${ProxyUtils.shouldSkipSslVerification()}\n`);
} catch (error) {
console.log(`❌ Proxy utils error: ${error.message}\n`);
}
// Test 2: Direct configuration
console.log('📋 Test 2: Direct Provider Configuration');
const testConfigs = [
{
provider: AIProvider.GEMINI,
model: 'gemini-2.5-pro',
apiKey: process.env.GEMINI_API_KEY || 'test-key',
},
{
provider: AIProvider.OPENAI,
model: 'gpt-4o',
apiKey: process.env.OPENAI_API_KEY || 'test-key',
},
{
provider: AIProvider.ANTHROPIC,
model: 'claude-3-5-sonnet-20241022',
apiKey: process.env.ANTHROPIC_API_KEY || 'test-key',
},
];
for (const config of testConfigs) {
try {
const client = new UniversalAIClient(config);
const info = client.getProviderInfo();
console.log(`✅ ${config.provider}: Configured with model ${info.model}`);
// Test connection (will fail without real API key, but structure should work)
const connectionTest = await client.testConnection();
if (connectionTest.success) {
console.log(` ✅ Connection successful`);
} else {
console.log(` ⚠️ Connection failed (expected without real API key): ${connectionTest.error}`);
}
} catch (error) {
console.log(`❌ ${config.provider}: Configuration error: ${error.message}`);
}
}
console.log('\n🎉 Multi-provider system structure is working correctly!');
console.log('\n💡 To test with real providers, set these environment variables:');
console.log('export HYPERCODE_PROVIDER=openai');
console.log('export HYPERCODE_API_KEY=your-api-key');
console.log('export HYPERCODE_MODEL=gpt-4o');
}
testProviders().catch(console.error);