@aj-archipelago/cortex 1.3.64 → 1.3.66
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/README.md +50 -1
- package/lib/entityConstants.js +1 -1
- package/lib/pathwayManager.js +140 -12
- package/lib/pathwayTools.js +3 -3
- package/lib/util.js +1 -1
- package/package.json +1 -1
- package/pathways/system/entity/memory/sys_memory_format.js +1 -0
- package/pathways/system/entity/memory/sys_memory_manager.js +3 -3
- package/pathways/system/entity/sys_entity_start.js +1 -1
- package/pathways/system/entity/tools/sys_tool_bing_search_afagent.js +2 -0
- package/pathways/system/entity/tools/sys_tool_codingagent.js +2 -2
- package/pathways/system/entity/tools/sys_tool_google_search.js +3 -3
- package/pathways/system/entity/tools/sys_tool_grok_x_search.js +12 -2
- package/server/graphql.js +173 -8
- package/server/pathwayResolver.js +13 -5
- package/server/plugins/apptekTranslatePlugin.js +2 -2
- package/server/plugins/azureFoundryAgentsPlugin.js +1 -1
- package/server/prompt.js +2 -1
- package/server/typeDef.js +1 -1
- package/tests/unit/core/pathwayManager.test.js +768 -0
- package/tests/unit/server/graphql.test.js +170 -0
|
@@ -12,6 +12,7 @@ import { publishRequestProgress } from '../lib/redisSubscription.js';
|
|
|
12
12
|
import logger from '../lib/logger.js';
|
|
13
13
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
14
14
|
import { createParser } from 'eventsource-parser';
|
|
15
|
+
import CortexResponse from '../lib/cortexResponse.js';
|
|
15
16
|
|
|
16
17
|
const modelTypesExcludedFromProgressUpdates = ['OPENAI-DALLE2', 'OPENAI-DALLE3'];
|
|
17
18
|
|
|
@@ -292,7 +293,7 @@ class PathwayResolver {
|
|
|
292
293
|
requestProgress = this.modelExecutor.plugin.processStreamEvent(event, requestProgress);
|
|
293
294
|
} catch (error) {
|
|
294
295
|
streamErrorOccurred = true;
|
|
295
|
-
logger.error(`Stream error: ${error.message}`);
|
|
296
|
+
logger.error(`Stream error: ${error instanceof Error ? error.stack || error.message : JSON.stringify(error)}`);
|
|
296
297
|
incomingMessage.off('data', processStream);
|
|
297
298
|
return;
|
|
298
299
|
}
|
|
@@ -303,7 +304,7 @@ class PathwayResolver {
|
|
|
303
304
|
streamEnded = requestProgress.progress === 1;
|
|
304
305
|
}
|
|
305
306
|
} catch (error) {
|
|
306
|
-
logger.error(`Could not publish the stream message: "${event.data}", ${error}`);
|
|
307
|
+
logger.error(`Could not publish the stream message: "${event.data}", ${error instanceof Error ? error.stack || error.message : JSON.stringify(error)}`);
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
}
|
|
@@ -324,7 +325,7 @@ class PathwayResolver {
|
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
} catch (error) {
|
|
327
|
-
logger.error(`Could not subscribe to stream: ${error}`);
|
|
328
|
+
logger.error(`Could not subscribe to stream: ${error instanceof Error ? error.stack || error.message : JSON.stringify(error)}`);
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
if (streamErrorOccurred) {
|
|
@@ -589,11 +590,15 @@ class PathwayResolver {
|
|
|
589
590
|
// If the prompt doesn't contain {{text}} then we can skip the chunking, and also give that token space to the previous result
|
|
590
591
|
if (!this.prompts[i].usesTextInput) {
|
|
591
592
|
// Limit context to it's N + text's characters
|
|
592
|
-
|
|
593
|
+
if (previousResult) {
|
|
594
|
+
previousResult = this.truncate(previousResult, 2 * this.chunkMaxTokenLength);
|
|
595
|
+
}
|
|
593
596
|
result = await this.applyPrompt(this.prompts[i], null, currentParameters);
|
|
594
597
|
} else {
|
|
595
598
|
// Limit context to N characters
|
|
596
|
-
|
|
599
|
+
if (previousResult) {
|
|
600
|
+
previousResult = this.truncate(previousResult, this.chunkMaxTokenLength);
|
|
601
|
+
}
|
|
597
602
|
result = await Promise.all(chunks.map(chunk =>
|
|
598
603
|
this.applyPrompt(this.prompts[i], chunk, currentParameters)));
|
|
599
604
|
|
|
@@ -607,6 +612,9 @@ class PathwayResolver {
|
|
|
607
612
|
// If this is any prompt other than the last, use the result as the previous context
|
|
608
613
|
if (i < this.prompts.length - 1) {
|
|
609
614
|
previousResult = result;
|
|
615
|
+
if (result instanceof CortexResponse) {
|
|
616
|
+
previousResult = result.output_text;
|
|
617
|
+
}
|
|
610
618
|
}
|
|
611
619
|
}
|
|
612
620
|
// store the previous result in the PathwayResolver
|
|
@@ -95,7 +95,7 @@ class ApptekTranslatePlugin extends ModelPlugin {
|
|
|
95
95
|
detectedLanguage = result.split('\n')[0].split(';')[0];
|
|
96
96
|
} else {
|
|
97
97
|
logger.error(`Apptek Language detection failed with status: ${resultResponse.status}`);
|
|
98
|
-
logger.debug({
|
|
98
|
+
logger.debug(`Apptek language detection response: ${JSON.stringify({ status: resultResponse.status, textSnippet: text?.slice?.(0, 200) || text })}`)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (!detectedLanguage) {
|
|
@@ -111,7 +111,7 @@ class ApptekTranslatePlugin extends ModelPlugin {
|
|
|
111
111
|
text,
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
logger.verbose(
|
|
114
|
+
logger.verbose(`Successfully used language pathway as fallback: ${JSON.stringify({ detectedLanguage })}`);
|
|
115
115
|
if (!detectedLanguage) {
|
|
116
116
|
throw new Error('Language detection failed using fallback language pathway');
|
|
117
117
|
}
|
|
@@ -182,7 +182,7 @@ class AzureFoundryAgentsPlugin extends ModelPlugin {
|
|
|
182
182
|
|
|
183
183
|
// Check if run failed
|
|
184
184
|
if (runStatus.status === 'failed') {
|
|
185
|
-
logger.error(`[Azure Foundry Agent] Run failed: ${runId}
|
|
185
|
+
logger.error(`[Azure Foundry Agent] Run failed: ${runId} ${runStatus?.lastError ? JSON.stringify(runStatus.lastError) : ''}`);
|
|
186
186
|
return null;
|
|
187
187
|
}
|
|
188
188
|
|
package/server/prompt.js
CHANGED
|
@@ -3,12 +3,13 @@ class Prompt {
|
|
|
3
3
|
if (typeof params === 'string' || params instanceof String) {
|
|
4
4
|
this.prompt = params;
|
|
5
5
|
} else {
|
|
6
|
-
const { prompt, saveResultTo, messages, context, examples } = params;
|
|
6
|
+
const { prompt, saveResultTo, messages, context, examples, name } = params;
|
|
7
7
|
this.prompt = prompt;
|
|
8
8
|
this.saveResultTo = saveResultTo;
|
|
9
9
|
this.messages = messages;
|
|
10
10
|
this.context = context;
|
|
11
11
|
this.examples = examples;
|
|
12
|
+
this.name = name;
|
|
12
13
|
this.params = params;
|
|
13
14
|
}
|
|
14
15
|
|
package/server/typeDef.js
CHANGED