-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-preferences-debug.js
More file actions
107 lines (90 loc) · 3.29 KB
/
test-preferences-debug.js
File metadata and controls
107 lines (90 loc) · 3.29 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env node
const BASE_URL = 'http://localhost:8080/api';
// Get token from environment
const AUTH_TOKEN = process.env.AUTH_TOKEN;
if (!AUTH_TOKEN) {
console.error('❌ AUTH_TOKEN environment variable not set');
process.exit(1);
}
async function checkKnowledgeSources() {
console.log('\n📚 Checking Knowledge Sources\n');
try {
const response = await fetch(`${BASE_URL}/knowledge-sources`, {
headers: {
'Authorization': `Bearer ${AUTH_TOKEN}`,
},
});
const data = await response.json();
if (response.ok) {
console.log(`✅ Found ${data.sources?.length || 0} knowledge sources`);
if (data.sources && data.sources.length > 0) {
data.sources.forEach((source, idx) => {
console.log(`\n${idx + 1}. Type: ${source.source_type}`);
console.log(` Status: ${source.processing_status}`);
console.log(` Created: ${source.created_at}`);
if (source.source_identifier) {
console.log(` Identifier: ${source.source_identifier}`);
}
});
} else {
console.log('\n⚠️ No knowledge sources found. Add a resume or LinkedIn profile first.');
}
} else {
console.log('❌ Failed to fetch knowledge sources:', data);
}
} catch (error) {
console.error('❌ Request failed:', error.message);
}
}
async function testPreferencesPredict() {
console.log('\n🧪 Testing Preferences Prediction\n');
const startTime = Date.now();
try {
const response = await fetch(`${BASE_URL}/preferences/predict`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${AUTH_TOKEN}`,
'Content-Type': 'application/json',
},
});
const duration = Date.now() - startTime;
const data = await response.json();
console.log(`Status: ${response.status}`);
console.log(`Duration: ${duration}ms`);
console.log('\nResponse:');
console.log(JSON.stringify(data, null, 2));
if (response.ok) {
console.log('\n✅ Preferences prediction succeeded!');
if (data.preferences) {
console.log(`\nPredicted Industries: ${data.preferences.preferred_industries?.length || 0}`);
console.log(`Predicted Roles: ${data.preferences.preferred_roles?.length || 0}`);
console.log(`Predicted Companies: ${data.preferences.preferred_companies?.length || 0}`);
if (data.preferences.preferred_industries?.length > 0) {
console.log('\nTop Industries:', data.preferences.preferred_industries.slice(0, 3).join(', '));
}
if (data.preferences.preferred_roles?.length > 0) {
console.log('Top Roles:', data.preferences.preferred_roles.slice(0, 3).join(', '));
}
}
} else {
console.log('\n❌ Preferences prediction failed');
if (data.message) {
console.log(`\nError message: ${data.message}`);
}
if (data.stack) {
console.log(`\nStack trace:\n${data.stack}`);
}
if (data.name) {
console.log(`Error type: ${data.name}`);
}
}
} catch (error) {
console.error('\n❌ Request failed:', error.message);
}
}
async function main() {
await checkKnowledgeSources();
console.log('\n' + '='.repeat(60));
await testPreferencesPredict();
}
main().catch(console.error);