#!/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();