File size: 2,991 Bytes
7c012de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env node

const fetch = require('node-fetch');

async function testNebiusSetup() {
  console.log('πŸ§ͺ Testing Nebius Integration...\n');
  
  const baseUrl = 'http://localhost:5000';
  
  try {
    // Test 1: Health Check
    console.log('1. Testing API Health...');
    const healthResponse = await fetch(`${baseUrl}/api/health`);
    if (healthResponse.ok) {
      const health = await healthResponse.json();
      console.log('βœ… Health check passed');
      console.log('Services status:', health.services?.map(s => `${s.service}: ${s.status}`).join(', '));
    } else {
      console.log('❌ Health check failed:', healthResponse.status);
    }
    
    // Test 2: Documents endpoint
    console.log('\n2. Testing Documents API...');
    const docsResponse = await fetch(`${baseUrl}/api/documents`);
    if (docsResponse.ok) {
      const docs = await docsResponse.json();
      console.log(`βœ… Documents API working (${docs.length} documents found)`);
    } else {
      console.log('❌ Documents API failed:', docsResponse.status);
    }
    
    // Test 3: Query Enhancement (Nebius)
    console.log('\n3. Testing Nebius Query Enhancement...');
    const enhanceResponse = await fetch(`${baseUrl}/api/enhance-query`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ query: 'machine learning' })
    });
    
    if (enhanceResponse.ok) {
      const enhancement = await enhanceResponse.json();
      console.log('βœ… Nebius query enhancement working');
      console.log('Enhanced query:', enhancement.enhancedQuery);
      console.log('Intent:', enhancement.intent);
    } else {
      console.log('❌ Nebius query enhancement failed:', enhanceResponse.status);
      const error = await enhanceResponse.text();
      console.log('Error:', error);
    }
    
    // Test 4: AI Explanation (Nebius)
    console.log('\n4. Testing Nebius AI Explanation...');
    const explainResponse = await fetch(`${baseUrl}/api/explain`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ 
        title: 'Test Document',
        snippet: 'This is a test document about artificial intelligence and machine learning.'
      })
    });
    
    if (explainResponse.ok) {
      const explanation = await explainResponse.json();
      console.log('βœ… Nebius AI explanation working');
      console.log('Explanation:', explanation.explanation);
    } else {
      console.log('❌ Nebius AI explanation failed:', explainResponse.status);
      const error = await explainResponse.text();
      console.log('Error:', error);
    }
    
  } catch (error) {
    console.error('❌ Test failed with error:', error.message);
  }
  
  console.log('\nπŸŽ‰ Testing complete!');
  console.log('\nπŸ’‘ If all tests passed, your KnowledgeBridge app is ready with Nebius AI!');
  console.log('πŸ“± Open http://localhost:5000 in your browser to use the app.');
}

testNebiusSetup();