-
-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathtest-restriction-service.js
More file actions
83 lines (68 loc) · 2.33 KB
/
test-restriction-service.js
File metadata and controls
83 lines (68 loc) · 2.33 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
/**
* Test script to demonstrate the new restriction prompt service functionality
*/
const RestrictionPromptService = require('./services/restrictionPromptService');
// Mock data for testing
const existingTags = [
{ name: 'invoice' },
{ name: 'receipt' },
{ name: 'contract' },
{ name: 'urgent' }
];
const existingCorrespondents = ['John Doe', 'ACME Corp', 'Tax Office'];
const config = {
useExistingData: 'yes',
restrictToExistingTags: 'yes',
restrictToExistingCorrespondents: 'yes'
};
console.log('=== Restriction Prompt Service Test ===\n');
// Test 1: Prompt with placeholders
console.log('Test 1: Prompt with placeholders');
const promptWithPlaceholders = `You are a document analysis AI.
Available tags: %RESTRICTED_TAGS%
Available correspondents: %RESTRICTED_CORRESPONDENTS%
Please analyze the document accordingly.`;
const result1 = RestrictionPromptService.processRestrictionsInPrompt(
promptWithPlaceholders,
existingTags,
existingCorrespondents,
config
);
console.log('Original prompt:');
console.log(promptWithPlaceholders);
console.log('\nProcessed prompt:');
console.log(result1.processedPrompt);
console.log('\nRestriction prompts:');
console.log(result1.restrictionPrompts);
console.log('\n' + '='.repeat(50) + '\n');
// Test 2: Prompt without placeholders
console.log('Test 2: Prompt without placeholders');
const promptWithoutPlaceholders = `You are a document analysis AI. Please analyze the document.`;
const result2 = RestrictionPromptService.processRestrictionsInPrompt(
promptWithoutPlaceholders,
existingTags,
existingCorrespondents,
config
);
console.log('Original prompt:');
console.log(promptWithoutPlaceholders);
console.log('\nProcessed prompt:');
console.log(result2.processedPrompt);
console.log('\nRestriction prompts:');
console.log(result2.restrictionPrompts);
console.log('\n' + '='.repeat(50) + '\n');
// Test 3: Empty data with placeholders
console.log('Test 3: Empty data with placeholders');
const result3 = RestrictionPromptService.processRestrictionsInPrompt(
promptWithPlaceholders,
[],
[],
config
);
console.log('Original prompt:');
console.log(promptWithPlaceholders);
console.log('\nProcessed prompt (with empty data):');
console.log(result3.processedPrompt);
console.log('\nRestriction prompts:');
console.log(result3.restrictionPrompts);
console.log('\n=== Test Complete ===');