-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-manual.ts
More file actions
76 lines (67 loc) · 2.44 KB
/
Copy pathtest-manual.ts
File metadata and controls
76 lines (67 loc) · 2.44 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
/**
* Manual integration test for NOPE Node SDK.
*
* Run with: npx tsx test-manual.ts
*/
import { NopeClient } from './src/client.js';
const API_URL = process.env.NOPE_API_URL ?? 'http://localhost:3700';
console.log(`Testing against: ${API_URL}`);
const client = new NopeClient({
baseUrl: API_URL,
});
console.log('\n--- Test 1: Low risk message ---');
try {
const result = await client.evaluate({
messages: [{ role: 'user', content: 'Hello, how are you?' }],
config: { user_country: 'US' },
});
console.log(`Success! Severity: ${result.global.overall_severity}`);
console.log(`Domains: ${result.domains.length}`);
console.log(`Resources: ${result.crisis_resources.length}`);
} catch (e) {
console.log(`Error: ${(e as Error).name}: ${(e as Error).message}`);
}
console.log('\n--- Test 2: Moderate risk message ---');
try {
const result = await client.evaluate({
messages: [
{ role: 'user', content: "I've been feeling really hopeless lately" },
],
config: { user_country: 'US' },
});
console.log(`Success! Severity: ${result.global.overall_severity}`);
console.log(`Imminence: ${result.global.overall_imminence}`);
console.log(`Concerns: ${result.global.primary_concerns.join(', ')}`);
if (result.crisis_resources.length > 0) {
console.log(`First resource: ${result.crisis_resources[0].name}`);
}
} catch (e) {
console.log(`Error: ${(e as Error).name}: ${(e as Error).message}`);
}
console.log('\n--- Test 3: Text input ---');
try {
const result = await client.evaluate({
text: 'Patient reports feeling overwhelmed.',
config: { user_country: 'GB' },
});
console.log(`Success! Severity: ${result.global.overall_severity}`);
} catch (e) {
console.log(`Error: ${(e as Error).name}: ${(e as Error).message}`);
}
console.log('\n--- Test 4: Parse all domain types ---');
try {
const result = await client.evaluate({
messages: [{ role: 'user', content: 'I feel so overwhelmed and anxious' }],
config: { user_country: 'US' },
});
console.log(`Success! Domains found: ${result.domains.length}`);
for (const domain of result.domains) {
console.log(` Domain: ${domain.domain}`);
console.log(` Severity: ${domain.severity}`);
console.log(` Imminence: ${domain.imminence}`);
console.log(` Risk features: ${domain.risk_features.join(', ')}`);
}
} catch (e) {
console.log(`Error: ${(e as Error).name}: ${(e as Error).message}`);
}
console.log('\n--- All tests complete ---');