@postalsys/email-ai-tools 1.12.1 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test.yaml +34 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +20 -0
- package/package.json +7 -7
- package/test/embeddings-query.test.js +304 -0
- package/test/generate-embeddings.test.js +103 -0
- package/test/generate-summary.test.js +328 -0
- package/test/helpers/mock-server.js +136 -0
- package/test/index.test.js +45 -0
- package/test/list-models.test.js +207 -0
- package/test/risk-analysis.test.js +211 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { describe, it, before, after, beforeEach } = require('node:test');
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const { createMockServer, chatResponse, instructResponse, errorResponse } = require('./helpers/mock-server');
|
|
6
|
+
const { generateSummary } = require('../lib/generate-summary');
|
|
7
|
+
|
|
8
|
+
describe('generateSummary', () => {
|
|
9
|
+
let mock;
|
|
10
|
+
|
|
11
|
+
before(async () => {
|
|
12
|
+
mock = await createMockServer();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
after(async () => {
|
|
16
|
+
await mock.close();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
mock.clearRequests();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const simpleMessage = {
|
|
24
|
+
headers: [
|
|
25
|
+
{ key: 'from', value: 'sender@example.com' },
|
|
26
|
+
{ key: 'to', value: 'recipient@example.com' },
|
|
27
|
+
{ key: 'subject', value: 'Test Subject' }
|
|
28
|
+
],
|
|
29
|
+
text: 'Hello, this is a test email.'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const summaryResult = {
|
|
33
|
+
sentiment: 'neutral',
|
|
34
|
+
summary: 'A test email greeting.',
|
|
35
|
+
shouldReply: false,
|
|
36
|
+
riskAssessment: { risk: 1, assessment: 'Low risk message.' }
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
it('returns structured response from chat API', async () => {
|
|
40
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
41
|
+
|
|
42
|
+
const result = await generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url });
|
|
43
|
+
|
|
44
|
+
assert.equal(result.sentiment, 'neutral');
|
|
45
|
+
assert.equal(result.summary, 'A test email greeting.');
|
|
46
|
+
assert.equal(result.shouldReply, false);
|
|
47
|
+
assert.deepEqual(result.riskAssessment, { risk: 1, assessment: 'Low risk message.' });
|
|
48
|
+
assert.equal(result.id, 'chatcmpl-test123');
|
|
49
|
+
assert.equal(result.tokens, 150);
|
|
50
|
+
assert.equal(result.model, 'gpt-5-mini');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('sends correct request to chat API endpoint', async () => {
|
|
54
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
55
|
+
|
|
56
|
+
await generateSummary(simpleMessage, 'my-api-key', {
|
|
57
|
+
baseApiUrl: mock.url,
|
|
58
|
+
user: 'user123',
|
|
59
|
+
temperature: 0.7,
|
|
60
|
+
topP: 0.9
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const req = mock.requests[0];
|
|
64
|
+
assert.equal(req.method, 'POST');
|
|
65
|
+
assert.equal(req.url, '/v1/chat/completions');
|
|
66
|
+
assert.ok(req.headers.authorization.includes('Bearer my-api-key'));
|
|
67
|
+
assert.equal(req.body.model, 'gpt-5-mini');
|
|
68
|
+
assert.equal(req.body.user, 'user123');
|
|
69
|
+
assert.equal(req.body.temperature, 0.7);
|
|
70
|
+
assert.equal(req.body.top_p, 0.9);
|
|
71
|
+
assert.ok(Array.isArray(req.body.messages));
|
|
72
|
+
assert.equal(req.body.messages.length, 2);
|
|
73
|
+
assert.equal(req.body.messages[0].role, 'system');
|
|
74
|
+
assert.equal(req.body.messages[1].role, 'user');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('converts HTML to text when HTML is longer', async () => {
|
|
78
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
79
|
+
|
|
80
|
+
const htmlMessage = {
|
|
81
|
+
headers: [{ key: 'from', value: 'test@example.com' }],
|
|
82
|
+
text: 'Short',
|
|
83
|
+
html: '<p>This is a much longer HTML content that should be converted to text and used instead of the short plain text version.</p>'
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
await generateSummary(htmlMessage, 'test-token', { baseApiUrl: mock.url });
|
|
87
|
+
|
|
88
|
+
const req = mock.requests[0];
|
|
89
|
+
const userContent = req.body.messages[1].content;
|
|
90
|
+
assert.ok(userContent.includes('This is a much longer HTML content'));
|
|
91
|
+
assert.ok(!userContent.includes('<p>'));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('filters headers using whitelist', async () => {
|
|
95
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
96
|
+
|
|
97
|
+
const messageWithExtraHeaders = {
|
|
98
|
+
headers: [
|
|
99
|
+
{ key: 'from', value: 'test@example.com' },
|
|
100
|
+
{ key: 'subject', value: 'Test' },
|
|
101
|
+
{ key: 'x-custom-header', value: 'should be filtered' },
|
|
102
|
+
{ key: 'received', value: 'should be filtered' },
|
|
103
|
+
{ key: 'authentication-results', value: 'spf=pass' }
|
|
104
|
+
],
|
|
105
|
+
text: 'Test email'
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
await generateSummary(messageWithExtraHeaders, 'test-token', { baseApiUrl: mock.url });
|
|
109
|
+
|
|
110
|
+
const userContent = mock.requests[0].body.messages[1].content;
|
|
111
|
+
assert.ok(userContent.includes('authentication-results'));
|
|
112
|
+
assert.ok(!userContent.includes('x-custom-header'));
|
|
113
|
+
assert.ok(!userContent.includes('received'));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('deduplicates authentication headers', async () => {
|
|
117
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
118
|
+
|
|
119
|
+
const messageWithDupAuth = {
|
|
120
|
+
headers: [
|
|
121
|
+
{ key: 'from', value: 'test@example.com' },
|
|
122
|
+
{ key: 'authentication-results', value: 'first result' },
|
|
123
|
+
{ key: 'authentication-results', value: 'second result' }
|
|
124
|
+
],
|
|
125
|
+
text: 'Test'
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
await generateSummary(messageWithDupAuth, 'test-token', { baseApiUrl: mock.url });
|
|
129
|
+
|
|
130
|
+
const userContent = mock.requests[0].body.messages[1].content;
|
|
131
|
+
assert.ok(userContent.includes('first result'));
|
|
132
|
+
assert.ok(!userContent.includes('second result'));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('merges custom allowedHeaders with defaults', async () => {
|
|
136
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
137
|
+
|
|
138
|
+
const messageWithCustomHeader = {
|
|
139
|
+
headers: [
|
|
140
|
+
{ key: 'from', value: 'test@example.com' },
|
|
141
|
+
{ key: 'x-priority', value: '1 (Highest)' }
|
|
142
|
+
],
|
|
143
|
+
text: 'Urgent email'
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
await generateSummary(messageWithCustomHeader, 'test-token', {
|
|
147
|
+
baseApiUrl: mock.url,
|
|
148
|
+
allowedHeaders: ['x-priority']
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const userContent = mock.requests[0].body.messages[1].content;
|
|
152
|
+
assert.ok(userContent.includes('x-priority'));
|
|
153
|
+
assert.ok(userContent.includes('1 (Highest)'));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('uses instruct endpoint for gpt-3.5-turbo-instruct', async () => {
|
|
157
|
+
mock.setHandler(() => instructResponse(JSON.stringify(summaryResult)));
|
|
158
|
+
|
|
159
|
+
const result = await generateSummary(simpleMessage, 'test-token', {
|
|
160
|
+
baseApiUrl: mock.url,
|
|
161
|
+
gptModel: 'gpt-3.5-turbo-instruct'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
assert.equal(result.model, 'gpt-3.5-turbo-instruct');
|
|
165
|
+
const req = mock.requests[0];
|
|
166
|
+
assert.equal(req.url, '/v1/completions');
|
|
167
|
+
assert.ok(typeof req.body.prompt === 'string');
|
|
168
|
+
assert.ok(req.body.max_tokens > 0);
|
|
169
|
+
assert.ok(!req.body.messages);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('removes null and empty string values from response', async () => {
|
|
173
|
+
mock.setHandler(() =>
|
|
174
|
+
chatResponse({
|
|
175
|
+
sentiment: 'neutral',
|
|
176
|
+
summary: 'Test',
|
|
177
|
+
shouldReply: false,
|
|
178
|
+
riskAssessment: { risk: 1, assessment: null },
|
|
179
|
+
events: null,
|
|
180
|
+
replyText: ''
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const result = await generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url });
|
|
185
|
+
|
|
186
|
+
assert.equal(result.sentiment, 'neutral');
|
|
187
|
+
assert.ok(!('assessment' in result.riskAssessment));
|
|
188
|
+
assert.ok(!('events' in result));
|
|
189
|
+
assert.ok(!('replyText' in result));
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('extracts JSON from response with surrounding text', async () => {
|
|
193
|
+
mock.setHandler(() =>
|
|
194
|
+
chatResponse(
|
|
195
|
+
'Here is my analysis:\n' +
|
|
196
|
+
'{"sentiment":"positive","summary":"Extracted JSON","shouldReply":true,"riskAssessment":{"risk":1}}\n' +
|
|
197
|
+
'End of analysis.'
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const result = await generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url });
|
|
202
|
+
|
|
203
|
+
assert.equal(result.sentiment, 'positive');
|
|
204
|
+
assert.equal(result.summary, 'Extracted JSON');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('uses custom system and user prompts', async () => {
|
|
208
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
209
|
+
|
|
210
|
+
await generateSummary(simpleMessage, 'test-token', {
|
|
211
|
+
baseApiUrl: mock.url,
|
|
212
|
+
systemPrompt: 'Custom system prompt here',
|
|
213
|
+
userPrompt: 'Custom user prompt here'
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const req = mock.requests[0];
|
|
217
|
+
assert.equal(req.body.messages[0].content, 'Custom system prompt here');
|
|
218
|
+
assert.ok(req.body.messages[1].content.startsWith('Custom user prompt here'));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('handles message with attachments', async () => {
|
|
222
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
223
|
+
|
|
224
|
+
const messageWithAttachments = {
|
|
225
|
+
headers: [{ key: 'from', value: 'test@example.com' }],
|
|
226
|
+
text: 'See attached.',
|
|
227
|
+
attachments: [
|
|
228
|
+
{ filename: 'document.pdf', contentType: 'application/pdf' },
|
|
229
|
+
{ filename: 'image.png', contentType: 'image/png' }
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const result = await generateSummary(messageWithAttachments, 'test-token', { baseApiUrl: mock.url });
|
|
234
|
+
|
|
235
|
+
assert.equal(result.sentiment, 'neutral');
|
|
236
|
+
const userContent = mock.requests[0].body.messages[1].content;
|
|
237
|
+
assert.ok(userContent.includes('document.pdf'));
|
|
238
|
+
assert.ok(userContent.includes('image.png'));
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('handles empty message', async () => {
|
|
242
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
243
|
+
|
|
244
|
+
const result = await generateSummary({ headers: [], text: '' }, 'test-token', { baseApiUrl: mock.url });
|
|
245
|
+
|
|
246
|
+
assert.equal(result.sentiment, 'neutral');
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('retries on 429 rate limit', { timeout: 10000 }, async () => {
|
|
250
|
+
let callCount = 0;
|
|
251
|
+
mock.setHandler(() => {
|
|
252
|
+
callCount++;
|
|
253
|
+
if (callCount === 1) {
|
|
254
|
+
return errorResponse(429, 'Rate limit exceeded');
|
|
255
|
+
}
|
|
256
|
+
return chatResponse(summaryResult);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const result = await generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url });
|
|
260
|
+
|
|
261
|
+
assert.equal(result.summary, 'A test email greeting.');
|
|
262
|
+
assert.equal(callCount, 2);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('throws on non-429 API errors with error details', async () => {
|
|
266
|
+
mock.setHandler(() => errorResponse(500, 'Internal server error', 'server_error'));
|
|
267
|
+
|
|
268
|
+
await assert.rejects(
|
|
269
|
+
() => generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url }),
|
|
270
|
+
err => {
|
|
271
|
+
assert.equal(err.message, 'Internal server error');
|
|
272
|
+
assert.equal(err.code, 'server_error');
|
|
273
|
+
assert.equal(err.statusCode, 500);
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('throws generic error on API failure without error details', async () => {
|
|
280
|
+
mock.setHandler(() => ({ status: 503, body: {} }));
|
|
281
|
+
|
|
282
|
+
await assert.rejects(
|
|
283
|
+
() => generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url }),
|
|
284
|
+
err => {
|
|
285
|
+
assert.equal(err.message, 'Failed to run API request');
|
|
286
|
+
assert.equal(err.statusCode, 503);
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('throws on invalid JSON response', async () => {
|
|
293
|
+
mock.setHandler(() => chatResponse('This response contains no JSON at all'));
|
|
294
|
+
|
|
295
|
+
await assert.rejects(
|
|
296
|
+
() => generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url }),
|
|
297
|
+
err => {
|
|
298
|
+
assert.ok(err.message.includes('Failed to parse'));
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('includes verbose fields when verbose is true', async () => {
|
|
305
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
306
|
+
|
|
307
|
+
const result = await generateSummary(simpleMessage, 'test-token', {
|
|
308
|
+
baseApiUrl: mock.url,
|
|
309
|
+
verbose: true
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
assert.ok('_text' in result);
|
|
313
|
+
assert.ok('_time' in result);
|
|
314
|
+
assert.ok('_cr' in result);
|
|
315
|
+
assert.equal(typeof result._time, 'number');
|
|
316
|
+
assert.ok(result._time >= 0);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('does not include verbose fields by default', async () => {
|
|
320
|
+
mock.setHandler(() => chatResponse(summaryResult));
|
|
321
|
+
|
|
322
|
+
const result = await generateSummary(simpleMessage, 'test-token', { baseApiUrl: mock.url });
|
|
323
|
+
|
|
324
|
+
assert.ok(!('_text' in result));
|
|
325
|
+
assert.ok(!('_time' in result));
|
|
326
|
+
assert.ok(!('_cr' in result));
|
|
327
|
+
});
|
|
328
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const http = require('node:http');
|
|
4
|
+
|
|
5
|
+
async function createMockServer() {
|
|
6
|
+
let requestHandler = () => ({ status: 500, body: { error: 'No handler set' } });
|
|
7
|
+
const requests = [];
|
|
8
|
+
|
|
9
|
+
const server = http.createServer((req, res) => {
|
|
10
|
+
let body = '';
|
|
11
|
+
req.on('data', chunk => {
|
|
12
|
+
body += chunk;
|
|
13
|
+
});
|
|
14
|
+
req.on('end', () => {
|
|
15
|
+
let parsedBody = null;
|
|
16
|
+
try {
|
|
17
|
+
if (body) {
|
|
18
|
+
parsedBody = JSON.parse(body);
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
parsedBody = body;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
requests.push({
|
|
25
|
+
method: req.method,
|
|
26
|
+
url: req.url,
|
|
27
|
+
headers: req.headers,
|
|
28
|
+
body: parsedBody
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const response = requestHandler(req, parsedBody);
|
|
32
|
+
res.writeHead(response.status || 200, { 'Content-Type': 'application/json' });
|
|
33
|
+
res.end(JSON.stringify(response.body || {}));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
|
38
|
+
const { port } = server.address();
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
url: `http://127.0.0.1:${port}`,
|
|
42
|
+
get requests() {
|
|
43
|
+
return requests;
|
|
44
|
+
},
|
|
45
|
+
clearRequests() {
|
|
46
|
+
requests.length = 0;
|
|
47
|
+
},
|
|
48
|
+
setHandler(fn) {
|
|
49
|
+
requestHandler = fn;
|
|
50
|
+
},
|
|
51
|
+
async close() {
|
|
52
|
+
await new Promise(resolve => server.close(resolve));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function chatResponse(content, opts) {
|
|
58
|
+
opts = opts || {};
|
|
59
|
+
return {
|
|
60
|
+
status: 200,
|
|
61
|
+
body: {
|
|
62
|
+
id: opts.id || 'chatcmpl-test123',
|
|
63
|
+
choices: [
|
|
64
|
+
{
|
|
65
|
+
index: 0,
|
|
66
|
+
message: {
|
|
67
|
+
role: 'assistant',
|
|
68
|
+
content: typeof content === 'string' ? content : JSON.stringify(content)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
usage: { total_tokens: opts.tokens || 150 }
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function instructResponse(content, opts) {
|
|
78
|
+
opts = opts || {};
|
|
79
|
+
return {
|
|
80
|
+
status: 200,
|
|
81
|
+
body: {
|
|
82
|
+
id: opts.id || 'cmpl-test123',
|
|
83
|
+
choices: [
|
|
84
|
+
{
|
|
85
|
+
index: 0,
|
|
86
|
+
text: typeof content === 'string' ? content : JSON.stringify(content)
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
usage: { total_tokens: opts.tokens || 100 }
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function embeddingResponse(embedding) {
|
|
95
|
+
return {
|
|
96
|
+
status: 200,
|
|
97
|
+
body: {
|
|
98
|
+
data: [{ embedding: embedding || [0.1, 0.2, 0.3] }],
|
|
99
|
+
usage: { total_tokens: 50 }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function modelsResponse(models) {
|
|
105
|
+
return {
|
|
106
|
+
status: 200,
|
|
107
|
+
body: {
|
|
108
|
+
data: models || [
|
|
109
|
+
{ id: 'gpt-4', owned_by: 'openai' },
|
|
110
|
+
{ id: 'gpt-3.5-turbo', owned_by: 'openai' },
|
|
111
|
+
{ id: 'text-embedding-ada-002', owned_by: 'openai' }
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function errorResponse(status, message, code) {
|
|
118
|
+
return {
|
|
119
|
+
status,
|
|
120
|
+
body: {
|
|
121
|
+
error: {
|
|
122
|
+
message,
|
|
123
|
+
code
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
createMockServer,
|
|
131
|
+
chatResponse,
|
|
132
|
+
instructResponse,
|
|
133
|
+
embeddingResponse,
|
|
134
|
+
modelsResponse,
|
|
135
|
+
errorResponse
|
|
136
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { describe, it } = require('node:test');
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const lib = require('../index');
|
|
6
|
+
|
|
7
|
+
describe('index exports', () => {
|
|
8
|
+
it('exports generateSummary as a function', () => {
|
|
9
|
+
assert.equal(typeof lib.generateSummary, 'function');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('exports generateEmbeddings as a function', () => {
|
|
13
|
+
assert.equal(typeof lib.generateEmbeddings, 'function');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('exports getChunkEmbeddings as a function', () => {
|
|
17
|
+
assert.equal(typeof lib.getChunkEmbeddings, 'function');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('exports embeddingsQuery as a function', () => {
|
|
21
|
+
assert.equal(typeof lib.embeddingsQuery, 'function');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('exports questionQuery as a function', () => {
|
|
25
|
+
assert.equal(typeof lib.questionQuery, 'function');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('exports riskAnalysis as a function', () => {
|
|
29
|
+
assert.equal(typeof lib.riskAnalysis, 'function');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('exports listModels as a function', () => {
|
|
33
|
+
assert.equal(typeof lib.listModels, 'function');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('exports DEFAULT_SYSTEM_PROMPT as a non-empty string', () => {
|
|
37
|
+
assert.equal(typeof lib.DEFAULT_SYSTEM_PROMPT, 'string');
|
|
38
|
+
assert.ok(lib.DEFAULT_SYSTEM_PROMPT.length > 0);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('exports DEFAULT_USER_PROMPT as a non-empty string', () => {
|
|
42
|
+
assert.equal(typeof lib.DEFAULT_USER_PROMPT, 'string');
|
|
43
|
+
assert.ok(lib.DEFAULT_USER_PROMPT.length > 0);
|
|
44
|
+
});
|
|
45
|
+
});
|