llmz 0.9.0 → 0.9.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/{common-BnvrDnIT.cjs → common-DJkSpeqw.cjs} +1 -1
- package/dist/{common-BlRFtdf2.js → common-DuEhn6u3.js} +1 -1
- package/dist/compiler/plugins/variable-extraction.d.ts +1 -7
- package/dist/{compiler-C-OI9sim.cjs → compiler-BJJUmNS9.cjs} +34 -68
- package/dist/{compiler-CW1VjQsn.js → compiler-BPl-5CXh.js} +34 -68
- package/dist/{component-C6Agl2ns.cjs → component-CPKXe6Ca.cjs} +2 -2
- package/dist/{custom-client-DAsGRnYc.cjs → custom-client-B_o56CB4.cjs} +6 -6
- package/dist/{custom-client-ChuZ63zp.js → custom-client-C-nDKG37.js} +3 -3
- package/dist/{dual-modes-DPXiuvNe.cjs → dual-modes-BNHlj2qM.cjs} +15 -14
- package/dist/{dual-modes-DDkoCp3R.js → dual-modes-BNIiNLrR.js} +13 -12
- package/dist/{execute-DM2-7y86.cjs → execute-0bvqakr7.cjs} +31 -18
- package/dist/{execute-BWcdv9so.js → execute-CWFIL5ny.js} +30 -17
- package/dist/{exit-DUM96DN1.cjs → exit-CGLXI0BH.cjs} +2 -2
- package/dist/index.cjs +21 -21
- package/dist/index.js +12 -12
- package/dist/index.workerd.js +217 -195
- package/dist/{jsx-owqxrquU.cjs → jsx-BJ6GWXI2.cjs} +1 -1
- package/dist/runtime/generate.test.d.ts +1 -0
- package/dist/{tool-Bv8N4IPj.js → tool-B6Pmuk6K.js} +35 -49
- package/dist/{tool-Dy6AJpJH.cjs → tool-BLTrA-sL.cjs} +38 -52
- package/dist/tool.d.ts +5 -3
- package/dist/{truncator-DZqEqnpD.js → truncator-CD7QtE84.js} +11 -6
- package/dist/{truncator-CLkouTCO.cjs → truncator-DmCu9M4m.cjs} +13 -8
- package/dist/{typings-3lsqCbkn.cjs → typings-DXJMu59O.cjs} +2 -2
- package/dist/{utils-3ESwP3yg.cjs → utils-DGQ4sRke.cjs} +1 -1
- package/dist/{vm-BLsHw1da.js → vm-Cn3jvZ00.js} +109 -53
- package/dist/{vm-D6s1zF6M.cjs → vm-X0uTj5Aa.cjs} +109 -53
- package/package.json +2 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as isEqual, l as toNumber } from "./dual-modes-
|
|
2
|
-
import { a as ResponseParser, i as toParsedAssistantResponse } from "./common-
|
|
3
|
-
import { d as Snapshot, f as parseExit, l as PartialExecutionResult, n as Context, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-
|
|
4
|
-
import { d as stripInvalidIdentifiers, i as getErrorMessage, s as init } from "./utils-UBeAFeEI.js";
|
|
1
|
+
import { a as isEqual, l as toNumber } from "./dual-modes-BNIiNLrR.js";
|
|
2
|
+
import { a as ResponseParser, i as toParsedAssistantResponse } from "./common-DuEhn6u3.js";
|
|
3
|
+
import { d as Snapshot, f as parseExit, l as PartialExecutionResult, n as Context, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-C-nDKG37.js";
|
|
4
|
+
import { d as stripInvalidIdentifiers, i as getErrorMessage, r as fromJSONSchemaCompat, s as init } from "./utils-UBeAFeEI.js";
|
|
5
5
|
import { t as createJsxComponent } from "./jsx-CIgdGGVs.js";
|
|
6
6
|
import { t as cleanStackTrace } from "./stack-traces-BIE_5Xwf.js";
|
|
7
7
|
import { a as InvalidCodeError, c as SnapshotSignal, i as CognitiveError, l as ThinkSignal, n as CodeExecutionError, o as LoopExceededError, s as Signals, t as AssignmentError } from "./errors-Cg1G0Awu.js";
|
|
8
|
-
import { n as truncateWrappedContent } from "./truncator-
|
|
9
|
-
import { r as hasTopLevelReturn } from "./compiler-
|
|
10
|
-
import { runAsyncFunction, warmupVM } from "./vm-
|
|
8
|
+
import { n as truncateWrappedContent } from "./truncator-CD7QtE84.js";
|
|
9
|
+
import { r as hasTopLevelReturn } from "./compiler-BPl-5CXh.js";
|
|
10
|
+
import { runAsyncFunction, warmupVM } from "./vm-Cn3jvZ00.js";
|
|
11
11
|
import { z } from "@bpinternal/zui";
|
|
12
12
|
import { ulid } from "ulid";
|
|
13
13
|
import { Client } from "@botpress/client";
|
|
@@ -125,19 +125,21 @@ const STREAM_INACTIVITY_TIMEOUT = 18e4;
|
|
|
125
125
|
/** A syntactically valid prefix must not execute when generation did not finish successfully. */
|
|
126
126
|
const assertSuccessfulGeneration = (metadata) => {
|
|
127
127
|
if (metadata.provider === "unknown") throw new CognitiveError("LLM generation failed: received error metadata with unknown provider");
|
|
128
|
-
if (metadata.stopReason === "max_tokens" || metadata.stopReason === "content_filter") throw new CognitiveError(`LLM generation did not complete: stopReason=${metadata.stopReason}`);
|
|
128
|
+
if (metadata.stopReason === "max_tokens" || metadata.stopReason === "content_filter" || metadata.stopReason === "other") throw new CognitiveError(`LLM generation did not complete: stopReason=${metadata.stopReason}`);
|
|
129
129
|
};
|
|
130
130
|
const getModelOutputLimit = (inputLength) => clamp(RESPONSE_LENGTH_BUFFER.PERCENTAGE * inputLength, RESPONSE_LENGTH_BUFFER.MIN_TOKENS, RESPONSE_LENGTH_BUFFER.MAX_TOKENS);
|
|
131
131
|
const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, onSend, onSendDelta, onRunStart }) => {
|
|
132
132
|
const startedAt = Date.now();
|
|
133
133
|
const traces = iteration.traces;
|
|
134
|
-
|
|
135
|
-
const
|
|
134
|
+
controller.signal.throwIfAborted();
|
|
135
|
+
const modelRefs = Array.isArray(iteration.model) ? iteration.model : [iteration.model];
|
|
136
|
+
const models = await Promise.all(modelRefs.map((modelRef) => cognitive.getModelDetails(modelRef).catch((thrown) => {
|
|
136
137
|
throw new CognitiveError(`Failed to fetch model details for model "${modelRef}": ${getErrorMessage(thrown)}`);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
138
|
+
})));
|
|
139
|
+
controller.signal.throwIfAborted();
|
|
140
|
+
const model = models[0];
|
|
141
|
+
const modelLimit = Math.min(...models.map((model) => model.input.maxTokens), ctx.maxTokens ?? Infinity);
|
|
142
|
+
const responseLengthBuffer = Math.min(getModelOutputLimit(modelLimit), Math.floor(modelLimit / 2));
|
|
141
143
|
if (iteration.tokens) iteration.tokens.limit = modelLimit;
|
|
142
144
|
let messages;
|
|
143
145
|
try {
|
|
@@ -357,6 +359,7 @@ const generateCode = async ({ iteration, ctx, cognitive, controller, metadata, o
|
|
|
357
359
|
const response = await cognitive.generateText(input, { signal: controller.signal }).catch((thrown) => {
|
|
358
360
|
throw new CognitiveError(`LLM generation failed: ${getErrorMessage(thrown)}`);
|
|
359
361
|
});
|
|
362
|
+
controller.signal.throwIfAborted();
|
|
360
363
|
if (response.error) throw new CognitiveError(`LLM generation failed: ${response.error}`);
|
|
361
364
|
if (!response.output) throw new CognitiveError("LLM did not return any text output");
|
|
362
365
|
responseMetadata = response.metadata;
|
|
@@ -567,8 +570,10 @@ const finalizeIteration = async ({ iteration, status, controller, onIterationEnd
|
|
|
567
570
|
//#region src/runtime/tool-wrapper.ts
|
|
568
571
|
const SLOW_TOOL_WARNING = ms("15s");
|
|
569
572
|
function wrapTool({ chat, tool, traces, object, iteration, beforeHook, afterHook, controller }) {
|
|
570
|
-
const
|
|
573
|
+
const traceSchema = tool.input ? fromJSONSchemaCompat(tool.input) : void 0;
|
|
574
|
+
const getToolInput = (input) => (traceSchema === null || traceSchema === void 0 ? void 0 : traceSchema.safeParse(input).data) ?? input;
|
|
571
575
|
return async function(input) {
|
|
576
|
+
controller.signal.throwIfAborted();
|
|
572
577
|
const toolCallId = `tcall_${ulid()}`;
|
|
573
578
|
const originalInput = input;
|
|
574
579
|
let effectiveInput = input;
|
|
@@ -644,6 +649,7 @@ function wrapTool({ chat, tool, traces, object, iteration, beforeHook, afterHook
|
|
|
644
649
|
object,
|
|
645
650
|
toolCallId
|
|
646
651
|
}));
|
|
652
|
+
controller.signal.throwIfAborted();
|
|
647
653
|
if (typeof (beforeRes === null || beforeRes === void 0 ? void 0 : beforeRes.input) !== "undefined") effectiveInput = beforeRes.input;
|
|
648
654
|
output = await tool.execute(effectiveInput, {
|
|
649
655
|
callId: toolCallId,
|
|
@@ -660,9 +666,16 @@ function wrapTool({ chat, tool, traces, object, iteration, beforeHook, afterHook
|
|
|
660
666
|
}));
|
|
661
667
|
if (typeof (afterRes === null || afterRes === void 0 ? void 0 : afterRes.output) !== "undefined") output = afterRes.output;
|
|
662
668
|
} catch (err) {
|
|
663
|
-
|
|
669
|
+
try {
|
|
670
|
+
if (!await handleSignals(err)) {
|
|
671
|
+
success = false;
|
|
672
|
+
error = err;
|
|
673
|
+
output = void 0;
|
|
674
|
+
}
|
|
675
|
+
} catch (hookError) {
|
|
664
676
|
success = false;
|
|
665
|
-
error =
|
|
677
|
+
error = hookError;
|
|
678
|
+
output = void 0;
|
|
666
679
|
}
|
|
667
680
|
} finally {
|
|
668
681
|
clearTimeout(alertSlowTool);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
2
|
const require_uniq = require("./uniq-G872RWmE.cjs");
|
|
3
|
-
const require_utils = require("./utils-
|
|
3
|
+
const require_utils = require("./utils-DGQ4sRke.cjs");
|
|
4
4
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
5
5
|
//#region src/exit.ts
|
|
6
6
|
var exit_exports = /* @__PURE__ */ require_compiler.__exportAll({ Exit: () => Exit });
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dual_modes = require("./dual-modes-
|
|
3
|
-
const require_common = require("./common-
|
|
4
|
-
const require_custom_client = require("./custom-client-
|
|
5
|
-
const require_utils = require("./utils-
|
|
6
|
-
const require_tool = require("./tool-
|
|
2
|
+
const require_dual_modes = require("./dual-modes-BNHlj2qM.cjs");
|
|
3
|
+
const require_common = require("./common-DJkSpeqw.cjs");
|
|
4
|
+
const require_custom_client = require("./custom-client-B_o56CB4.cjs");
|
|
5
|
+
const require_utils = require("./utils-DGQ4sRke.cjs");
|
|
6
|
+
const require_tool = require("./tool-BLTrA-sL.cjs");
|
|
7
7
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
8
|
-
const require_typings = require("./typings-
|
|
9
|
-
const require_exit = require("./exit-
|
|
10
|
-
const require_component = require("./component-
|
|
11
|
-
const require_truncator = require("./truncator-
|
|
8
|
+
const require_typings = require("./typings-DXJMu59O.cjs");
|
|
9
|
+
const require_exit = require("./exit-CGLXI0BH.cjs");
|
|
10
|
+
const require_component = require("./component-CPKXe6Ca.cjs");
|
|
11
|
+
const require_truncator = require("./truncator-DmCu9M4m.cjs");
|
|
12
12
|
const require_quickjs_variant = require("./quickjs-variant-CsIwTVFC.cjs");
|
|
13
13
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
14
14
|
//#region package.json
|
|
15
|
-
var version = "0.9.
|
|
15
|
+
var version = "0.9.2";
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/hoist.ts
|
|
18
18
|
/**
|
|
@@ -1693,7 +1693,7 @@ const utils = {
|
|
|
1693
1693
|
* })
|
|
1694
1694
|
*/
|
|
1695
1695
|
const execute = async (props) => {
|
|
1696
|
-
const { executeContext } = await Promise.resolve().then(() => require("./execute-
|
|
1696
|
+
const { executeContext } = await Promise.resolve().then(() => require("./execute-0bvqakr7.cjs"));
|
|
1697
1697
|
return executeContext(props);
|
|
1698
1698
|
};
|
|
1699
1699
|
/**
|
|
@@ -1702,16 +1702,16 @@ const execute = async (props) => {
|
|
|
1702
1702
|
* It's recommended to call this function at the beginning of your application without awaiting it (void init())
|
|
1703
1703
|
*/
|
|
1704
1704
|
const init = async () => {
|
|
1705
|
-
await Promise.resolve().then(() => require("./execute-
|
|
1706
|
-
await Promise.resolve().then(() => require("./component-
|
|
1707
|
-
await Promise.resolve().then(() => require("./tool-
|
|
1708
|
-
await Promise.resolve().then(() => require("./exit-
|
|
1709
|
-
await Promise.resolve().then(() => require("./jsx-
|
|
1710
|
-
await Promise.resolve().then(() => require("./vm-
|
|
1711
|
-
await Promise.resolve().then(() => require("./utils-
|
|
1712
|
-
await Promise.resolve().then(() => require("./truncator-
|
|
1713
|
-
await Promise.resolve().then(() => require("./typings-
|
|
1714
|
-
await Promise.resolve().then(() => require("./dual-modes-
|
|
1705
|
+
await Promise.resolve().then(() => require("./execute-0bvqakr7.cjs"));
|
|
1706
|
+
await Promise.resolve().then(() => require("./component-CPKXe6Ca.cjs")).then((n) => n.component_exports);
|
|
1707
|
+
await Promise.resolve().then(() => require("./tool-BLTrA-sL.cjs")).then((n) => n.tool_exports);
|
|
1708
|
+
await Promise.resolve().then(() => require("./exit-CGLXI0BH.cjs")).then((n) => n.exit_exports);
|
|
1709
|
+
await Promise.resolve().then(() => require("./jsx-BJ6GWXI2.cjs")).then((n) => n.jsx_exports);
|
|
1710
|
+
await Promise.resolve().then(() => require("./vm-X0uTj5Aa.cjs"));
|
|
1711
|
+
await Promise.resolve().then(() => require("./utils-DGQ4sRke.cjs")).then((n) => n.utils_exports);
|
|
1712
|
+
await Promise.resolve().then(() => require("./truncator-DmCu9M4m.cjs")).then((n) => n.truncator_exports);
|
|
1713
|
+
await Promise.resolve().then(() => require("./typings-DXJMu59O.cjs")).then((n) => n.typings_exports);
|
|
1714
|
+
await Promise.resolve().then(() => require("./dual-modes-BNHlj2qM.cjs")).then((n) => n.dual_modes_exports);
|
|
1715
1715
|
};
|
|
1716
1716
|
//#endregion
|
|
1717
1717
|
exports.BaseResponse = BaseResponse;
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { d as generateInstructions, f as validateComponent, m as ComponentRegistry, p as validateProps, u as Example } from "./dual-modes-
|
|
2
|
-
import { c as MARKER, l as NAME_REGEX, o as StreamingMessageParser, s as tryParseJson } from "./common-
|
|
3
|
-
import { a as ThinkExit, c as ExecutionResult, d as Snapshot, f as parseExit, i as ListenExit, l as PartialExecutionResult, o as getValue, r as DefaultExit, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-
|
|
1
|
+
import { d as generateInstructions, f as validateComponent, m as ComponentRegistry, p as validateProps, u as Example } from "./dual-modes-BNIiNLrR.js";
|
|
2
|
+
import { c as MARKER, l as NAME_REGEX, o as StreamingMessageParser, s as tryParseJson } from "./common-DuEhn6u3.js";
|
|
3
|
+
import { a as ThinkExit, c as ExecutionResult, d as Snapshot, f as parseExit, i as ListenExit, l as PartialExecutionResult, o as getValue, r as DefaultExit, s as ErrorExecutionResult, t as _CustomModelClient, u as SuccessExecutionResult } from "./custom-client-C-nDKG37.js";
|
|
4
4
|
import { a as getMultilineComment, c as isJsonSchema, l as isValidIdentifier, m as toValidObjectName, n as escapeString, p as toValidFunctionName, t as configureTokenizer, u as isZuiSchema, v as upperFirst } from "./utils-UBeAFeEI.js";
|
|
5
|
-
import { t as Tool } from "./tool-
|
|
5
|
+
import { t as Tool } from "./tool-B6Pmuk6K.js";
|
|
6
6
|
import { c as SnapshotSignal, l as ThinkSignal, o as LoopExceededError, r as CodeFormattingError } from "./errors-Cg1G0Awu.js";
|
|
7
7
|
import { a as isPunct, i as isGroup, o as parse, r as formatTypings, s as tokenize, t as getTypings } from "./typings-CrBa7Tyy.js";
|
|
8
8
|
import { t as Exit } from "./exit-CDdxDBRT.js";
|
|
9
9
|
import { a as isComponent, i as isAnyComponent, n as assertValidComponent, t as Component } from "./component-DGG7d_Mz.js";
|
|
10
|
-
import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags } from "./truncator-
|
|
10
|
+
import { i as wrapContent, n as truncateWrappedContent, t as stripTruncationTags } from "./truncator-CD7QtE84.js";
|
|
11
11
|
import { t as configureQuickJS } from "./quickjs-variant-BYhMBpwU.js";
|
|
12
12
|
import { transforms, z } from "@bpinternal/zui";
|
|
13
13
|
//#region package.json
|
|
14
|
-
var version = "0.9.
|
|
14
|
+
var version = "0.9.2";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/hoist.ts
|
|
17
17
|
/**
|
|
@@ -1692,7 +1692,7 @@ const utils = {
|
|
|
1692
1692
|
* })
|
|
1693
1693
|
*/
|
|
1694
1694
|
const execute = async (props) => {
|
|
1695
|
-
const { executeContext } = await import("./execute-
|
|
1695
|
+
const { executeContext } = await import("./execute-CWFIL5ny.js");
|
|
1696
1696
|
return executeContext(props);
|
|
1697
1697
|
};
|
|
1698
1698
|
/**
|
|
@@ -1701,16 +1701,16 @@ const execute = async (props) => {
|
|
|
1701
1701
|
* It's recommended to call this function at the beginning of your application without awaiting it (void init())
|
|
1702
1702
|
*/
|
|
1703
1703
|
const init = async () => {
|
|
1704
|
-
await import("./execute-
|
|
1704
|
+
await import("./execute-CWFIL5ny.js");
|
|
1705
1705
|
await import("./component-DGG7d_Mz.js").then((n) => n.r);
|
|
1706
|
-
await import("./tool-
|
|
1706
|
+
await import("./tool-B6Pmuk6K.js").then((n) => n.n);
|
|
1707
1707
|
await import("./exit-CDdxDBRT.js").then((n) => n.n);
|
|
1708
1708
|
await import("./jsx-CIgdGGVs.js").then((n) => n.i);
|
|
1709
|
-
await import("./vm-
|
|
1709
|
+
await import("./vm-Cn3jvZ00.js");
|
|
1710
1710
|
await import("./utils-UBeAFeEI.js").then((n) => n.h);
|
|
1711
|
-
await import("./truncator-
|
|
1711
|
+
await import("./truncator-CD7QtE84.js").then((n) => n.r);
|
|
1712
1712
|
await import("./typings-CrBa7Tyy.js").then((n) => n.n);
|
|
1713
|
-
await import("./dual-modes-
|
|
1713
|
+
await import("./dual-modes-BNIiNLrR.js").then((n) => n.n);
|
|
1714
1714
|
};
|
|
1715
1715
|
//#endregion
|
|
1716
1716
|
export { BaseResponse, Chat, CitationsManager, Component, ComponentRegistry, DefaultComponents, DefaultExit, ErrorExecutionResult, Example, ExecutionResult, Exit, ListenExit, LoopExceededError, MARKER, NAME_REGEX, NextResponse, ObjectInstance, PartialExecutionResult, ReplayableAsyncIterable, RunResponse, SendResponse, Snapshot, SnapshotSignal, StreamingMessageParser, SuccessExecutionResult, ThinkExit, ThinkSignal, Tool, _CustomModelClient, assertValidComponent, collectText, configureQuickJS, configureTokenizer, execute, generateInstructions, getValue, init, isAnyComponent, isComponent, normalizeComponentDefinition, normalizeComponentName, normalizePropsSchema, parseExit, parseStream, parseText, sanitizeMessageText, tryParseJson, utils, validateComponent, validateProps, version };
|