llmz 0.0.25 → 0.0.26
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/{chunk-FZJHYLM2.cjs → chunk-45GKLDDR.cjs} +2 -2
- package/dist/{chunk-LUX4X7XO.js → chunk-7G5QAIUX.js} +2 -2
- package/dist/{chunk-XGJOEQMW.cjs → chunk-A63TROZX.cjs} +2 -2
- package/dist/{chunk-A7QHWVD7.js → chunk-CARJB3HP.js} +1 -1
- package/dist/{chunk-2D2DE7CD.js → chunk-EDVD6GWH.js} +1 -1
- package/dist/chunk-KIN7Y247.cjs +32 -0
- package/dist/{chunk-BNDY7RGX.cjs → chunk-M3LCKL55.cjs} +20 -20
- package/dist/{chunk-JKVVQN2P.js → chunk-MYLTD5WT.js} +15 -2
- package/dist/{chunk-EE6NVDID.js → chunk-PBTEQAZK.js} +1 -1
- package/dist/{chunk-UGXCQIHB.cjs → chunk-PQILLTEM.cjs} +11 -11
- package/dist/{chunk-PIDLNYIP.cjs → chunk-Q2O6MYES.cjs} +4 -4
- package/dist/{chunk-DBRWIHIH.js → chunk-SHC22IAH.js} +3 -3
- package/dist/{chunk-JDABP4SD.cjs → chunk-T63Y6GTW.cjs} +17 -4
- package/dist/chunk-YEAWWJSJ.js +32 -0
- package/dist/context.d.ts +8 -8
- package/dist/{dual-modes-7FI4T35O.js → dual-modes-7FEESYXQ.js} +2 -2
- package/dist/{dual-modes-OFHV2C3X.cjs → dual-modes-F2HJJY2Z.cjs} +3 -3
- package/dist/errors.d.ts +3 -0
- package/dist/index.cjs +19 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/{llmz-M5AWNDMV.js → llmz-VGZUUM3U.js} +11 -10
- package/dist/{llmz-HRL52DC6.cjs → llmz-Z5ULKYGZ.cjs} +35 -34
- package/dist/llmz.d.ts +3 -3
- package/dist/result.d.ts +3 -3
- package/dist/tool-4J4JNDNV.cjs +11 -0
- package/dist/tool-SFRUHH7M.js +11 -0
- package/dist/typings-2WTRKHEH.cjs +10 -0
- package/dist/{typings-WYHEFCYB.js → typings-AYAZ5YA3.js} +3 -3
- package/dist/{vm-CYC5RLKU.js → vm-I4G4IH7T.js} +3 -3
- package/dist/vm-YJX6M4NJ.cjs +12 -0
- package/package.json +2 -2
- package/dist/chunk-IKSIOIIP.cjs +0 -28
- package/dist/chunk-JQBT7UWN.js +0 -28
- package/dist/tool-O4SFRIE4.cjs +0 -11
- package/dist/tool-PCOYOCRH.js +0 -11
- package/dist/typings-Y45GMPZT.cjs +0 -10
- package/dist/vm-PRZ5GEM2.cjs +0 -12
package/dist/index.cjs
CHANGED
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
require('./chunk-
|
|
11
|
+
var _chunkPQILLTEMcjs = require('./chunk-PQILLTEM.cjs');
|
|
12
|
+
require('./chunk-Q2O6MYES.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkA63TROZXcjs = require('./chunk-A63TROZX.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk45GKLDDRcjs = require('./chunk-45GKLDDR.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
var
|
|
26
|
-
require('./chunk-
|
|
25
|
+
var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
|
|
26
|
+
require('./chunk-KIN7Y247.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
|
|
@@ -296,12 +296,12 @@ async function hoistTypings(code, formatOptions) {
|
|
|
296
296
|
} catch (err) {
|
|
297
297
|
console.error(err);
|
|
298
298
|
if (formatOptions.throwOnError) {
|
|
299
|
-
throw new (0,
|
|
299
|
+
throw new (0, _chunkT63Y6GTWcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
|
|
300
300
|
}
|
|
301
301
|
break;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
return
|
|
304
|
+
return _chunk45GKLDDRcjs.formatTypings.call(void 0, code, formatOptions);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
// src/objects.ts
|
|
@@ -427,7 +427,7 @@ var ObjectInstance = class {
|
|
|
427
427
|
this.description = props.description;
|
|
428
428
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
429
429
|
this.properties = props.properties;
|
|
430
|
-
this.tools =
|
|
430
|
+
this.tools = _chunkA63TROZXcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
431
431
|
}
|
|
432
432
|
/**
|
|
433
433
|
* Generates TypeScript namespace declarations for this object.
|
|
@@ -508,7 +508,7 @@ function getObjectTypings(obj) {
|
|
|
508
508
|
}
|
|
509
509
|
let type = "unknown";
|
|
510
510
|
if (prop.type) {
|
|
511
|
-
type = await
|
|
511
|
+
type = await _chunk45GKLDDRcjs.getTypings.call(void 0, prop.type, {});
|
|
512
512
|
} else if (prop.value !== void 0) {
|
|
513
513
|
type = typeof prop.value;
|
|
514
514
|
}
|
|
@@ -528,7 +528,7 @@ function getObjectTypings(obj) {
|
|
|
528
528
|
typings.push("");
|
|
529
529
|
for (const tool of obj.tools) {
|
|
530
530
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
531
|
-
let temp = await
|
|
531
|
+
let temp = await _chunk45GKLDDRcjs.getTypings.call(void 0, fnType, {
|
|
532
532
|
declaration: true
|
|
533
533
|
});
|
|
534
534
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -551,7 +551,7 @@ function getObjectTypings(obj) {
|
|
|
551
551
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
552
552
|
header = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, obj.description);
|
|
553
553
|
}
|
|
554
|
-
return
|
|
554
|
+
return _chunk45GKLDDRcjs.formatTypings.call(void 0,
|
|
555
555
|
`${header}
|
|
556
556
|
export namespace ${obj.name} {
|
|
557
557
|
${body}
|
|
@@ -1103,20 +1103,20 @@ var utils = {
|
|
|
1103
1103
|
truncateWrappedContent: _chunkGZPN7RGHcjs.truncateWrappedContent
|
|
1104
1104
|
};
|
|
1105
1105
|
var execute = async (props) => {
|
|
1106
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1106
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-Z5ULKYGZ.cjs")));
|
|
1107
1107
|
return executeContext(props);
|
|
1108
1108
|
};
|
|
1109
1109
|
var init = async () => {
|
|
1110
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1110
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-Z5ULKYGZ.cjs")));
|
|
1111
1111
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
1112
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
1112
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-4J4JNDNV.cjs")));
|
|
1113
1113
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
|
|
1114
1114
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
1115
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-
|
|
1115
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-YJX6M4NJ.cjs")));
|
|
1116
1116
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-L5QAQXV2.cjs")));
|
|
1117
1117
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-W3NXBLYJ.cjs")));
|
|
1118
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
1119
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
1118
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-2WTRKHEH.cjs")));
|
|
1119
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-F2HJJY2Z.cjs")));
|
|
1120
1120
|
};
|
|
1121
1121
|
|
|
1122
1122
|
|
|
@@ -1145,4 +1145,4 @@ var init = async () => {
|
|
|
1145
1145
|
|
|
1146
1146
|
|
|
1147
1147
|
|
|
1148
|
-
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit =
|
|
1148
|
+
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkPQILLTEMcjs.DefaultExit; exports.ErrorExecutionResult = _chunkPQILLTEMcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkPQILLTEMcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkPQILLTEMcjs.ListenExit; exports.LoopExceededError = _chunkT63Y6GTWcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkPQILLTEMcjs.PartialExecutionResult; exports.Snapshot = _chunkPQILLTEMcjs.Snapshot; exports.SnapshotSignal = _chunkT63Y6GTWcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkPQILLTEMcjs.SuccessExecutionResult; exports.ThinkExit = _chunkPQILLTEMcjs.ThinkExit; exports.ThinkSignal = _chunkT63Y6GTWcjs.ThinkSignal; exports.Tool = _chunkA63TROZXcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkPQILLTEMcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare const utils: {
|
|
|
39
39
|
* @param props.exits - Array of Exit definitions for structured completion (static or dynamic)
|
|
40
40
|
* @param props.snapshot - Optional Snapshot to resume paused execution
|
|
41
41
|
* @param props.signal - Optional AbortSignal to cancel execution
|
|
42
|
-
* @param props.model - Optional model name (static or dynamic function)
|
|
42
|
+
* @param props.model - Optional model name (or array or models to use as fallback) (static or dynamic function)
|
|
43
43
|
* @param props.temperature - Optional temperature value (static or dynamic function)
|
|
44
44
|
* @param props.options - Optional execution options (loop limit, timeout)
|
|
45
45
|
* @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
|
package/dist/index.js
CHANGED
|
@@ -8,22 +8,22 @@ import {
|
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
10
|
getValue
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-SHC22IAH.js";
|
|
12
|
+
import "./chunk-EDVD6GWH.js";
|
|
13
13
|
import {
|
|
14
14
|
Tool
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CARJB3HP.js";
|
|
16
16
|
import {
|
|
17
17
|
formatTypings,
|
|
18
18
|
getTypings
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PBTEQAZK.js";
|
|
20
20
|
import {
|
|
21
21
|
CodeFormattingError,
|
|
22
22
|
LoopExceededError,
|
|
23
23
|
SnapshotSignal,
|
|
24
24
|
ThinkSignal
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-MYLTD5WT.js";
|
|
26
|
+
import "./chunk-YEAWWJSJ.js";
|
|
27
27
|
import {
|
|
28
28
|
Exit
|
|
29
29
|
} from "./chunk-VPTFUOIK.js";
|
|
@@ -1103,20 +1103,20 @@ var utils = {
|
|
|
1103
1103
|
truncateWrappedContent
|
|
1104
1104
|
};
|
|
1105
1105
|
var execute = async (props) => {
|
|
1106
|
-
const { executeContext } = await import("./llmz-
|
|
1106
|
+
const { executeContext } = await import("./llmz-VGZUUM3U.js");
|
|
1107
1107
|
return executeContext(props);
|
|
1108
1108
|
};
|
|
1109
1109
|
var init = async () => {
|
|
1110
|
-
await import("./llmz-
|
|
1110
|
+
await import("./llmz-VGZUUM3U.js");
|
|
1111
1111
|
await import("./component-WFVDVSDK.js");
|
|
1112
|
-
await import("./tool-
|
|
1112
|
+
await import("./tool-SFRUHH7M.js");
|
|
1113
1113
|
await import("./exit-YLO7BY7Z.js");
|
|
1114
1114
|
await import("./jsx-AEHVFB3L.js");
|
|
1115
|
-
await import("./vm-
|
|
1115
|
+
await import("./vm-I4G4IH7T.js");
|
|
1116
1116
|
await import("./utils-RQHQ2KOG.js");
|
|
1117
1117
|
await import("./truncator-BSP6PQPC.js");
|
|
1118
|
-
await import("./typings-
|
|
1119
|
-
await import("./dual-modes-
|
|
1118
|
+
await import("./typings-AYAZ5YA3.js");
|
|
1119
|
+
await import("./dual-modes-7FEESYXQ.js");
|
|
1120
1120
|
};
|
|
1121
1121
|
export {
|
|
1122
1122
|
Chat,
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runAsyncFunction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7G5QAIUX.js";
|
|
4
4
|
import {
|
|
5
5
|
Context,
|
|
6
6
|
ErrorExecutionResult,
|
|
7
7
|
PartialExecutionResult,
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-SHC22IAH.js";
|
|
11
|
+
import "./chunk-EDVD6GWH.js";
|
|
12
|
+
import "./chunk-CARJB3HP.js";
|
|
13
|
+
import "./chunk-PBTEQAZK.js";
|
|
14
14
|
import {
|
|
15
15
|
AssignmentError,
|
|
16
16
|
CodeExecutionError,
|
|
17
|
+
CognitiveError,
|
|
17
18
|
InvalidCodeError,
|
|
18
19
|
LoopExceededError,
|
|
19
20
|
Signals,
|
|
20
21
|
SnapshotSignal,
|
|
21
22
|
ThinkSignal,
|
|
22
23
|
VMSignal
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-MYLTD5WT.js";
|
|
24
25
|
import {
|
|
25
26
|
cleanStackTrace
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-YEAWWJSJ.js";
|
|
27
28
|
import "./chunk-VPTFUOIK.js";
|
|
28
29
|
import "./chunk-GGWM6X2K.js";
|
|
29
30
|
import "./chunk-ORQP26SZ.js";
|
|
@@ -207,8 +208,8 @@ var executeIteration = async ({
|
|
|
207
208
|
var _a, _b, _c, _d, _e;
|
|
208
209
|
let startedAt = Date.now();
|
|
209
210
|
const traces = iteration.traces;
|
|
210
|
-
const model = await cognitive.getModelDetails(iteration.model
|
|
211
|
-
const modelLimit = model.input.maxTokens;
|
|
211
|
+
const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
|
|
212
|
+
const modelLimit = Math.max(model.input.maxTokens, 8e3);
|
|
212
213
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
213
214
|
const messages = truncateWrappedContent({
|
|
214
215
|
messages: iteration.messages,
|
|
@@ -238,7 +239,7 @@ var executeIteration = async ({
|
|
|
238
239
|
});
|
|
239
240
|
const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
|
|
240
241
|
if (!out) {
|
|
241
|
-
throw new
|
|
242
|
+
throw new CognitiveError("LLM did not return any text output");
|
|
242
243
|
}
|
|
243
244
|
const assistantResponse = ctx.version.parseAssistantResponse(out);
|
|
244
245
|
iteration.code = assistantResponse.code.trim();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkM3LCKL55cjs = require('./chunk-M3LCKL55.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
10
|
+
var _chunkPQILLTEMcjs = require('./chunk-PQILLTEM.cjs');
|
|
11
|
+
require('./chunk-Q2O6MYES.cjs');
|
|
12
|
+
require('./chunk-A63TROZX.cjs');
|
|
13
|
+
require('./chunk-45GKLDDR.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -20,10 +20,11 @@ require('./chunk-FZJHYLM2.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
24
23
|
|
|
24
|
+
var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
27
28
|
require('./chunk-3G3BS5IA.cjs');
|
|
28
29
|
require('./chunk-ZRCU35UV.cjs');
|
|
29
30
|
require('./chunk-KMZDFWYZ.cjs');
|
|
@@ -105,7 +106,7 @@ var _executeContext = async (props) => {
|
|
|
105
106
|
const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
106
107
|
const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
|
|
107
108
|
const cleanups = [];
|
|
108
|
-
const ctx = new (0,
|
|
109
|
+
const ctx = new (0, _chunkPQILLTEMcjs.Context)({
|
|
109
110
|
chat: props.chat,
|
|
110
111
|
instructions: props.instructions,
|
|
111
112
|
objects: props.objects,
|
|
@@ -120,7 +121,7 @@ var _executeContext = async (props) => {
|
|
|
120
121
|
try {
|
|
121
122
|
while (true) {
|
|
122
123
|
if (ctx.iterations.length >= ctx.loop) {
|
|
123
|
-
return new (0,
|
|
124
|
+
return new (0, _chunkPQILLTEMcjs.ErrorExecutionResult)(ctx, new (0, _chunkT63Y6GTWcjs.LoopExceededError)());
|
|
124
125
|
}
|
|
125
126
|
const iteration = await ctx.nextIteration();
|
|
126
127
|
if (controller.signal.aborted) {
|
|
@@ -130,7 +131,7 @@ var _executeContext = async (props) => {
|
|
|
130
131
|
reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
|
-
return new (0,
|
|
134
|
+
return new (0, _chunkPQILLTEMcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
134
135
|
}
|
|
135
136
|
cleanups.push(
|
|
136
137
|
iteration.traces.onPush((traces) => {
|
|
@@ -155,7 +156,7 @@ var _executeContext = async (props) => {
|
|
|
155
156
|
type: "execution_error",
|
|
156
157
|
execution_error: {
|
|
157
158
|
message: "An unexpected error occurred: " + getErrorMessage(err),
|
|
158
|
-
stack:
|
|
159
|
+
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
|
|
159
160
|
}
|
|
160
161
|
});
|
|
161
162
|
}
|
|
@@ -166,25 +167,25 @@ var _executeContext = async (props) => {
|
|
|
166
167
|
}
|
|
167
168
|
if (iteration.status.type === "exit_success") {
|
|
168
169
|
const exitName = iteration.status.exit_success.exit_name;
|
|
169
|
-
return new (0,
|
|
170
|
+
return new (0, _chunkPQILLTEMcjs.SuccessExecutionResult)(ctx, {
|
|
170
171
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
171
172
|
result: iteration.status.exit_success.return_value
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
if (iteration.status.type === "callback_requested") {
|
|
175
|
-
return new (0,
|
|
176
|
+
return new (0, _chunkPQILLTEMcjs.PartialExecutionResult)(
|
|
176
177
|
ctx,
|
|
177
178
|
iteration.status.callback_requested.signal,
|
|
178
|
-
|
|
179
|
+
_chunkPQILLTEMcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
179
180
|
);
|
|
180
181
|
}
|
|
181
182
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
182
183
|
continue;
|
|
183
184
|
}
|
|
184
|
-
return new (0,
|
|
185
|
+
return new (0, _chunkPQILLTEMcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
|
|
185
186
|
}
|
|
186
187
|
} catch (error) {
|
|
187
|
-
return new (0,
|
|
188
|
+
return new (0, _chunkPQILLTEMcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
188
189
|
} finally {
|
|
189
190
|
for (const cleanup of cleanups) {
|
|
190
191
|
try {
|
|
@@ -207,8 +208,8 @@ var executeIteration = async ({
|
|
|
207
208
|
var _a, _b, _c, _d, _e;
|
|
208
209
|
let startedAt = Date.now();
|
|
209
210
|
const traces = iteration.traces;
|
|
210
|
-
const model = await cognitive.getModelDetails(
|
|
211
|
-
const modelLimit = model.input.maxTokens;
|
|
211
|
+
const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
|
|
212
|
+
const modelLimit = Math.max(model.input.maxTokens, 8e3);
|
|
212
213
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
213
214
|
const messages = _chunkGZPN7RGHcjs.truncateWrappedContent.call(void 0, {
|
|
214
215
|
messages: iteration.messages,
|
|
@@ -238,7 +239,7 @@ var executeIteration = async ({
|
|
|
238
239
|
});
|
|
239
240
|
const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
|
|
240
241
|
if (!out) {
|
|
241
|
-
throw new
|
|
242
|
+
throw new (0, _chunkT63Y6GTWcjs.CognitiveError)("LLM did not return any text output");
|
|
242
243
|
}
|
|
243
244
|
const assistantResponse = ctx.version.parseAssistantResponse(out);
|
|
244
245
|
iteration.code = assistantResponse.code.trim();
|
|
@@ -249,7 +250,7 @@ var executeIteration = async ({
|
|
|
249
250
|
iteration.code = hookRes.code.trim();
|
|
250
251
|
}
|
|
251
252
|
} catch (err) {
|
|
252
|
-
if (err instanceof
|
|
253
|
+
if (err instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
|
|
253
254
|
return iteration.end({
|
|
254
255
|
type: "thinking_requested",
|
|
255
256
|
thinking_requested: {
|
|
@@ -262,7 +263,7 @@ var executeIteration = async ({
|
|
|
262
263
|
type: "execution_error",
|
|
263
264
|
execution_error: {
|
|
264
265
|
message: `Error in onBeforeExecution hook: ${getErrorMessage(err)}`,
|
|
265
|
-
stack:
|
|
266
|
+
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
|
|
266
267
|
}
|
|
267
268
|
});
|
|
268
269
|
}
|
|
@@ -303,14 +304,14 @@ var executeIteration = async ({
|
|
|
303
304
|
return;
|
|
304
305
|
}
|
|
305
306
|
if (!writable) {
|
|
306
|
-
throw new (0,
|
|
307
|
+
throw new (0, _chunkT63Y6GTWcjs.AssignmentError)(`Property ${obj.name}.${name} is read-only and cannot be modified`);
|
|
307
308
|
}
|
|
308
309
|
if (value2 === internalValues[name]) {
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
311
312
|
const parsed = schema.safeParse(value2);
|
|
312
313
|
if (!parsed.success) {
|
|
313
|
-
throw new (0,
|
|
314
|
+
throw new (0, _chunkT63Y6GTWcjs.AssignmentError)(
|
|
314
315
|
`Invalid value for Object property ${obj.name}.${name}: ${getErrorMessage(parsed.error)}`
|
|
315
316
|
);
|
|
316
317
|
}
|
|
@@ -361,7 +362,7 @@ var executeIteration = async ({
|
|
|
361
362
|
});
|
|
362
363
|
}
|
|
363
364
|
startedAt = Date.now();
|
|
364
|
-
const result = await
|
|
365
|
+
const result = await _chunkM3LCKL55cjs.runAsyncFunction.call(void 0,
|
|
365
366
|
vmContext,
|
|
366
367
|
iteration.code,
|
|
367
368
|
traces,
|
|
@@ -376,7 +377,7 @@ var executeIteration = async ({
|
|
|
376
377
|
variables: {}
|
|
377
378
|
};
|
|
378
379
|
});
|
|
379
|
-
if (result.error && result.error instanceof
|
|
380
|
+
if (result.error && result.error instanceof _chunkT63Y6GTWcjs.InvalidCodeError) {
|
|
380
381
|
return iteration.end({
|
|
381
382
|
type: "invalid_code_error",
|
|
382
383
|
invalid_code_error: {
|
|
@@ -390,12 +391,12 @@ var executeIteration = async ({
|
|
|
390
391
|
started_at: startedAt,
|
|
391
392
|
ended_at: Date.now()
|
|
392
393
|
});
|
|
393
|
-
if (result.error && result.error instanceof
|
|
394
|
+
if (result.error && result.error instanceof _chunkT63Y6GTWcjs.CodeExecutionError) {
|
|
394
395
|
return iteration.end({
|
|
395
396
|
type: "execution_error",
|
|
396
397
|
execution_error: {
|
|
397
398
|
message: result.error.message,
|
|
398
|
-
stack:
|
|
399
|
+
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(_nullishCoalesce(result.error.stacktrace, () => ( result.error.stack)), () => ( "No stack trace available")))
|
|
399
400
|
}
|
|
400
401
|
});
|
|
401
402
|
}
|
|
@@ -412,11 +413,11 @@ var executeIteration = async ({
|
|
|
412
413
|
type: "execution_error",
|
|
413
414
|
execution_error: {
|
|
414
415
|
message: _nullishCoalesce(((_e = result == null ? void 0 : result.error) == null ? void 0 : _e.message), () => ( "Unknown error occurred")),
|
|
415
|
-
stack:
|
|
416
|
+
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(result.error.stack, () => ( "No stack trace available")))
|
|
416
417
|
}
|
|
417
418
|
});
|
|
418
419
|
}
|
|
419
|
-
if (result.signal instanceof
|
|
420
|
+
if (result.signal instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
|
|
420
421
|
return iteration.end({
|
|
421
422
|
type: "thinking_requested",
|
|
422
423
|
thinking_requested: {
|
|
@@ -425,7 +426,7 @@ var executeIteration = async ({
|
|
|
425
426
|
}
|
|
426
427
|
});
|
|
427
428
|
}
|
|
428
|
-
if (result.signal instanceof
|
|
429
|
+
if (result.signal instanceof _chunkT63Y6GTWcjs.SnapshotSignal) {
|
|
429
430
|
return iteration.end({
|
|
430
431
|
type: "callback_requested",
|
|
431
432
|
callback_requested: {
|
|
@@ -538,16 +539,16 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
538
539
|
if (output === error2) {
|
|
539
540
|
return true;
|
|
540
541
|
}
|
|
541
|
-
if (error2 instanceof
|
|
542
|
+
if (error2 instanceof _chunkT63Y6GTWcjs.SnapshotSignal) {
|
|
542
543
|
error2.toolCall = {
|
|
543
544
|
name: tool.name,
|
|
544
545
|
inputSchema: tool.input,
|
|
545
546
|
outputSchema: tool.output,
|
|
546
547
|
input
|
|
547
548
|
};
|
|
548
|
-
error2.message =
|
|
549
|
+
error2.message = _chunkT63Y6GTWcjs.Signals.serializeError(error2);
|
|
549
550
|
}
|
|
550
|
-
if (error2 instanceof
|
|
551
|
+
if (error2 instanceof _chunkT63Y6GTWcjs.ThinkSignal) {
|
|
551
552
|
traces.push({
|
|
552
553
|
type: "think_signal",
|
|
553
554
|
started_at: Date.now(),
|
|
@@ -638,7 +639,7 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
638
639
|
if (!success) {
|
|
639
640
|
throw error;
|
|
640
641
|
}
|
|
641
|
-
if (output instanceof
|
|
642
|
+
if (output instanceof _chunkT63Y6GTWcjs.VMSignal) {
|
|
642
643
|
throw output;
|
|
643
644
|
}
|
|
644
645
|
return output;
|
package/dist/llmz.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Cognitive, type BotpressClientLike } from '@botpress/cognitive';
|
|
1
|
+
import { Cognitive, Models, type BotpressClientLike } from '@botpress/cognitive';
|
|
2
2
|
import { Chat } from './chat.js';
|
|
3
|
-
import { Context, Iteration
|
|
3
|
+
import { Context, Iteration } from './context.js';
|
|
4
4
|
import { Exit, ExitResult } from './exit.js';
|
|
5
5
|
import { ValueOrGetter } from './getter.js';
|
|
6
6
|
import { type ObjectInstance } from './objects.js';
|
|
@@ -175,7 +175,7 @@ export type ExecutionProps = {
|
|
|
175
175
|
* The model to use for the LLM.
|
|
176
176
|
* This can be a static model name or a function that returns a model name based on the current context.
|
|
177
177
|
*/
|
|
178
|
-
model?: ValueOrGetter<
|
|
178
|
+
model?: ValueOrGetter<Models | Models[], Context>;
|
|
179
179
|
/**
|
|
180
180
|
* The temperature to use for the LLM.
|
|
181
181
|
* This can be a static temperature or a function that returns a temperature based on the current context.
|
package/dist/result.d.ts
CHANGED
|
@@ -388,7 +388,7 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
|
|
|
388
388
|
id: string;
|
|
389
389
|
messages: import("./index.js").LLMzPrompts.Message[];
|
|
390
390
|
code: string | undefined;
|
|
391
|
-
model: import("
|
|
391
|
+
model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
|
|
392
392
|
temperature: number;
|
|
393
393
|
traces: import("./types.js").Traces.Trace[];
|
|
394
394
|
variables: Record<string, any>;
|
|
@@ -543,7 +543,7 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
|
|
|
543
543
|
id: string;
|
|
544
544
|
messages: import("./index.js").LLMzPrompts.Message[];
|
|
545
545
|
code: string | undefined;
|
|
546
|
-
model: import("
|
|
546
|
+
model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
|
|
547
547
|
temperature: number;
|
|
548
548
|
traces: import("./types.js").Traces.Trace[];
|
|
549
549
|
variables: Record<string, any>;
|
|
@@ -718,7 +718,7 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
|
|
|
718
718
|
id: string;
|
|
719
719
|
messages: import("./index.js").LLMzPrompts.Message[];
|
|
720
720
|
code: string | undefined;
|
|
721
|
-
model: import("
|
|
721
|
+
model: import("@botpress/cognitive").Models | import("@botpress/cognitive").Models[];
|
|
722
722
|
temperature: number;
|
|
723
723
|
traces: import("./types.js").Traces.Trace[];
|
|
724
724
|
variables: Record<string, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkA63TROZXcjs = require('./chunk-A63TROZX.cjs');
|
|
4
|
+
require('./chunk-45GKLDDR.cjs');
|
|
5
|
+
require('./chunk-T63Y6GTW.cjs');
|
|
6
|
+
require('./chunk-KIN7Y247.cjs');
|
|
7
|
+
require('./chunk-WHNOR4ZU.cjs');
|
|
8
|
+
require('./chunk-UQOBUJIQ.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.Tool = _chunkA63TROZXcjs.Tool;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk45GKLDDRcjs = require('./chunk-45GKLDDR.cjs');
|
|
4
|
+
require('./chunk-T63Y6GTW.cjs');
|
|
5
|
+
require('./chunk-KIN7Y247.cjs');
|
|
6
|
+
require('./chunk-WHNOR4ZU.cjs');
|
|
7
|
+
require('./chunk-UQOBUJIQ.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.getTypings = _chunk45GKLDDRcjs.getTypings;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-PBTEQAZK.js";
|
|
4
|
+
import "./chunk-MYLTD5WT.js";
|
|
5
|
+
import "./chunk-YEAWWJSJ.js";
|
|
6
6
|
import "./chunk-ZORRILUV.js";
|
|
7
7
|
import "./chunk-7WRN4E42.js";
|
|
8
8
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CAN_USE_ISOLATED_VM,
|
|
3
3
|
runAsyncFunction
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-7G5QAIUX.js";
|
|
5
|
+
import "./chunk-MYLTD5WT.js";
|
|
6
|
+
import "./chunk-YEAWWJSJ.js";
|
|
7
7
|
import "./chunk-ORQP26SZ.js";
|
|
8
8
|
import "./chunk-7WRN4E42.js";
|
|
9
9
|
export {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkM3LCKL55cjs = require('./chunk-M3LCKL55.cjs');
|
|
5
|
+
require('./chunk-T63Y6GTW.cjs');
|
|
6
|
+
require('./chunk-KIN7Y247.cjs');
|
|
7
|
+
require('./chunk-KMZDFWYZ.cjs');
|
|
8
|
+
require('./chunk-UQOBUJIQ.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.CAN_USE_ISOLATED_VM = _chunkM3LCKL55cjs.CAN_USE_ISOLATED_VM; exports.runAsyncFunction = _chunkM3LCKL55cjs.runAsyncFunction;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "llmz",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "LLMz – An LLM-native Typescript VM built on top of Zui",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.26",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@botpress/client": "^1.25.0",
|
|
70
|
-
"@botpress/cognitive": "^0.1.
|
|
70
|
+
"@botpress/cognitive": "^0.1.45",
|
|
71
71
|
"@bpinternal/thicktoken": "^1.0.5",
|
|
72
72
|
"@bpinternal/zui": "^1.0.1"
|
|
73
73
|
},
|
package/dist/chunk-IKSIOIIP.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/stack-traces.ts
|
|
2
|
-
var isInternalLine = (line) => {
|
|
3
|
-
return line.includes("/llmz/") || line.includes("\\llmz\\src\\") || line.includes("node_modules");
|
|
4
|
-
};
|
|
5
|
-
function cleanStackTrace(stack, cleanInternal = true) {
|
|
6
|
-
const lines = stack.split("\n");
|
|
7
|
-
for (let i = 0; i < lines.length; i++) {
|
|
8
|
-
const line = lines[i];
|
|
9
|
-
let llmzIndex = line.indexOf("/llmz/");
|
|
10
|
-
if (llmzIndex === -1) {
|
|
11
|
-
llmzIndex = line.indexOf("\\llmz\\");
|
|
12
|
-
}
|
|
13
|
-
if (llmzIndex === -1) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
let lastSpaceIndex = line.lastIndexOf(" ", llmzIndex);
|
|
17
|
-
if (lastSpaceIndex === -1) {
|
|
18
|
-
lastSpaceIndex = 0;
|
|
19
|
-
}
|
|
20
|
-
const maybeParen = line[lastSpaceIndex + 1] === "(" ? "(" : "";
|
|
21
|
-
lines[i] = line.slice(0, lastSpaceIndex + 1) + maybeParen + line.slice(llmzIndex);
|
|
22
|
-
}
|
|
23
|
-
return lines.filter((x) => !cleanInternal || !isInternalLine(x)).join("\n");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.cleanStackTrace = cleanStackTrace;
|