-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeep-debug-nlp.ts
More file actions
61 lines (46 loc) · 1.61 KB
/
deep-debug-nlp.ts
File metadata and controls
61 lines (46 loc) · 1.61 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
#!/usr/bin/env bun
/**
* Deep Debug NLP - trace exactly where processQuery fails
*/
import { processQuery } from '../src/ai/orchestrator.js';
import chalk from 'chalk';
async function deepDebugNLP() {
console.log("🔍 DEEP DEBUGGING NLP PROCESS\n");
// Test data
const catalog = [
{ attribute: 'name', type: 'string', examples: ['Alice Johnson', 'iPhone 15'] },
{ attribute: 'email', type: 'string', examples: ['alice@gmail.com'] },
];
const dataStats = {
totalFacts: 22,
uniqueEntities: 3,
uniqueAttributes: 9
};
const failingQuery = "users with gmail emails";
console.log(`Testing query: ${chalk.yellow(`"${failingQuery}"`)}\n`);
try {
console.log("🤖 Calling processQuery...");
const startTime = Date.now();
const result = await processQuery(failingQuery, { catalog, dataStats });
const endTime = Date.now();
console.log(`⏱️ Processing took: ${endTime - startTime}ms\n`);
console.log("📤 RAW RESULT:");
console.log(JSON.stringify(result, null, 2));
console.log();
if (result.error) {
console.log(chalk.red(`❌ Error: ${result.error}`));
} else if (result.eqlsQuery) {
console.log(chalk.green(`✅ Success: ${result.eqlsQuery}`));
} else {
console.log(chalk.yellow("⚠️ No error but no query either"));
}
} catch (error) {
console.log(chalk.red("💥 EXCEPTION CAUGHT:"));
console.log(error);
if (error instanceof Error) {
console.log(`Message: ${error.message}`);
console.log(`Stack: ${error.stack}`);
}
}
}
deepDebugNLP().catch(console.error);