@aj-archipelago/cortex 1.3.62 → 1.3.63
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/cortex-file-handler-test.yml +61 -0
- package/README.md +31 -7
- package/config/default.example.json +15 -0
- package/config.js +133 -12
- package/helper-apps/cortex-autogen2/DigiCertGlobalRootCA.crt.pem +22 -0
- package/helper-apps/cortex-autogen2/Dockerfile +31 -0
- package/helper-apps/cortex-autogen2/Dockerfile.worker +41 -0
- package/helper-apps/cortex-autogen2/README.md +183 -0
- package/helper-apps/cortex-autogen2/__init__.py +1 -0
- package/helper-apps/cortex-autogen2/agents.py +131 -0
- package/helper-apps/cortex-autogen2/docker-compose.yml +20 -0
- package/helper-apps/cortex-autogen2/function_app.py +55 -0
- package/helper-apps/cortex-autogen2/host.json +15 -0
- package/helper-apps/cortex-autogen2/main.py +126 -0
- package/helper-apps/cortex-autogen2/poetry.lock +3652 -0
- package/helper-apps/cortex-autogen2/pyproject.toml +36 -0
- package/helper-apps/cortex-autogen2/requirements.txt +20 -0
- package/helper-apps/cortex-autogen2/send_task.py +105 -0
- package/helper-apps/cortex-autogen2/services/__init__.py +1 -0
- package/helper-apps/cortex-autogen2/services/azure_queue.py +85 -0
- package/helper-apps/cortex-autogen2/services/redis_publisher.py +153 -0
- package/helper-apps/cortex-autogen2/task_processor.py +488 -0
- package/helper-apps/cortex-autogen2/tools/__init__.py +24 -0
- package/helper-apps/cortex-autogen2/tools/azure_blob_tools.py +175 -0
- package/helper-apps/cortex-autogen2/tools/azure_foundry_agents.py +601 -0
- package/helper-apps/cortex-autogen2/tools/coding_tools.py +72 -0
- package/helper-apps/cortex-autogen2/tools/download_tools.py +48 -0
- package/helper-apps/cortex-autogen2/tools/file_tools.py +545 -0
- package/helper-apps/cortex-autogen2/tools/search_tools.py +646 -0
- package/helper-apps/cortex-azure-cleaner/README.md +36 -0
- package/helper-apps/cortex-file-converter/README.md +93 -0
- package/helper-apps/cortex-file-converter/key_to_pdf.py +104 -0
- package/helper-apps/cortex-file-converter/list_blob_extensions.py +89 -0
- package/helper-apps/cortex-file-converter/process_azure_keynotes.py +181 -0
- package/helper-apps/cortex-file-converter/requirements.txt +1 -0
- package/helper-apps/cortex-file-handler/.env.test.azure.ci +7 -0
- package/helper-apps/cortex-file-handler/.env.test.azure.sample +1 -1
- package/helper-apps/cortex-file-handler/.env.test.gcs.ci +10 -0
- package/helper-apps/cortex-file-handler/.env.test.gcs.sample +2 -2
- package/helper-apps/cortex-file-handler/INTERFACE.md +41 -0
- package/helper-apps/cortex-file-handler/package.json +1 -1
- package/helper-apps/cortex-file-handler/scripts/setup-azure-container.js +41 -17
- package/helper-apps/cortex-file-handler/scripts/setup-test-containers.js +30 -15
- package/helper-apps/cortex-file-handler/scripts/test-azure.sh +32 -6
- package/helper-apps/cortex-file-handler/scripts/test-gcs.sh +24 -2
- package/helper-apps/cortex-file-handler/scripts/validate-env.js +128 -0
- package/helper-apps/cortex-file-handler/src/blobHandler.js +161 -51
- package/helper-apps/cortex-file-handler/src/constants.js +3 -0
- package/helper-apps/cortex-file-handler/src/fileChunker.js +10 -8
- package/helper-apps/cortex-file-handler/src/index.js +116 -9
- package/helper-apps/cortex-file-handler/src/redis.js +61 -1
- package/helper-apps/cortex-file-handler/src/services/ConversionService.js +11 -8
- package/helper-apps/cortex-file-handler/src/services/FileConversionService.js +2 -2
- package/helper-apps/cortex-file-handler/src/services/storage/AzureStorageProvider.js +88 -6
- package/helper-apps/cortex-file-handler/src/services/storage/GCSStorageProvider.js +58 -0
- package/helper-apps/cortex-file-handler/src/services/storage/StorageFactory.js +25 -5
- package/helper-apps/cortex-file-handler/src/services/storage/StorageProvider.js +9 -0
- package/helper-apps/cortex-file-handler/src/services/storage/StorageService.js +120 -16
- package/helper-apps/cortex-file-handler/src/start.js +27 -17
- package/helper-apps/cortex-file-handler/tests/FileConversionService.test.js +52 -1
- package/helper-apps/cortex-file-handler/tests/blobHandler.test.js +40 -0
- package/helper-apps/cortex-file-handler/tests/checkHashShortLived.test.js +553 -0
- package/helper-apps/cortex-file-handler/tests/cleanup.test.js +46 -52
- package/helper-apps/cortex-file-handler/tests/containerConversionFlow.test.js +451 -0
- package/helper-apps/cortex-file-handler/tests/containerNameParsing.test.js +229 -0
- package/helper-apps/cortex-file-handler/tests/containerParameterFlow.test.js +392 -0
- package/helper-apps/cortex-file-handler/tests/conversionResilience.test.js +7 -2
- package/helper-apps/cortex-file-handler/tests/deleteOperations.test.js +348 -0
- package/helper-apps/cortex-file-handler/tests/fileChunker.test.js +23 -2
- package/helper-apps/cortex-file-handler/tests/fileUpload.test.js +11 -5
- package/helper-apps/cortex-file-handler/tests/getOperations.test.js +58 -24
- package/helper-apps/cortex-file-handler/tests/postOperations.test.js +11 -4
- package/helper-apps/cortex-file-handler/tests/shortLivedUrlConversion.test.js +225 -0
- package/helper-apps/cortex-file-handler/tests/start.test.js +8 -12
- package/helper-apps/cortex-file-handler/tests/storage/StorageFactory.test.js +80 -0
- package/helper-apps/cortex-file-handler/tests/storage/StorageService.test.js +388 -22
- package/helper-apps/cortex-file-handler/tests/testUtils.helper.js +74 -0
- package/lib/cortexResponse.js +153 -0
- package/lib/entityConstants.js +21 -3
- package/lib/logger.js +21 -4
- package/lib/pathwayTools.js +28 -9
- package/lib/util.js +49 -0
- package/package.json +1 -1
- package/pathways/basePathway.js +1 -0
- package/pathways/bing_afagent.js +54 -1
- package/pathways/call_tools.js +2 -3
- package/pathways/chat_jarvis.js +1 -1
- package/pathways/google_cse.js +27 -0
- package/pathways/grok_live_search.js +18 -0
- package/pathways/system/entity/memory/sys_memory_lookup_required.js +1 -0
- package/pathways/system/entity/memory/sys_memory_required.js +1 -0
- package/pathways/system/entity/memory/sys_search_memory.js +1 -0
- package/pathways/system/entity/sys_entity_agent.js +56 -4
- package/pathways/system/entity/sys_generator_quick.js +1 -0
- package/pathways/system/entity/tools/sys_tool_bing_search_afagent.js +26 -0
- package/pathways/system/entity/tools/sys_tool_google_search.js +141 -0
- package/pathways/system/entity/tools/sys_tool_grok_x_search.js +237 -0
- package/pathways/system/entity/tools/sys_tool_image.js +1 -1
- package/pathways/system/rest_streaming/sys_claude_37_sonnet.js +21 -0
- package/pathways/system/rest_streaming/sys_claude_41_opus.js +21 -0
- package/pathways/system/rest_streaming/sys_claude_4_sonnet.js +21 -0
- package/pathways/system/rest_streaming/sys_google_gemini_25_flash.js +25 -0
- package/pathways/system/rest_streaming/{sys_google_gemini_chat.js → sys_google_gemini_25_pro.js} +6 -4
- package/pathways/system/rest_streaming/sys_grok_4.js +23 -0
- package/pathways/system/rest_streaming/sys_grok_4_fast_non_reasoning.js +23 -0
- package/pathways/system/rest_streaming/sys_grok_4_fast_reasoning.js +23 -0
- package/pathways/system/rest_streaming/sys_openai_chat.js +3 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41.js +22 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41_mini.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41_nano.js +21 -0
- package/pathways/system/rest_streaming/{sys_claude_35_sonnet.js → sys_openai_chat_gpt4_omni.js} +6 -4
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_omni_mini.js +21 -0
- package/pathways/system/rest_streaming/{sys_claude_3_haiku.js → sys_openai_chat_gpt5.js} +7 -5
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_chat.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_mini.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_nano.js +21 -0
- package/pathways/system/rest_streaming/{sys_openai_chat_o1.js → sys_openai_chat_o3.js} +6 -3
- package/pathways/system/rest_streaming/sys_openai_chat_o3_mini.js +3 -0
- package/pathways/system/workspaces/run_workspace_prompt.js +99 -0
- package/pathways/vision.js +1 -1
- package/server/graphql.js +1 -1
- package/server/modelExecutor.js +8 -0
- package/server/pathwayResolver.js +166 -16
- package/server/pathwayResponseParser.js +16 -8
- package/server/plugins/azureFoundryAgentsPlugin.js +1 -1
- package/server/plugins/claude3VertexPlugin.js +193 -45
- package/server/plugins/gemini15ChatPlugin.js +21 -0
- package/server/plugins/gemini15VisionPlugin.js +360 -0
- package/server/plugins/googleCsePlugin.js +94 -0
- package/server/plugins/grokVisionPlugin.js +365 -0
- package/server/plugins/modelPlugin.js +3 -1
- package/server/plugins/openAiChatPlugin.js +106 -13
- package/server/plugins/openAiVisionPlugin.js +42 -30
- package/server/resolver.js +28 -4
- package/server/rest.js +270 -53
- package/server/typeDef.js +1 -0
- package/tests/{mocks.js → helpers/mocks.js} +5 -2
- package/tests/{server.js → helpers/server.js} +2 -2
- package/tests/helpers/sseAssert.js +23 -0
- package/tests/helpers/sseClient.js +73 -0
- package/tests/helpers/subscriptionAssert.js +11 -0
- package/tests/helpers/subscriptions.js +113 -0
- package/tests/{sublong.srt → integration/features/translate/sublong.srt} +4543 -4543
- package/tests/integration/features/translate/translate_chunking_stream.test.js +100 -0
- package/tests/{translate_srt.test.js → integration/features/translate/translate_srt.test.js} +2 -2
- package/tests/integration/graphql/async/stream/agentic.test.js +477 -0
- package/tests/integration/graphql/async/stream/subscription_streaming.test.js +62 -0
- package/tests/integration/graphql/async/stream/sys_entity_start_streaming.test.js +71 -0
- package/tests/integration/graphql/async/stream/vendors/claude_streaming.test.js +56 -0
- package/tests/integration/graphql/async/stream/vendors/gemini_streaming.test.js +66 -0
- package/tests/integration/graphql/async/stream/vendors/grok_streaming.test.js +56 -0
- package/tests/integration/graphql/async/stream/vendors/openai_streaming.test.js +72 -0
- package/tests/integration/graphql/features/google/sysToolGoogleSearch.test.js +96 -0
- package/tests/integration/graphql/features/grok/grok.test.js +688 -0
- package/tests/integration/graphql/features/grok/grok_x_search_tool.test.js +354 -0
- package/tests/{main.test.js → integration/graphql/features/main.test.js} +1 -1
- package/tests/{call_tools.test.js → integration/graphql/features/tools/call_tools.test.js} +2 -2
- package/tests/{vision.test.js → integration/graphql/features/vision/vision.test.js} +1 -1
- package/tests/integration/graphql/subscriptions/connection.test.js +26 -0
- package/tests/{openai_api.test.js → integration/rest/oai/openai_api.test.js} +63 -238
- package/tests/integration/rest/oai/tool_calling_api.test.js +343 -0
- package/tests/integration/rest/oai/tool_calling_streaming.test.js +85 -0
- package/tests/integration/rest/vendors/claude_streaming.test.js +47 -0
- package/tests/integration/rest/vendors/claude_tool_calling_streaming.test.js +75 -0
- package/tests/integration/rest/vendors/gemini_streaming.test.js +47 -0
- package/tests/integration/rest/vendors/gemini_tool_calling_streaming.test.js +75 -0
- package/tests/integration/rest/vendors/grok_streaming.test.js +55 -0
- package/tests/integration/rest/vendors/grok_tool_calling_streaming.test.js +75 -0
- package/tests/{azureAuthTokenHelper.test.js → unit/core/azureAuthTokenHelper.test.js} +1 -1
- package/tests/{chunkfunction.test.js → unit/core/chunkfunction.test.js} +2 -2
- package/tests/{config.test.js → unit/core/config.test.js} +3 -3
- package/tests/{encodeCache.test.js → unit/core/encodeCache.test.js} +1 -1
- package/tests/{fastLruCache.test.js → unit/core/fastLruCache.test.js} +1 -1
- package/tests/{handleBars.test.js → unit/core/handleBars.test.js} +1 -1
- package/tests/{memoryfunction.test.js → unit/core/memoryfunction.test.js} +2 -2
- package/tests/unit/core/mergeResolver.test.js +952 -0
- package/tests/{parser.test.js → unit/core/parser.test.js} +3 -3
- package/tests/unit/core/pathwayResolver.test.js +187 -0
- package/tests/{requestMonitor.test.js → unit/core/requestMonitor.test.js} +1 -1
- package/tests/{requestMonitorDurationEstimator.test.js → unit/core/requestMonitorDurationEstimator.test.js} +1 -1
- package/tests/{truncateMessages.test.js → unit/core/truncateMessages.test.js} +3 -3
- package/tests/{util.test.js → unit/core/util.test.js} +1 -1
- package/tests/{apptekTranslatePlugin.test.js → unit/plugins/apptekTranslatePlugin.test.js} +3 -3
- package/tests/{azureFoundryAgents.test.js → unit/plugins/azureFoundryAgents.test.js} +136 -1
- package/tests/{claude3VertexPlugin.test.js → unit/plugins/claude3VertexPlugin.test.js} +32 -10
- package/tests/{claude3VertexToolConversion.test.js → unit/plugins/claude3VertexToolConversion.test.js} +3 -3
- package/tests/unit/plugins/googleCsePlugin.test.js +111 -0
- package/tests/unit/plugins/grokVisionPlugin.test.js +1392 -0
- package/tests/{modelPlugin.test.js → unit/plugins/modelPlugin.test.js} +3 -3
- package/tests/{multimodal_conversion.test.js → unit/plugins/multimodal_conversion.test.js} +4 -4
- package/tests/{openAiChatPlugin.test.js → unit/plugins/openAiChatPlugin.test.js} +13 -4
- package/tests/{openAiToolPlugin.test.js → unit/plugins/openAiToolPlugin.test.js} +35 -27
- package/tests/{tokenHandlingTests.test.js → unit/plugins/tokenHandlingTests.test.js} +5 -5
- package/tests/{translate_apptek.test.js → unit/plugins/translate_apptek.test.js} +3 -3
- package/tests/{streaming.test.js → unit/plugins.streaming/plugin_stream_events.test.js} +19 -58
- package/helper-apps/mogrt-handler/tests/test-files/test.gif +0 -1
- package/helper-apps/mogrt-handler/tests/test-files/test.mogrt +0 -1
- package/helper-apps/mogrt-handler/tests/test-files/test.mp4 +0 -1
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4.js +0 -19
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_32.js +0 -19
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_turbo.js +0 -19
- package/pathways/system/workspaces/run_claude35_sonnet.js +0 -21
- package/pathways/system/workspaces/run_claude3_haiku.js +0 -20
- package/pathways/system/workspaces/run_gpt35turbo.js +0 -20
- package/pathways/system/workspaces/run_gpt4.js +0 -20
- package/pathways/system/workspaces/run_gpt4_32.js +0 -20
- package/tests/agentic.test.js +0 -256
- package/tests/pathwayResolver.test.js +0 -78
- package/tests/subscription.test.js +0 -387
- /package/tests/{subchunk.srt → integration/features/translate/subchunk.srt} +0 -0
- /package/tests/{subhorizontal.srt → integration/features/translate/subhorizontal.srt} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// test/ModelPlugin.test.js
|
|
2
2
|
import test from 'ava';
|
|
3
|
-
import ModelPlugin from '
|
|
4
|
-
import HandleBars from '
|
|
5
|
-
import { mockConfig, mockPathwayString, mockPathwayFunction, mockPathwayMessages, mockPathwayResolverString } from '
|
|
3
|
+
import ModelPlugin from '../../../server/plugins/modelPlugin.js';
|
|
4
|
+
import HandleBars from '../../../lib/handleBars.js';
|
|
5
|
+
import { mockConfig, mockPathwayString, mockPathwayFunction, mockPathwayMessages, mockPathwayResolverString } from '../../helpers/mocks.js';
|
|
6
6
|
|
|
7
7
|
const DEFAULT_MAX_TOKENS = 4096;
|
|
8
8
|
const DEFAULT_PROMPT_TOKEN_RATIO = 1.0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import OpenAIVisionPlugin from '
|
|
3
|
-
import Claude3VertexPlugin from '
|
|
4
|
-
import Gemini15VisionPlugin from '
|
|
5
|
-
import GeminiVisionPlugin from '
|
|
2
|
+
import OpenAIVisionPlugin from '../../../server/plugins/openAiVisionPlugin.js';
|
|
3
|
+
import Claude3VertexPlugin from '../../../server/plugins/claude3VertexPlugin.js';
|
|
4
|
+
import Gemini15VisionPlugin from '../../../server/plugins/gemini15VisionPlugin.js';
|
|
5
|
+
import GeminiVisionPlugin from '../../../server/plugins/geminiVisionPlugin.js';
|
|
6
6
|
|
|
7
7
|
// Mock pathway and model for plugin initialization
|
|
8
8
|
const mockPathway = { name: 'test', temperature: 0.7 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import OpenAIChatPlugin from '
|
|
3
|
-
import { mockPathwayResolverMessages } from '
|
|
4
|
-
import { config } from '
|
|
2
|
+
import OpenAIChatPlugin from '../../../server/plugins/openAiChatPlugin.js';
|
|
3
|
+
import { mockPathwayResolverMessages } from '../../helpers/mocks.js';
|
|
4
|
+
import { config } from '../../../config.js';
|
|
5
5
|
|
|
6
6
|
const { pathway, modelName, model } = mockPathwayResolverMessages;
|
|
7
7
|
|
|
@@ -107,7 +107,16 @@ test('parseResponse', (t) => {
|
|
|
107
107
|
],
|
|
108
108
|
};
|
|
109
109
|
const result = plugin.parseResponse(data);
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
// Verify it's a CortexResponse object
|
|
112
|
+
t.truthy(result);
|
|
113
|
+
t.is(typeof result, 'object');
|
|
114
|
+
t.is(result.constructor.name, 'CortexResponse');
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// Verify the content using string conversion (triggers toString automatically)
|
|
118
|
+
t.is(String(result), 'Sure, I can help John who is 30 years old.');
|
|
119
|
+
t.is(result.finishReason, 'stop');
|
|
111
120
|
});
|
|
112
121
|
|
|
113
122
|
// Test the logRequestData function
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import OpenAIVisionPlugin from '
|
|
3
|
-
import { mockPathwayResolverMessages } from '
|
|
4
|
-
import { config } from '
|
|
2
|
+
import OpenAIVisionPlugin from '../../../server/plugins/openAiVisionPlugin.js';
|
|
3
|
+
import { mockPathwayResolverMessages } from '../../helpers/mocks.js';
|
|
4
|
+
import { config } from '../../../config.js';
|
|
5
5
|
|
|
6
6
|
const { pathway, modelName, model } = mockPathwayResolverMessages;
|
|
7
7
|
|
|
@@ -71,18 +71,22 @@ test('Tool call response handling', async (t) => {
|
|
|
71
71
|
|
|
72
72
|
const result = plugin.parseResponse(responseData);
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
// Verify it's a CortexResponse object
|
|
75
|
+
t.truthy(result);
|
|
76
|
+
t.is(typeof result, 'object');
|
|
77
|
+
t.is(result.constructor.name, 'CortexResponse');
|
|
78
|
+
|
|
79
|
+
// Verify the content
|
|
80
|
+
t.is(result.output_text, 'I will check the weather for you.');
|
|
81
|
+
t.is(result.finishReason, 'tool_calls');
|
|
82
|
+
|
|
83
|
+
// Verify tool calls
|
|
84
|
+
t.truthy(result.toolCalls);
|
|
85
|
+
t.is(result.toolCalls.length, 1);
|
|
86
|
+
t.is(result.toolCalls[0].id, 'call_123');
|
|
87
|
+
t.is(result.toolCalls[0].type, 'function');
|
|
88
|
+
t.is(result.toolCalls[0].function.name, 'get_weather');
|
|
89
|
+
t.is(result.toolCalls[0].function.arguments, '{"location": "Bogotá, Colombia"}');
|
|
86
90
|
});
|
|
87
91
|
|
|
88
92
|
// Test tool result message handling
|
|
@@ -177,18 +181,22 @@ test('Error handling in tool calls', async (t) => {
|
|
|
177
181
|
|
|
178
182
|
const result = plugin.parseResponse(responseData);
|
|
179
183
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
// Verify it's a CortexResponse object
|
|
185
|
+
t.truthy(result);
|
|
186
|
+
t.is(typeof result, 'object');
|
|
187
|
+
t.is(result.constructor.name, 'CortexResponse');
|
|
188
|
+
|
|
189
|
+
// Verify the content
|
|
190
|
+
t.is(result.output_text, 'I will check the weather for you.');
|
|
191
|
+
t.is(result.finishReason, 'tool_calls');
|
|
192
|
+
|
|
193
|
+
// Verify tool calls
|
|
194
|
+
t.truthy(result.toolCalls);
|
|
195
|
+
t.is(result.toolCalls.length, 1);
|
|
196
|
+
t.is(result.toolCalls[0].id, 'call_123');
|
|
197
|
+
t.is(result.toolCalls[0].type, 'function');
|
|
198
|
+
t.is(result.toolCalls[0].function.name, 'get_weather');
|
|
199
|
+
t.is(result.toolCalls[0].function.arguments, 'invalid json');
|
|
192
200
|
});
|
|
193
201
|
|
|
194
202
|
// Test multiple tool calls in sequence
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { encode } from '
|
|
5
|
-
import { getFirstNToken } from '
|
|
6
|
-
import Claude3VertexPlugin from '
|
|
7
|
-
import ModelPlugin from '
|
|
8
|
-
import { mockPathwayResolverMessages } from '
|
|
4
|
+
import { encode } from '../../../lib/encodeCache.js';
|
|
5
|
+
import { getFirstNToken } from '../../../server/chunker.js';
|
|
6
|
+
import Claude3VertexPlugin from '../../../server/plugins/claude3VertexPlugin.js';
|
|
7
|
+
import ModelPlugin from '../../../server/plugins/modelPlugin.js';
|
|
8
|
+
import { mockPathwayResolverMessages } from '../../helpers/mocks.js';
|
|
9
9
|
|
|
10
10
|
const { pathway, model } = mockPathwayResolverMessages;
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import sinon from 'sinon';
|
|
3
|
-
import { PathwayResolver } from '
|
|
3
|
+
import { PathwayResolver } from '../../../server/pathwayResolver.js';
|
|
4
4
|
|
|
5
5
|
// Mock configuration
|
|
6
6
|
const mockModel = {
|
|
@@ -118,7 +118,7 @@ test('resolver uses correct model', (t) => {
|
|
|
118
118
|
|
|
119
119
|
test('pathway has fallback pathway parameter', async (t) => {
|
|
120
120
|
// Import the actual pathway to test the new parameter
|
|
121
|
-
const pathway = await import('
|
|
121
|
+
const pathway = await import('../../../pathways/translate_apptek.js');
|
|
122
122
|
|
|
123
123
|
t.truthy(pathway.default.inputParameters.fallbackPathway);
|
|
124
124
|
t.is(pathway.default.inputParameters.fallbackPathway, 'translate_groq');
|
|
@@ -126,7 +126,7 @@ test('pathway has fallback pathway parameter', async (t) => {
|
|
|
126
126
|
|
|
127
127
|
test('pathway has executePathway function', async (t) => {
|
|
128
128
|
// Import the actual pathway to test the executePathway function
|
|
129
|
-
const pathway = await import('
|
|
129
|
+
const pathway = await import('../../../pathways/translate_apptek.js');
|
|
130
130
|
|
|
131
131
|
t.truthy(pathway.default.executePathway);
|
|
132
132
|
t.is(typeof pathway.default.executePathway, 'function');
|
|
@@ -1,30 +1,14 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { config } from '../config.js';
|
|
2
|
+
import { PathwayResolver } from '../../../server/pathwayResolver.js';
|
|
3
|
+
import OpenAIChatPlugin from '../../../server/plugins/openAiChatPlugin.js';
|
|
4
|
+
import GeminiChatPlugin from '../../../server/plugins/geminiChatPlugin.js';
|
|
5
|
+
import Gemini15ChatPlugin from '../../../server/plugins/gemini15ChatPlugin.js';
|
|
6
|
+
import Claude3VertexPlugin from '../../../server/plugins/claude3VertexPlugin.js';
|
|
7
|
+
import { config } from '../../../config.js';
|
|
9
8
|
|
|
10
9
|
let testServer;
|
|
11
10
|
|
|
12
|
-
test.before(async () => {
|
|
13
|
-
process.env.CORTEX_ENABLE_REST = 'true';
|
|
14
|
-
const { server, startServer } = await serverFactory();
|
|
15
|
-
startServer && await startServer();
|
|
16
|
-
testServer = server;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test.after.always('cleanup', async () => {
|
|
20
|
-
if (testServer) {
|
|
21
|
-
await testServer.stop();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Helper function to create a PathwayResolver with a specific plugin
|
|
26
11
|
function createResolverWithPlugin(pluginClass, modelName = 'test-model') {
|
|
27
|
-
// Map plugin classes to their corresponding model types
|
|
28
12
|
const pluginToModelType = {
|
|
29
13
|
OpenAIChatPlugin: 'OPENAI-VISION',
|
|
30
14
|
GeminiChatPlugin: 'GEMINI-VISION',
|
|
@@ -59,12 +43,10 @@ function createResolverWithPlugin(pluginClass, modelName = 'test-model') {
|
|
|
59
43
|
return resolver;
|
|
60
44
|
}
|
|
61
45
|
|
|
62
|
-
// Test OpenAI Chat Plugin Streaming
|
|
63
46
|
test('OpenAI Chat Plugin - processStreamEvent handles content chunks correctly', async t => {
|
|
64
47
|
const resolver = createResolverWithPlugin(OpenAIChatPlugin);
|
|
65
48
|
const plugin = resolver.modelExecutor.plugin;
|
|
66
49
|
|
|
67
|
-
// Test regular content chunk
|
|
68
50
|
const contentEvent = {
|
|
69
51
|
data: JSON.stringify({
|
|
70
52
|
id: 'test-id',
|
|
@@ -79,7 +61,6 @@ test('OpenAI Chat Plugin - processStreamEvent handles content chunks correctly',
|
|
|
79
61
|
t.is(progress.data, contentEvent.data);
|
|
80
62
|
t.falsy(progress.progress);
|
|
81
63
|
|
|
82
|
-
// Test stream end
|
|
83
64
|
const endEvent = {
|
|
84
65
|
data: JSON.stringify({
|
|
85
66
|
id: 'test-id',
|
|
@@ -94,39 +75,32 @@ test('OpenAI Chat Plugin - processStreamEvent handles content chunks correctly',
|
|
|
94
75
|
t.is(progress.progress, 1);
|
|
95
76
|
});
|
|
96
77
|
|
|
97
|
-
// Test Gemini Chat Plugin Streaming
|
|
98
78
|
test('Gemini Chat Plugin - processStreamEvent handles content chunks correctly', async t => {
|
|
99
79
|
const resolver = createResolverWithPlugin(GeminiChatPlugin);
|
|
100
80
|
const plugin = resolver.modelExecutor.plugin;
|
|
101
81
|
|
|
102
|
-
// Test regular content chunk
|
|
103
82
|
const contentEvent = {
|
|
104
83
|
data: JSON.stringify({
|
|
105
84
|
candidates: [{
|
|
106
|
-
content: {
|
|
107
|
-
parts: [{ text: 'test content' }]
|
|
108
|
-
},
|
|
85
|
+
content: { parts: [{ text: 'test content' }] },
|
|
109
86
|
finishReason: null
|
|
110
87
|
}]
|
|
111
88
|
})
|
|
112
89
|
};
|
|
113
90
|
|
|
114
91
|
let progress = plugin.processStreamEvent(contentEvent, {});
|
|
115
|
-
t.truthy(progress.data
|
|
92
|
+
t.truthy(progress.data);
|
|
116
93
|
const parsedData = JSON.parse(progress.data);
|
|
117
|
-
t.truthy(parsedData.candidates
|
|
118
|
-
t.truthy(parsedData.candidates[0].content
|
|
119
|
-
t.truthy(parsedData.candidates[0].content.parts
|
|
120
|
-
t.is(parsedData.candidates[0].content.parts[0].text, 'test content'
|
|
94
|
+
t.truthy(parsedData.candidates);
|
|
95
|
+
t.truthy(parsedData.candidates[0].content);
|
|
96
|
+
t.truthy(parsedData.candidates[0].content.parts);
|
|
97
|
+
t.is(parsedData.candidates[0].content.parts[0].text, 'test content');
|
|
121
98
|
t.falsy(progress.progress);
|
|
122
99
|
|
|
123
|
-
// Test stream end with STOP
|
|
124
100
|
const endEvent = {
|
|
125
101
|
data: JSON.stringify({
|
|
126
102
|
candidates: [{
|
|
127
|
-
content: {
|
|
128
|
-
parts: [{ text: '' }]
|
|
129
|
-
},
|
|
103
|
+
content: { parts: [{ text: '' }] },
|
|
130
104
|
finishReason: 'STOP'
|
|
131
105
|
}]
|
|
132
106
|
})
|
|
@@ -136,17 +110,13 @@ test('Gemini Chat Plugin - processStreamEvent handles content chunks correctly',
|
|
|
136
110
|
t.is(progress.progress, 1);
|
|
137
111
|
});
|
|
138
112
|
|
|
139
|
-
// Test Gemini 15 Chat Plugin Streaming
|
|
140
113
|
test('Gemini 15 Chat Plugin - processStreamEvent handles safety blocks', async t => {
|
|
141
114
|
const resolver = createResolverWithPlugin(Gemini15ChatPlugin);
|
|
142
115
|
const plugin = resolver.modelExecutor.plugin;
|
|
143
116
|
|
|
144
|
-
// Test safety block
|
|
145
117
|
const safetyEvent = {
|
|
146
118
|
data: JSON.stringify({
|
|
147
|
-
candidates: [{
|
|
148
|
-
safetyRatings: [{ blocked: true }]
|
|
149
|
-
}]
|
|
119
|
+
candidates: [{ safetyRatings: [{ blocked: true }] }]
|
|
150
120
|
})
|
|
151
121
|
};
|
|
152
122
|
|
|
@@ -155,12 +125,10 @@ test('Gemini 15 Chat Plugin - processStreamEvent handles safety blocks', async t
|
|
|
155
125
|
t.is(progress.progress, 1);
|
|
156
126
|
});
|
|
157
127
|
|
|
158
|
-
// Test Claude 3 Vertex Plugin Streaming
|
|
159
128
|
test('Claude 3 Vertex Plugin - processStreamEvent handles message types', async t => {
|
|
160
129
|
const resolver = createResolverWithPlugin(Claude3VertexPlugin);
|
|
161
130
|
const plugin = resolver.modelExecutor.plugin;
|
|
162
131
|
|
|
163
|
-
// Test message start
|
|
164
132
|
const startEvent = {
|
|
165
133
|
data: JSON.stringify({
|
|
166
134
|
type: 'message_start',
|
|
@@ -171,27 +139,20 @@ test('Claude 3 Vertex Plugin - processStreamEvent handles message types', async
|
|
|
171
139
|
let progress = plugin.processStreamEvent(startEvent, {});
|
|
172
140
|
t.true(JSON.parse(progress.data).choices[0].delta.role === 'assistant');
|
|
173
141
|
|
|
174
|
-
// Test content block
|
|
175
142
|
const contentEvent = {
|
|
176
143
|
data: JSON.stringify({
|
|
177
144
|
type: 'content_block_delta',
|
|
178
|
-
delta: {
|
|
179
|
-
type: 'text_delta',
|
|
180
|
-
text: 'test content'
|
|
181
|
-
}
|
|
145
|
+
delta: { type: 'text_delta', text: 'test content' }
|
|
182
146
|
})
|
|
183
147
|
};
|
|
184
148
|
|
|
185
149
|
progress = plugin.processStreamEvent(contentEvent, {});
|
|
186
150
|
t.true(JSON.parse(progress.data).choices[0].delta.content === 'test content');
|
|
187
151
|
|
|
188
|
-
|
|
189
|
-
const stopEvent = {
|
|
190
|
-
data: JSON.stringify({
|
|
191
|
-
type: 'message_stop'
|
|
192
|
-
})
|
|
193
|
-
};
|
|
152
|
+
const stopEvent = { data: JSON.stringify({ type: 'message_stop' }) };
|
|
194
153
|
|
|
195
154
|
progress = plugin.processStreamEvent(stopEvent, {});
|
|
196
155
|
t.is(progress.progress, 1);
|
|
197
|
-
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
test preview gif content
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
test mogrt content
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
test preview mp4 content
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// sys_openai_chat_gpt4.js
|
|
2
|
-
// override handler for gpt-4
|
|
3
|
-
|
|
4
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
prompt:
|
|
8
|
-
[
|
|
9
|
-
new Prompt({ messages: [
|
|
10
|
-
"{{messages}}",
|
|
11
|
-
]}),
|
|
12
|
-
],
|
|
13
|
-
inputParameters: {
|
|
14
|
-
messages: [],
|
|
15
|
-
},
|
|
16
|
-
model: 'oai-gpt4',
|
|
17
|
-
useInputChunking: false,
|
|
18
|
-
emulateOpenAIChatModel: 'gpt-4',
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// sys_openai_chat_gpt4_32.js
|
|
2
|
-
// override handler for gpt-4-32
|
|
3
|
-
|
|
4
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
prompt:
|
|
8
|
-
[
|
|
9
|
-
new Prompt({ messages: [
|
|
10
|
-
"{{messages}}",
|
|
11
|
-
]}),
|
|
12
|
-
],
|
|
13
|
-
inputParameters: {
|
|
14
|
-
messages: [],
|
|
15
|
-
},
|
|
16
|
-
model: 'oai-gpt4-32',
|
|
17
|
-
useInputChunking: false,
|
|
18
|
-
emulateOpenAIChatModel: 'gpt-4-32k',
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// sys_openai_chat_gpt4_turbo.js
|
|
2
|
-
// override handler for gpt-4-turbo
|
|
3
|
-
|
|
4
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
prompt:
|
|
8
|
-
[
|
|
9
|
-
new Prompt({ messages: [
|
|
10
|
-
"{{messages}}",
|
|
11
|
-
]}),
|
|
12
|
-
],
|
|
13
|
-
inputParameters: {
|
|
14
|
-
messages: [],
|
|
15
|
-
},
|
|
16
|
-
model: 'oai-gpt4-turbo',
|
|
17
|
-
useInputChunking: false,
|
|
18
|
-
emulateOpenAIChatModel: 'gpt-4-turbo',
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Import required modules
|
|
3
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
prompt: [
|
|
7
|
-
new Prompt({
|
|
8
|
-
messages: [
|
|
9
|
-
{ "role": "system", "content": "{{{systemPrompt}}}" },
|
|
10
|
-
{ "role": "user", "content": "{{{text}}}\n\n{{{prompt}}}" }
|
|
11
|
-
]
|
|
12
|
-
}),
|
|
13
|
-
],
|
|
14
|
-
|
|
15
|
-
inputParameters: {
|
|
16
|
-
prompt: "",
|
|
17
|
-
systemPrompt: "Assistant is an expert journalist's assistant for a prestigious international news agency. When a user posts a request, Assistant will come up with the best response while upholding the highest journalistic standards.",
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
model: 'claude-35-sonnet-vertex',
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Import required modules
|
|
2
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
prompt: [
|
|
6
|
-
new Prompt({
|
|
7
|
-
messages: [
|
|
8
|
-
{ "role": "system", "content": "{{{systemPrompt}}}" },
|
|
9
|
-
{ "role": "user", "content": "{{{text}}}\n\n{{{prompt}}}" }
|
|
10
|
-
]
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
|
|
14
|
-
inputParameters: {
|
|
15
|
-
prompt: "",
|
|
16
|
-
systemPrompt: "Assistant is an expert journalist's assistant for a prestigious international news agency. When a user posts a request, Assistant will come up with the best response while upholding the highest journalistic standards.",
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
model: 'claude-3-haiku-vertex',
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Import required modules
|
|
2
|
-
import { Prompt } from "../../../server/prompt.js"
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
prompt: [
|
|
6
|
-
new Prompt({
|
|
7
|
-
messages: [
|
|
8
|
-
{ "role": "system", "content": "{{{systemPrompt}}}" },
|
|
9
|
-
{ "role": "user", "content": "{{{text}}}\n\n{{{prompt}}}" }
|
|
10
|
-
]
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
|
|
14
|
-
inputParameters: {
|
|
15
|
-
prompt: "",
|
|
16
|
-
systemPrompt: "Assistant is an expert journalist's assistant working for a prestigious international news agency. When a user posts a request, Assistant will come up with the best response while upholding the highest journalistic standards.",
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
model: 'oai-gpturbo',
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Import required modules
|
|
2
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
prompt: [
|
|
6
|
-
new Prompt({
|
|
7
|
-
messages: [
|
|
8
|
-
{ "role": "system", "content": "{{{systemPrompt}}}" },
|
|
9
|
-
{ "role": "user", "content": "{{{text}}}\n\n{{{prompt}}}" }
|
|
10
|
-
]
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
|
|
14
|
-
inputParameters: {
|
|
15
|
-
prompt: "",
|
|
16
|
-
systemPrompt: "Assistant is an expert journalist's assistant for a prestigious international news agency. When a user posts a request, Assistant will come up with the best response while upholding the highest journalistic standards.",
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
model: 'oai-gpt4',
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Import required modules
|
|
2
|
-
import { Prompt } from '../../../server/prompt.js';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
prompt: [
|
|
6
|
-
new Prompt({
|
|
7
|
-
messages: [
|
|
8
|
-
{ "role": "system", "content": "{{{systemPrompt}}}" },
|
|
9
|
-
{ "role": "user", "content": "{{{text}}}\n\n{{{prompt}}}" }
|
|
10
|
-
]
|
|
11
|
-
}),
|
|
12
|
-
],
|
|
13
|
-
|
|
14
|
-
inputParameters: {
|
|
15
|
-
prompt: "",
|
|
16
|
-
systemPrompt: "Assistant is an expert journalist's assistant for a prestigious international news agency. When a user posts a request, Assistant will come up with the best response while upholding the highest journalistic standards.",
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
model: 'oai-gpt4-32',
|
|
20
|
-
}
|