@eko-ai/eko 2.1.8-alpha.1 → 2.1.8-alpha.2
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/agent/llm.d.ts.map +1 -1
- package/dist/index.cjs.js +26 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +26 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/types/llm.types.d.ts +2 -1
- package/dist/types/llm.types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/agent/llm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAGL,cAAc,EACd,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EAErB,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,2BAA2B,EAAE,EACpC,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,yBAAyB,EACtC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,GACxC,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,2BAA2B,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAGL,cAAc,EACd,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EAErB,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,2BAA2B,EAAE,EACpC,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,yBAAyB,EACtC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,GACxC,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,2BAA2B,CAAC,CAAC,CA0TvE"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -14161,7 +14161,7 @@ class RetryLanguageModel {
|
|
|
14161
14161
|
this.llms = llms;
|
|
14162
14162
|
this.names = names || [];
|
|
14163
14163
|
this.stream_first_timeout = stream_first_timeout || 30000;
|
|
14164
|
-
this.stream_token_timeout = stream_token_timeout ||
|
|
14164
|
+
this.stream_token_timeout = stream_token_timeout || 180000;
|
|
14165
14165
|
if (this.names.indexOf("default") == -1) {
|
|
14166
14166
|
this.names.push("default");
|
|
14167
14167
|
}
|
|
@@ -14189,25 +14189,29 @@ class RetryLanguageModel {
|
|
|
14189
14189
|
let lastError;
|
|
14190
14190
|
for (let i = 0; i < names.length; i++) {
|
|
14191
14191
|
const name = names[i];
|
|
14192
|
+
const llmConfig = this.llms[name];
|
|
14192
14193
|
const llm = await this.getLLM(name);
|
|
14193
14194
|
if (!llm) {
|
|
14194
14195
|
continue;
|
|
14195
14196
|
}
|
|
14196
14197
|
if (!maxTokens) {
|
|
14197
|
-
options.maxTokens =
|
|
14198
|
-
this.llms[name].config?.maxTokens || config.maxTokens;
|
|
14198
|
+
options.maxTokens = llmConfig.config?.maxTokens || config.maxTokens;
|
|
14199
14199
|
}
|
|
14200
14200
|
if (!providerMetadata) {
|
|
14201
14201
|
options.providerMetadata = {};
|
|
14202
|
-
options.providerMetadata[llm.provider] =
|
|
14202
|
+
options.providerMetadata[llm.provider] = llmConfig.options || {};
|
|
14203
|
+
}
|
|
14204
|
+
let _options = options;
|
|
14205
|
+
if (llmConfig.handler) {
|
|
14206
|
+
_options = await llmConfig.handler(_options);
|
|
14203
14207
|
}
|
|
14204
14208
|
try {
|
|
14205
|
-
let result = (await llm.doGenerate(
|
|
14209
|
+
let result = (await llm.doGenerate(_options));
|
|
14206
14210
|
if (Log.isEnableDebug()) {
|
|
14207
14211
|
Log.debug(`LLM nonstream body, name: ${name} => `, result.request?.body);
|
|
14208
14212
|
}
|
|
14209
14213
|
result.llm = name;
|
|
14210
|
-
result.llmConfig =
|
|
14214
|
+
result.llmConfig = llmConfig;
|
|
14211
14215
|
return result;
|
|
14212
14216
|
}
|
|
14213
14217
|
catch (e) {
|
|
@@ -14217,8 +14221,8 @@ class RetryLanguageModel {
|
|
|
14217
14221
|
lastError = e;
|
|
14218
14222
|
if (Log.isEnableInfo()) {
|
|
14219
14223
|
Log.info(`LLM nonstream request, name: ${name} => `, {
|
|
14220
|
-
tools:
|
|
14221
|
-
messages:
|
|
14224
|
+
tools: _options.mode?.tools,
|
|
14225
|
+
messages: _options.prompt,
|
|
14222
14226
|
});
|
|
14223
14227
|
}
|
|
14224
14228
|
Log.error(`LLM error, name: ${name} => `, e);
|
|
@@ -14249,24 +14253,28 @@ class RetryLanguageModel {
|
|
|
14249
14253
|
let lastError;
|
|
14250
14254
|
for (let i = 0; i < names.length; i++) {
|
|
14251
14255
|
const name = names[i];
|
|
14256
|
+
const llmConfig = this.llms[name];
|
|
14252
14257
|
const llm = await this.getLLM(name);
|
|
14253
14258
|
if (!llm) {
|
|
14254
14259
|
continue;
|
|
14255
14260
|
}
|
|
14256
14261
|
if (!maxTokens) {
|
|
14257
|
-
options.maxTokens =
|
|
14258
|
-
this.llms[name].config?.maxTokens || config.maxTokens;
|
|
14262
|
+
options.maxTokens = llmConfig.config?.maxTokens || config.maxTokens;
|
|
14259
14263
|
}
|
|
14260
14264
|
if (!providerMetadata) {
|
|
14261
14265
|
options.providerMetadata = {};
|
|
14262
|
-
options.providerMetadata[llm.provider] =
|
|
14266
|
+
options.providerMetadata[llm.provider] = llmConfig.options || {};
|
|
14267
|
+
}
|
|
14268
|
+
let _options = options;
|
|
14269
|
+
if (llmConfig.handler) {
|
|
14270
|
+
_options = await llmConfig.handler(_options);
|
|
14263
14271
|
}
|
|
14264
14272
|
try {
|
|
14265
14273
|
const controller = new AbortController();
|
|
14266
|
-
const signal =
|
|
14267
|
-
? AbortSignal.any([
|
|
14274
|
+
const signal = _options.abortSignal
|
|
14275
|
+
? AbortSignal.any([_options.abortSignal, controller.signal])
|
|
14268
14276
|
: controller.signal;
|
|
14269
|
-
const result = (await call_timeout(async () => await llm.doStream({ ...
|
|
14277
|
+
const result = (await call_timeout(async () => await llm.doStream({ ..._options, abortSignal: signal }), this.stream_first_timeout, (e) => {
|
|
14270
14278
|
controller.abort();
|
|
14271
14279
|
}));
|
|
14272
14280
|
const stream = result.stream;
|
|
@@ -14291,7 +14299,7 @@ class RetryLanguageModel {
|
|
|
14291
14299
|
continue;
|
|
14292
14300
|
}
|
|
14293
14301
|
result.llm = name;
|
|
14294
|
-
result.llmConfig =
|
|
14302
|
+
result.llmConfig = llmConfig;
|
|
14295
14303
|
result.stream = this.streamWrapper([chunk], reader, controller);
|
|
14296
14304
|
return result;
|
|
14297
14305
|
}
|
|
@@ -14302,8 +14310,8 @@ class RetryLanguageModel {
|
|
|
14302
14310
|
lastError = e;
|
|
14303
14311
|
if (Log.isEnableInfo()) {
|
|
14304
14312
|
Log.info(`LLM stream request, name: ${name} => `, {
|
|
14305
|
-
tools:
|
|
14306
|
-
messages:
|
|
14313
|
+
tools: _options.mode?.tools,
|
|
14314
|
+
messages: _options.prompt,
|
|
14307
14315
|
});
|
|
14308
14316
|
}
|
|
14309
14317
|
Log.error(`LLM error, name: ${name} => `, e);
|
|
@@ -17415,6 +17423,7 @@ async function callAgentLLM(agentContext, rlm, messages, tools, noCompress, tool
|
|
|
17415
17423
|
catch (e) {
|
|
17416
17424
|
await context.checkAborted();
|
|
17417
17425
|
if (!retry) {
|
|
17426
|
+
await sleep(200);
|
|
17418
17427
|
return callAgentLLM(agentContext, rlm, messages, tools, noCompress, toolChoice, true, streamCallback);
|
|
17419
17428
|
}
|
|
17420
17429
|
throw e;
|