@eko-ai/eko 4.1.1 → 4.1.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.
- package/dist/index.cjs +46 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +44 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/llm/react.d.ts.map +1 -1
- package/dist/llm/rlm.d.ts.map +1 -1
- package/dist/memory/index.d.ts +2 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29813,7 +29813,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
29813
29813
|
}
|
|
29814
29814
|
|
|
29815
29815
|
// src/version.ts
|
|
29816
|
-
var VERSION$1 = "1.5.
|
|
29816
|
+
var VERSION$1 = "1.5.4";
|
|
29817
29817
|
|
|
29818
29818
|
// src/provider.ts
|
|
29819
29819
|
function createOpenRouter(options = {}) {
|
|
@@ -37133,15 +37133,15 @@ async function doCompressAgentMessages(agentContext, messages, tools) {
|
|
|
37133
37133
|
content: toolResult.content.filter((s) => s.type == "text"),
|
|
37134
37134
|
});
|
|
37135
37135
|
}
|
|
37136
|
-
function compressLargeContextMessages(messages) {
|
|
37136
|
+
function compressLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37137
37137
|
for (let r = 2; r < messages.length; r++) {
|
|
37138
37138
|
const message = messages[r];
|
|
37139
37139
|
if (message.role == "assistant") {
|
|
37140
37140
|
message.content = message.content.map((c) => {
|
|
37141
|
-
if (c.type == "text" && c.text.length >
|
|
37141
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37142
37142
|
return {
|
|
37143
37143
|
...c,
|
|
37144
|
-
text: sub(c.text,
|
|
37144
|
+
text: sub(c.text, largeTextLength, true),
|
|
37145
37145
|
};
|
|
37146
37146
|
}
|
|
37147
37147
|
return c;
|
|
@@ -37149,10 +37149,10 @@ function compressLargeContextMessages(messages) {
|
|
|
37149
37149
|
}
|
|
37150
37150
|
else if (message.role == "user") {
|
|
37151
37151
|
message.content = message.content.map((c) => {
|
|
37152
|
-
if (c.type == "text" && c.text.length >
|
|
37152
|
+
if (c.type == "text" && c.text.length > largeTextLength) {
|
|
37153
37153
|
return {
|
|
37154
37154
|
...c,
|
|
37155
|
-
text: sub(c.text,
|
|
37155
|
+
text: sub(c.text, largeTextLength, true),
|
|
37156
37156
|
};
|
|
37157
37157
|
}
|
|
37158
37158
|
return c;
|
|
@@ -37163,18 +37163,18 @@ function compressLargeContextMessages(messages) {
|
|
|
37163
37163
|
if (c.type == "tool-result" && c.output) {
|
|
37164
37164
|
const output = c.output;
|
|
37165
37165
|
if ((output.type == "text" || output.type == "error-text") &&
|
|
37166
|
-
output.value.length >
|
|
37166
|
+
output.value.length > largeTextLength) {
|
|
37167
37167
|
return {
|
|
37168
37168
|
...c,
|
|
37169
37169
|
output: {
|
|
37170
37170
|
...output,
|
|
37171
|
-
value: sub(output.value,
|
|
37171
|
+
value: sub(output.value, largeTextLength, true),
|
|
37172
37172
|
},
|
|
37173
37173
|
};
|
|
37174
37174
|
}
|
|
37175
37175
|
else if ((output.type == "json" || output.type == "error-json") &&
|
|
37176
|
-
JSON.stringify(output.value).length >
|
|
37177
|
-
const json_str = sub(JSON.stringify(output.value),
|
|
37176
|
+
JSON.stringify(output.value).length > largeTextLength) {
|
|
37177
|
+
const json_str = sub(JSON.stringify(output.value), largeTextLength, false);
|
|
37178
37178
|
const json_obj = fixJson(json_str);
|
|
37179
37179
|
if (JSON.stringify(json_obj).length < 10) {
|
|
37180
37180
|
return {
|
|
@@ -37200,8 +37200,8 @@ function compressLargeContextMessages(messages) {
|
|
|
37200
37200
|
for (let i = 0; i < output.value.length; i++) {
|
|
37201
37201
|
const content = output.value[i];
|
|
37202
37202
|
if (content.type == "text" &&
|
|
37203
|
-
content.text.length >
|
|
37204
|
-
content.text = sub(content.text,
|
|
37203
|
+
content.text.length > largeTextLength) {
|
|
37204
|
+
content.text = sub(content.text, largeTextLength, true);
|
|
37205
37205
|
}
|
|
37206
37206
|
}
|
|
37207
37207
|
}
|
|
@@ -37211,7 +37211,7 @@ function compressLargeContextMessages(messages) {
|
|
|
37211
37211
|
}
|
|
37212
37212
|
}
|
|
37213
37213
|
}
|
|
37214
|
-
function handleLargeContextMessages(messages) {
|
|
37214
|
+
function handleLargeContextMessages(messages, largeTextLength = config$1.largeTextLength) {
|
|
37215
37215
|
let imageNum = 0;
|
|
37216
37216
|
let fileNum = 0;
|
|
37217
37217
|
let maxNum = config$1.maxDialogueImgFileNum;
|
|
@@ -37267,7 +37267,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37267
37267
|
for (let r = 0; r < toolContent.value.length; r++) {
|
|
37268
37268
|
let _content = toolContent.value[r];
|
|
37269
37269
|
if (_content.type == "text" &&
|
|
37270
|
-
_content.text?.length >
|
|
37270
|
+
_content.text?.length > largeTextLength) {
|
|
37271
37271
|
if (!longTextTools[toolResult.toolName]) {
|
|
37272
37272
|
longTextTools[toolResult.toolName] = 1;
|
|
37273
37273
|
break;
|
|
@@ -37277,7 +37277,7 @@ function handleLargeContextMessages(messages) {
|
|
|
37277
37277
|
}
|
|
37278
37278
|
_content = {
|
|
37279
37279
|
type: "text",
|
|
37280
|
-
text: sub(_content.text,
|
|
37280
|
+
text: sub(_content.text, largeTextLength, true),
|
|
37281
37281
|
};
|
|
37282
37282
|
toolContent.value[r] = _content;
|
|
37283
37283
|
}
|
|
@@ -37707,7 +37707,7 @@ class RetryLanguageModel {
|
|
|
37707
37707
|
this.llms = llms;
|
|
37708
37708
|
this.names = names || [];
|
|
37709
37709
|
context && this.setContext(context);
|
|
37710
|
-
this.stream_first_timeout = stream_first_timeout ||
|
|
37710
|
+
this.stream_first_timeout = stream_first_timeout || 45000;
|
|
37711
37711
|
this.stream_token_timeout = stream_token_timeout || 180000;
|
|
37712
37712
|
if (this.names.indexOf("default") == -1) {
|
|
37713
37713
|
this.names.push("default");
|
|
@@ -37755,7 +37755,13 @@ class RetryLanguageModel {
|
|
|
37755
37755
|
if (!providerOptions) {
|
|
37756
37756
|
options.providerOptions = defaultLLMProviderOptions();
|
|
37757
37757
|
if (llmConfig.options && Object.keys(llmConfig.options).length > 0) {
|
|
37758
|
-
|
|
37758
|
+
// Filter out keys that start with 'stream_'
|
|
37759
|
+
options.providerOptions[llm.provider] = Object.entries(llmConfig.options).reduce((acc, [key, value]) => {
|
|
37760
|
+
if (!key.startsWith("stream_")) {
|
|
37761
|
+
acc[key] = value;
|
|
37762
|
+
}
|
|
37763
|
+
return acc;
|
|
37764
|
+
}, {});
|
|
37759
37765
|
}
|
|
37760
37766
|
}
|
|
37761
37767
|
let _options = options;
|
|
@@ -37868,12 +37874,11 @@ class RetryLanguageModel {
|
|
|
37868
37874
|
}
|
|
37869
37875
|
lastError = e;
|
|
37870
37876
|
if (Log.isEnableInfo()) {
|
|
37871
|
-
Log.info(`LLM stream request, name: ${name} => `, {
|
|
37872
|
-
tools: _options.tools,
|
|
37877
|
+
Log.info(`LLM stream request, name: ${name} => `, e, {
|
|
37873
37878
|
messages: _options.prompt,
|
|
37879
|
+
tools: _options.tools,
|
|
37874
37880
|
});
|
|
37875
37881
|
}
|
|
37876
|
-
Log.error(`LLM error, name: ${name} => `, e);
|
|
37877
37882
|
}
|
|
37878
37883
|
}
|
|
37879
37884
|
return Promise.reject(lastError ? lastError : new Error("No LLM available"));
|
|
@@ -38377,14 +38382,28 @@ async function callLLM(rlm, request, streamCallback, errorHandler, finishHandler
|
|
|
38377
38382
|
}
|
|
38378
38383
|
}
|
|
38379
38384
|
catch (e) {
|
|
38380
|
-
if (
|
|
38381
|
-
await sleep(200 * (retryNum + 1) * (retryNum + 1));
|
|
38385
|
+
if (e instanceof Error && e.name === "AbortError") {
|
|
38382
38386
|
if (errorHandler) {
|
|
38383
38387
|
await errorHandler(request, e, retryNum);
|
|
38384
38388
|
}
|
|
38385
|
-
|
|
38389
|
+
Log.warn("callLLM abort error: ", e);
|
|
38390
|
+
return streamText
|
|
38391
|
+
? [
|
|
38392
|
+
{ type: "text", text: streamText },
|
|
38393
|
+
...toolParts,
|
|
38394
|
+
]
|
|
38395
|
+
: toolParts;
|
|
38396
|
+
}
|
|
38397
|
+
else {
|
|
38398
|
+
if (retryNum < config$1.maxRetryNum) {
|
|
38399
|
+
await sleep(200 * (retryNum + 1) * (retryNum + 1));
|
|
38400
|
+
if (errorHandler) {
|
|
38401
|
+
await errorHandler(request, e, retryNum);
|
|
38402
|
+
}
|
|
38403
|
+
return callLLM(rlm, request, streamCallback, errorHandler, finishHandler, ++retryNum);
|
|
38404
|
+
}
|
|
38405
|
+
throw e;
|
|
38386
38406
|
}
|
|
38387
|
-
throw e;
|
|
38388
38407
|
}
|
|
38389
38408
|
finally {
|
|
38390
38409
|
reader && reader.releaseLock();
|
|
@@ -44985,11 +45004,14 @@ exports.callLLM = callLLM;
|
|
|
44985
45004
|
exports.callWithReAct = callWithReAct;
|
|
44986
45005
|
exports.call_timeout = call_timeout;
|
|
44987
45006
|
exports.compressImageData = compressImageData;
|
|
45007
|
+
exports.compressLargeContextMessages = compressLargeContextMessages;
|
|
44988
45008
|
exports.config = config$1;
|
|
44989
45009
|
exports.convertToolSchema = convertToolSchema;
|
|
44990
45010
|
exports.default = Eko;
|
|
44991
45011
|
exports.extract_page_content = extract_page_content;
|
|
45012
|
+
exports.fixJson = fixJson;
|
|
44992
45013
|
exports.global = global;
|
|
45014
|
+
exports.handleLargeContextMessages = handleLargeContextMessages;
|
|
44993
45015
|
exports.mergeTools = mergeTools;
|
|
44994
45016
|
exports.parseWorkflow = parseWorkflow;
|
|
44995
45017
|
exports.resetWorkflowXml = resetWorkflowXml;
|