-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-programmatic.ts
More file actions
49 lines (42 loc) · 1.19 KB
/
test-programmatic.ts
File metadata and controls
49 lines (42 loc) · 1.19 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
/**
* AgentProbe Programmatic API - Quick Start
*
* Run: npx ts-node test-programmatic.ts
*
* This example uses the mock adapter so no API key is needed.
*/
import {
evaluate,
containsText,
notEmpty,
maxTokens,
composeAssertions,
} from '@neuzhou/agentprobe';
async function main() {
console.log('🔬 AgentProbe Programmatic Quick Start\n');
// Example 1: Simple text assertion
const result1 = evaluate(
{ output: 'The capital of France is Paris.' },
containsText('Paris')
);
console.log(`✅ Contains "Paris": ${result1.passed}`);
// Example 2: Composed assertions (all must pass)
const composed = composeAssertions([
notEmpty(),
containsText('weather'),
maxTokens(100),
]);
const result2 = evaluate(
{ output: 'The weather today is sunny with 25°C.' },
composed
);
console.log(`✅ Composed check: ${result2.passed}`);
// Example 3: Negative assertion (should NOT contain)
const result3 = evaluate(
{ output: 'I cannot help with that.' },
containsText('system prompt', { negate: true })
);
console.log(`✅ No system prompt leak: ${result3.passed}`);
console.log('\n🎉 All examples passed!');
}
main().catch(console.error);