|
#!/usr/bin/env node |
|
|
|
const fetch = require('node-fetch'); |
|
|
|
async function testNebiusSetup() { |
|
console.log('π§ͺ Testing Nebius Integration...\n'); |
|
|
|
const baseUrl = 'http://localhost:5000'; |
|
|
|
try { |
|
|
|
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); |
|
} |
|
|
|
|
|
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); |
|
} |
|
|
|
|
|
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); |
|
} |
|
|
|
|
|
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(); |