@aj-archipelago/cortex 1.4.2 → 1.4.3

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.
Files changed (86) hide show
  1. package/README.md +1 -0
  2. package/config.js +1 -1
  3. package/helper-apps/cortex-autogen2/.dockerignore +1 -0
  4. package/helper-apps/cortex-autogen2/Dockerfile +6 -10
  5. package/helper-apps/cortex-autogen2/Dockerfile.worker +2 -0
  6. package/helper-apps/cortex-autogen2/agents.py +203 -2
  7. package/helper-apps/cortex-autogen2/main.py +1 -1
  8. package/helper-apps/cortex-autogen2/pyproject.toml +12 -0
  9. package/helper-apps/cortex-autogen2/requirements.txt +14 -0
  10. package/helper-apps/cortex-autogen2/services/redis_publisher.py +1 -1
  11. package/helper-apps/cortex-autogen2/services/run_analyzer.py +1 -1
  12. package/helper-apps/cortex-autogen2/task_processor.py +431 -229
  13. package/helper-apps/cortex-autogen2/test_entity_fetcher.py +305 -0
  14. package/helper-apps/cortex-autogen2/tests/README.md +240 -0
  15. package/helper-apps/cortex-autogen2/tests/TEST_REPORT.md +342 -0
  16. package/helper-apps/cortex-autogen2/tests/__init__.py +8 -0
  17. package/helper-apps/cortex-autogen2/tests/analysis/__init__.py +1 -0
  18. package/helper-apps/cortex-autogen2/tests/analysis/improvement_suggester.py +224 -0
  19. package/helper-apps/cortex-autogen2/tests/analysis/trend_analyzer.py +211 -0
  20. package/helper-apps/cortex-autogen2/tests/cli/__init__.py +1 -0
  21. package/helper-apps/cortex-autogen2/tests/cli/run_tests.py +296 -0
  22. package/helper-apps/cortex-autogen2/tests/collectors/__init__.py +1 -0
  23. package/helper-apps/cortex-autogen2/tests/collectors/log_collector.py +252 -0
  24. package/helper-apps/cortex-autogen2/tests/collectors/progress_collector.py +182 -0
  25. package/helper-apps/cortex-autogen2/tests/conftest.py +15 -0
  26. package/helper-apps/cortex-autogen2/tests/database/__init__.py +1 -0
  27. package/helper-apps/cortex-autogen2/tests/database/repository.py +501 -0
  28. package/helper-apps/cortex-autogen2/tests/database/schema.sql +108 -0
  29. package/helper-apps/cortex-autogen2/tests/evaluators/__init__.py +1 -0
  30. package/helper-apps/cortex-autogen2/tests/evaluators/llm_scorer.py +294 -0
  31. package/helper-apps/cortex-autogen2/tests/evaluators/prompts.py +250 -0
  32. package/helper-apps/cortex-autogen2/tests/evaluators/wordcloud_validator.py +168 -0
  33. package/helper-apps/cortex-autogen2/tests/metrics/__init__.py +1 -0
  34. package/helper-apps/cortex-autogen2/tests/metrics/collector.py +155 -0
  35. package/helper-apps/cortex-autogen2/tests/orchestrator.py +576 -0
  36. package/helper-apps/cortex-autogen2/tests/test_cases.yaml +279 -0
  37. package/helper-apps/cortex-autogen2/tests/test_data.db +0 -0
  38. package/helper-apps/cortex-autogen2/tests/utils/__init__.py +3 -0
  39. package/helper-apps/cortex-autogen2/tests/utils/connectivity.py +112 -0
  40. package/helper-apps/cortex-autogen2/tools/azure_blob_tools.py +74 -24
  41. package/helper-apps/cortex-autogen2/tools/entity_api_registry.json +38 -0
  42. package/helper-apps/cortex-autogen2/tools/file_tools.py +1 -1
  43. package/helper-apps/cortex-autogen2/tools/search_tools.py +436 -238
  44. package/helper-apps/cortex-file-handler/package-lock.json +2 -2
  45. package/helper-apps/cortex-file-handler/package.json +1 -1
  46. package/helper-apps/cortex-file-handler/scripts/setup-test-containers.js +4 -5
  47. package/helper-apps/cortex-file-handler/src/blobHandler.js +36 -144
  48. package/helper-apps/cortex-file-handler/src/services/FileConversionService.js +5 -3
  49. package/helper-apps/cortex-file-handler/src/services/storage/AzureStorageProvider.js +34 -1
  50. package/helper-apps/cortex-file-handler/src/services/storage/GCSStorageProvider.js +22 -0
  51. package/helper-apps/cortex-file-handler/src/services/storage/LocalStorageProvider.js +28 -1
  52. package/helper-apps/cortex-file-handler/src/services/storage/StorageFactory.js +29 -4
  53. package/helper-apps/cortex-file-handler/src/services/storage/StorageProvider.js +11 -0
  54. package/helper-apps/cortex-file-handler/src/services/storage/StorageService.js +1 -1
  55. package/helper-apps/cortex-file-handler/tests/blobHandler.test.js +3 -2
  56. package/helper-apps/cortex-file-handler/tests/checkHashShortLived.test.js +8 -1
  57. package/helper-apps/cortex-file-handler/tests/containerConversionFlow.test.js +5 -2
  58. package/helper-apps/cortex-file-handler/tests/containerNameParsing.test.js +14 -7
  59. package/helper-apps/cortex-file-handler/tests/containerParameterFlow.test.js +5 -2
  60. package/helper-apps/cortex-file-handler/tests/storage/StorageFactory.test.js +31 -19
  61. package/package.json +1 -1
  62. package/server/modelExecutor.js +4 -0
  63. package/server/plugins/claude4VertexPlugin.js +540 -0
  64. package/server/plugins/openAiWhisperPlugin.js +43 -2
  65. package/tests/integration/rest/vendors/claude_streaming.test.js +121 -0
  66. package/tests/unit/plugins/claude4VertexPlugin.test.js +462 -0
  67. package/tests/unit/plugins/claude4VertexToolConversion.test.js +413 -0
  68. package/helper-apps/cortex-autogen/.funcignore +0 -8
  69. package/helper-apps/cortex-autogen/Dockerfile +0 -10
  70. package/helper-apps/cortex-autogen/OAI_CONFIG_LIST +0 -6
  71. package/helper-apps/cortex-autogen/agents.py +0 -493
  72. package/helper-apps/cortex-autogen/agents_extra.py +0 -14
  73. package/helper-apps/cortex-autogen/config.py +0 -18
  74. package/helper-apps/cortex-autogen/data_operations.py +0 -29
  75. package/helper-apps/cortex-autogen/function_app.py +0 -44
  76. package/helper-apps/cortex-autogen/host.json +0 -15
  77. package/helper-apps/cortex-autogen/main.py +0 -38
  78. package/helper-apps/cortex-autogen/prompts.py +0 -196
  79. package/helper-apps/cortex-autogen/prompts_extra.py +0 -5
  80. package/helper-apps/cortex-autogen/requirements.txt +0 -9
  81. package/helper-apps/cortex-autogen/search.py +0 -85
  82. package/helper-apps/cortex-autogen/test.sh +0 -40
  83. package/helper-apps/cortex-autogen/tools/sasfileuploader.py +0 -66
  84. package/helper-apps/cortex-autogen/utils.py +0 -88
  85. package/helper-apps/cortex-autogen2/DigiCertGlobalRootCA.crt.pem +0 -22
  86. package/helper-apps/cortex-autogen2/poetry.lock +0 -3652
@@ -0,0 +1,413 @@
1
+ import test from 'ava';
2
+ import Claude4VertexPlugin from '../../../server/plugins/claude4VertexPlugin.js';
3
+ import { mockPathwayResolverMessages } from '../../helpers/mocks.js';
4
+
5
+ const { pathway, modelName, model } = mockPathwayResolverMessages;
6
+
7
+ // Helper function to create a plugin instance
8
+ const createPlugin = () => new Claude4VertexPlugin(pathway, model);
9
+
10
+ // Test OpenAI tools block conversion
11
+ test('OpenAI tools block conversion', async (t) => {
12
+ const plugin = createPlugin();
13
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
14
+
15
+ const parameters = {
16
+ tools: [
17
+ {
18
+ type: 'function',
19
+ function: {
20
+ name: 'get_weather',
21
+ description: 'Get current temperature for a given location.',
22
+ parameters: {
23
+ type: 'object',
24
+ properties: {
25
+ location: {
26
+ type: 'string',
27
+ description: 'City and country e.g. Bogotá, Colombia'
28
+ }
29
+ },
30
+ required: ['location'],
31
+ additionalProperties: false
32
+ },
33
+ strict: true
34
+ }
35
+ }
36
+ ]
37
+ };
38
+
39
+ const cortexRequest = { tools: parameters.tools };
40
+ const result = await plugin.getRequestParameters('test', parameters, prompt, cortexRequest);
41
+
42
+ t.deepEqual(result.tools, [{
43
+ name: 'get_weather',
44
+ description: 'Get current temperature for a given location.',
45
+ input_schema: {
46
+ type: 'object',
47
+ properties: {
48
+ location: {
49
+ type: 'string',
50
+ description: 'City and country e.g. Bogotá, Colombia'
51
+ }
52
+ },
53
+ required: ['location']
54
+ }
55
+ }]);
56
+ });
57
+
58
+ // Test tool call conversion without tools block
59
+ test('Tool call conversion without tools block', async (t) => {
60
+ const plugin = createPlugin();
61
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
62
+
63
+ const messages = [
64
+ {
65
+ role: 'system',
66
+ content: 'You are a helpful assistant'
67
+ },
68
+ {
69
+ role: 'user',
70
+ content: 'What\'s in my memory?'
71
+ },
72
+ {
73
+ role: 'assistant',
74
+ content: [
75
+ {
76
+ type: 'tool_use',
77
+ id: 'tool_1',
78
+ name: 'memory_lookup',
79
+ input: 'search memory for relevant information'
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ role: 'user',
85
+ content: [
86
+ {
87
+ type: 'tool_result',
88
+ tool_use_id: 'tool_1',
89
+ content: 'Memory search results here'
90
+ }
91
+ ]
92
+ }
93
+ ];
94
+
95
+ // add messages to mockPrompt.messages
96
+ prompt.messages = messages;
97
+
98
+ const cortexRequest = {};
99
+ const result = await plugin.getRequestParameters('test', {}, prompt, cortexRequest);
100
+
101
+ // Check generated tools block
102
+ t.deepEqual(result.tools, [{
103
+ name: 'memory_lookup',
104
+ description: 'Tool for memory_lookup',
105
+ input_schema: {
106
+ type: 'object',
107
+ properties: {
108
+ query: {
109
+ type: 'string',
110
+ description: 'Parameter query for memory_lookup'
111
+ }
112
+ },
113
+ required: ['query']
114
+ }
115
+ }]);
116
+
117
+ // Check converted messages
118
+ t.is(result.messages[1].role, 'assistant');
119
+ t.deepEqual(result.messages[1].content[0], {
120
+ type: 'tool_use',
121
+ id: 'tool_1',
122
+ name: 'memory_lookup',
123
+ input: { query: 'search memory for relevant information' }
124
+ });
125
+
126
+ t.is(result.messages[2].role, 'user');
127
+ t.deepEqual(result.messages[2].content[0], {
128
+ type: 'tool_result',
129
+ tool_use_id: 'tool_1',
130
+ content: 'Memory search results here'
131
+ });
132
+ });
133
+
134
+ // Test multiple tool calls in conversation
135
+ test('Multiple tool calls in conversation', async (t) => {
136
+ const plugin = createPlugin();
137
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
138
+
139
+ const messages = [
140
+ {
141
+ role: 'system',
142
+ content: 'You are a helpful assistant'
143
+ },
144
+ {
145
+ role: 'user',
146
+ content: 'What\'s in my memory and what\'s the weather in San Francisco?'
147
+ },
148
+ {
149
+ role: 'assistant',
150
+ content: [
151
+ {
152
+ type: 'tool_use',
153
+ id: 'tool_1',
154
+ name: 'memory_lookup',
155
+ input: { query: 'search memory' }
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ role: 'user',
161
+ content: [
162
+ {
163
+ type: 'tool_result',
164
+ tool_use_id: 'tool_1',
165
+ content: 'Memory results'
166
+ }
167
+ ]
168
+ },
169
+ {
170
+ role: 'assistant',
171
+ content: [
172
+ {
173
+ type: 'tool_use',
174
+ id: 'tool_2',
175
+ name: 'weather_lookup',
176
+ input: { location: 'San Francisco' }
177
+ }
178
+ ]
179
+ },
180
+ {
181
+ role: 'user',
182
+ content: [
183
+ {
184
+ type: 'tool_result',
185
+ tool_use_id: 'tool_2',
186
+ content: 'Weather results'
187
+ }
188
+ ]
189
+ }
190
+ ];
191
+
192
+ // add messages to mockPrompt.messages
193
+ prompt.messages = messages;
194
+
195
+ const cortexRequest = { messages };
196
+ const result = await plugin.getRequestParameters('test', {}, prompt, cortexRequest);
197
+
198
+ // Check that both tools are in the tools block
199
+ t.truthy(result.tools, 'Tools should be defined');
200
+ t.is(result.tools.length, 2, 'Should have 2 tools');
201
+ t.deepEqual(result.tools.map(t => t.name).sort(), ['memory_lookup', 'weather_lookup']);
202
+
203
+ // Check all messages are converted correctly
204
+ t.is(result.messages.length, 5);
205
+ t.deepEqual(result.messages[1].content[0].input, { query: 'search memory' });
206
+ t.deepEqual(result.messages[3].content[0].input, { location: 'San Francisco' });
207
+ });
208
+
209
+ // Test mixed conversation with tools and regular messages
210
+ test('Mixed conversation with tools and regular messages', async (t) => {
211
+ const plugin = createPlugin();
212
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
213
+
214
+ const messages = [
215
+ {
216
+ role: 'system',
217
+ content: 'You are a helpful assistant'
218
+ },
219
+ {
220
+ role: 'user',
221
+ content: 'What\'s in my memory?'
222
+ },
223
+ {
224
+ role: 'assistant',
225
+ content: [
226
+ {
227
+ type: 'tool_use',
228
+ id: 'tool_1',
229
+ name: 'memory_lookup',
230
+ input: 'search memory'
231
+ }
232
+ ]
233
+ },
234
+ {
235
+ role: 'user',
236
+ content: [
237
+ {
238
+ type: 'tool_result',
239
+ tool_use_id: 'tool_1',
240
+ content: 'Memory results here'
241
+ }
242
+ ]
243
+ }
244
+ ];
245
+
246
+ // add messages to mockPrompt.messages
247
+ prompt.messages = messages;
248
+
249
+ const cortexRequest = { messages };
250
+ const result = await plugin.getRequestParameters('test', {}, prompt, cortexRequest);
251
+
252
+ // Check system message
253
+ t.is(result.system, 'You are a helpful assistant');
254
+
255
+ // Check regular messages and tool messages are converted correctly
256
+ t.is(result.messages.length, 3);
257
+ t.deepEqual(result.messages[0].content[0], { type: 'text', text: 'What\'s in my memory?' });
258
+ t.deepEqual(result.messages[1].content[0].input, { query: 'search memory' });
259
+ t.deepEqual(result.messages[2].content[0], {
260
+ type: 'tool_result',
261
+ tool_use_id: 'tool_1',
262
+ content: 'Memory results here'
263
+ });
264
+ });
265
+
266
+ // Test tool conversion with document content blocks
267
+ test('Tool conversion with document content blocks', async (t) => {
268
+ const plugin = createPlugin();
269
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
270
+
271
+ const base64Pdf = Buffer.from('Sample PDF content').toString('base64');
272
+
273
+ // Need 3 messages (odd number) after system is removed: user, assistant, user
274
+ const messages = [
275
+ {
276
+ role: 'system',
277
+ content: 'You are a helpful assistant'
278
+ },
279
+ {
280
+ role: 'user',
281
+ content: [
282
+ {
283
+ type: 'text',
284
+ text: 'Please analyze this PDF'
285
+ },
286
+ {
287
+ type: 'document',
288
+ source: {
289
+ type: 'base64',
290
+ media_type: 'application/pdf',
291
+ data: base64Pdf
292
+ }
293
+ }
294
+ ]
295
+ },
296
+ {
297
+ role: 'assistant',
298
+ content: [
299
+ {
300
+ type: 'tool_use',
301
+ id: 'tool_1',
302
+ name: 'analyze_document',
303
+ input: { action: 'analyze' }
304
+ }
305
+ ]
306
+ },
307
+ {
308
+ role: 'user',
309
+ content: 'What did you find?'
310
+ }
311
+ ];
312
+
313
+ prompt.messages = messages;
314
+
315
+ const cortexRequest = { messages };
316
+ const result = await plugin.getRequestParameters('test', {}, prompt, cortexRequest);
317
+
318
+ // System message should be extracted
319
+ t.is(result.system, 'You are a helpful assistant');
320
+
321
+ // After filtering system messages and ensuring odd count, we have 3 messages
322
+ t.is(result.messages.length, 3);
323
+ t.is(result.messages[0].role, 'user');
324
+ t.is(result.messages[0].content.length, 2);
325
+ t.is(result.messages[0].content[0].type, 'text');
326
+ t.is(result.messages[0].content[1].type, 'document');
327
+
328
+ t.is(result.messages[1].role, 'assistant');
329
+ t.is(result.messages[2].role, 'user');
330
+
331
+ // Check tool was generated
332
+ t.truthy(result.tools);
333
+ t.truthy(result.tools.find(t => t.name === 'analyze_document'));
334
+ });
335
+
336
+ // Test preventing duplicate tool definitions
337
+ test('Prevent duplicate tool definitions', async (t) => {
338
+ const plugin = createPlugin();
339
+ const prompt = mockPathwayResolverMessages.pathway.prompt;
340
+
341
+ const parameters = {
342
+ tools: [
343
+ {
344
+ type: 'function',
345
+ function: {
346
+ name: 'memory_lookup',
347
+ description: 'Look up information in memory',
348
+ parameters: {
349
+ type: 'object',
350
+ properties: {
351
+ query: {
352
+ type: 'string',
353
+ description: 'The search query'
354
+ }
355
+ },
356
+ required: ['query']
357
+ }
358
+ }
359
+ }
360
+ ]
361
+ };
362
+
363
+ const messages = [
364
+ {
365
+ role: 'system',
366
+ content: 'You are a helpful assistant'
367
+ },
368
+ {
369
+ role: 'user',
370
+ content: 'What\'s in my memory?'
371
+ },
372
+ {
373
+ role: 'assistant',
374
+ content: [
375
+ {
376
+ type: 'tool_use',
377
+ id: 'tool_1',
378
+ name: 'memory_lookup',
379
+ input: { query: 'search memory' }
380
+ }
381
+ ]
382
+ }
383
+ ];
384
+
385
+ // Set up the mock prompt with messages
386
+ prompt.messages = messages;
387
+
388
+ const cortexRequest = { messages };
389
+ const result = await plugin.getRequestParameters('test', parameters, prompt, cortexRequest);
390
+
391
+ // Check that we only have one memory_lookup tool definition
392
+ t.truthy(result.tools, 'Tools should be defined');
393
+ t.is(result.tools.length, 1, 'Should have exactly 1 tool');
394
+ t.is(result.tools[0].name, 'memory_lookup', 'Tool should be memory_lookup');
395
+ t.is(result.tools[0].description, 'Look up information in memory', 'Should preserve original tool description');
396
+
397
+ // Verify the tool_use call is still properly converted
398
+ t.truthy(result.messages, 'Messages should be defined');
399
+ t.is(result.messages.length, 1, 'Should have 1 message after conversion');
400
+
401
+ // Check the converted message
402
+ const message = result.messages[0];
403
+ t.is(message.role, 'assistant', 'Message should be from assistant');
404
+ t.truthy(message.content, 'Message should have content');
405
+ t.is(message.content.length, 1, 'Message should have one content item');
406
+ t.deepEqual(message.content[0], {
407
+ type: 'tool_use',
408
+ id: 'tool_1',
409
+ name: 'memory_lookup',
410
+ input: { query: 'search memory' }
411
+ });
412
+ });
413
+
@@ -1,8 +0,0 @@
1
- .git*
2
- .vscode
3
- __azurite_db*__.json
4
- __blobstorage__
5
- __queuestorage__
6
- local.settings.json
7
- test
8
- .venv
@@ -1,10 +0,0 @@
1
- FROM python:3.9-slim
2
-
3
- WORKDIR /app
4
-
5
- COPY requirements.txt .
6
- RUN pip install --no-cache-dir -r requirements.txt
7
-
8
- COPY . .
9
-
10
- CMD ["python", "main.py"]
@@ -1,6 +0,0 @@
1
- [
2
- {
3
- "model": "claude-3.7-sonnet",
4
- "price": [0,0]
5
- }
6
- ]