llmz 0.0.23 → 0.0.25
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-QIZBF7A5.js → chunk-DBRWIHIH.js} +22 -9
- package/dist/{chunk-2NU62OI4.cjs → chunk-UGXCQIHB.cjs} +22 -9
- package/dist/context.d.ts +15 -11
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -3
- package/dist/{llmz-UUZTBIF3.cjs → llmz-HRL52DC6.cjs} +16 -16
- package/dist/{llmz-IUGXC4SH.js → llmz-M5AWNDMV.js} +8 -8
- package/dist/llmz.d.ts +15 -2
- package/dist/result.d.ts +6 -6
- package/package.json +7 -4
|
@@ -684,6 +684,12 @@ var Iteration = class {
|
|
|
684
684
|
get objects() {
|
|
685
685
|
return this._parameters.objects;
|
|
686
686
|
}
|
|
687
|
+
get model() {
|
|
688
|
+
return this._parameters.model;
|
|
689
|
+
}
|
|
690
|
+
get temperature() {
|
|
691
|
+
return this._parameters.temperature;
|
|
692
|
+
}
|
|
687
693
|
get exits() {
|
|
688
694
|
const exits = [...this._parameters.exits, ThinkExit];
|
|
689
695
|
if (this.isChatEnabled) {
|
|
@@ -763,6 +769,8 @@ var Iteration = class {
|
|
|
763
769
|
id: this.id,
|
|
764
770
|
messages: [...this.messages],
|
|
765
771
|
code: this.code,
|
|
772
|
+
model: this.model,
|
|
773
|
+
temperature: this.temperature,
|
|
766
774
|
traces: [...this.traces],
|
|
767
775
|
variables: this.variables,
|
|
768
776
|
started_ts: this.started_ts,
|
|
@@ -788,12 +796,12 @@ var Context = class {
|
|
|
788
796
|
objects;
|
|
789
797
|
tools;
|
|
790
798
|
exits;
|
|
799
|
+
model;
|
|
800
|
+
temperature;
|
|
791
801
|
version = DualModePrompt;
|
|
792
802
|
timeout = 6e4;
|
|
793
803
|
// Default timeout of 60 seconds
|
|
794
804
|
loop;
|
|
795
|
-
temperature;
|
|
796
|
-
model;
|
|
797
805
|
metadata;
|
|
798
806
|
snapshot;
|
|
799
807
|
iteration = 0;
|
|
@@ -962,6 +970,8 @@ var Context = class {
|
|
|
962
970
|
const objects = await getValue(this.objects, this) ?? [];
|
|
963
971
|
const exits = await getValue(this.exits, this) ?? [];
|
|
964
972
|
const components = await getValue(((_b = this.chat) == null ? void 0 : _b.components) ?? [], this);
|
|
973
|
+
const model = await getValue(this.model, this) ?? "best";
|
|
974
|
+
const temperature = await getValue(this.temperature, this);
|
|
965
975
|
if (objects && objects.length > 100) {
|
|
966
976
|
throw new Error("Too many objects. Expected at most 100 objects.");
|
|
967
977
|
}
|
|
@@ -1041,13 +1051,21 @@ var Context = class {
|
|
|
1041
1051
|
if (!components.length && !exits.length) {
|
|
1042
1052
|
exits.push(DefaultExit);
|
|
1043
1053
|
}
|
|
1054
|
+
if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
|
|
1055
|
+
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1056
|
+
}
|
|
1057
|
+
if (typeof model !== "string" || model.length === 0) {
|
|
1058
|
+
throw new Error("Invalid model. Expected a non-empty string.");
|
|
1059
|
+
}
|
|
1044
1060
|
return {
|
|
1045
1061
|
transcript,
|
|
1046
1062
|
tools: allTools,
|
|
1047
1063
|
objects,
|
|
1048
1064
|
exits,
|
|
1049
1065
|
instructions,
|
|
1050
|
-
components
|
|
1066
|
+
components,
|
|
1067
|
+
model,
|
|
1068
|
+
temperature
|
|
1051
1069
|
};
|
|
1052
1070
|
}
|
|
1053
1071
|
constructor(props) {
|
|
@@ -1060,16 +1078,13 @@ var Context = class {
|
|
|
1060
1078
|
this.timeout = Math.min(999999999, Math.max(0, props.timeout ?? 6e4));
|
|
1061
1079
|
this.loop = props.loop ?? 3;
|
|
1062
1080
|
this.temperature = props.temperature ?? 0.7;
|
|
1063
|
-
this.model = props.model;
|
|
1081
|
+
this.model = props.model ?? "best";
|
|
1064
1082
|
this.iterations = [];
|
|
1065
1083
|
this.metadata = props.metadata ?? {};
|
|
1066
1084
|
this.snapshot = props.snapshot;
|
|
1067
1085
|
if (this.loop < 1 || this.loop > 100) {
|
|
1068
1086
|
throw new Error("Invalid loop. Expected a number between 1 and 100.");
|
|
1069
1087
|
}
|
|
1070
|
-
if (this.temperature < 0 || this.temperature > 2) {
|
|
1071
|
-
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1072
|
-
}
|
|
1073
1088
|
}
|
|
1074
1089
|
toJSON() {
|
|
1075
1090
|
var _a;
|
|
@@ -1079,8 +1094,6 @@ var Context = class {
|
|
|
1079
1094
|
iteration: this.iteration,
|
|
1080
1095
|
timeout: this.timeout,
|
|
1081
1096
|
loop: this.loop,
|
|
1082
|
-
temperature: this.temperature,
|
|
1083
|
-
model: this.model,
|
|
1084
1097
|
metadata: this.metadata,
|
|
1085
1098
|
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
1099
|
};
|
|
@@ -684,6 +684,12 @@ var Iteration = class {
|
|
|
684
684
|
get objects() {
|
|
685
685
|
return this._parameters.objects;
|
|
686
686
|
}
|
|
687
|
+
get model() {
|
|
688
|
+
return this._parameters.model;
|
|
689
|
+
}
|
|
690
|
+
get temperature() {
|
|
691
|
+
return this._parameters.temperature;
|
|
692
|
+
}
|
|
687
693
|
get exits() {
|
|
688
694
|
const exits = [...this._parameters.exits, ThinkExit];
|
|
689
695
|
if (this.isChatEnabled) {
|
|
@@ -763,6 +769,8 @@ var Iteration = class {
|
|
|
763
769
|
id: this.id,
|
|
764
770
|
messages: [...this.messages],
|
|
765
771
|
code: this.code,
|
|
772
|
+
model: this.model,
|
|
773
|
+
temperature: this.temperature,
|
|
766
774
|
traces: [...this.traces],
|
|
767
775
|
variables: this.variables,
|
|
768
776
|
started_ts: this.started_ts,
|
|
@@ -788,14 +796,14 @@ var Context = (_class2 = class {
|
|
|
788
796
|
|
|
789
797
|
|
|
790
798
|
|
|
799
|
+
|
|
800
|
+
|
|
791
801
|
__init3() {this.version = _chunkPIDLNYIPcjs.DualModePrompt}
|
|
792
802
|
__init4() {this.timeout = 6e4}
|
|
793
803
|
// Default timeout of 60 seconds
|
|
794
804
|
|
|
795
805
|
|
|
796
806
|
|
|
797
|
-
|
|
798
|
-
|
|
799
807
|
__init5() {this.iteration = 0}
|
|
800
808
|
|
|
801
809
|
async nextIteration() {
|
|
@@ -962,6 +970,8 @@ var Context = (_class2 = class {
|
|
|
962
970
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
963
971
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
964
972
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|
|
973
|
+
const model = await _asyncNullishCoalesce(await getValue(this.model, this), async () => ( "best"));
|
|
974
|
+
const temperature = await getValue(this.temperature, this);
|
|
965
975
|
if (objects && objects.length > 100) {
|
|
966
976
|
throw new Error("Too many objects. Expected at most 100 objects.");
|
|
967
977
|
}
|
|
@@ -1041,13 +1051,21 @@ var Context = (_class2 = class {
|
|
|
1041
1051
|
if (!components.length && !exits.length) {
|
|
1042
1052
|
exits.push(DefaultExit);
|
|
1043
1053
|
}
|
|
1054
|
+
if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
|
|
1055
|
+
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1056
|
+
}
|
|
1057
|
+
if (typeof model !== "string" || model.length === 0) {
|
|
1058
|
+
throw new Error("Invalid model. Expected a non-empty string.");
|
|
1059
|
+
}
|
|
1044
1060
|
return {
|
|
1045
1061
|
transcript,
|
|
1046
1062
|
tools: allTools,
|
|
1047
1063
|
objects,
|
|
1048
1064
|
exits,
|
|
1049
1065
|
instructions,
|
|
1050
|
-
components
|
|
1066
|
+
components,
|
|
1067
|
+
model,
|
|
1068
|
+
temperature
|
|
1051
1069
|
};
|
|
1052
1070
|
}
|
|
1053
1071
|
constructor(props) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
|
@@ -1060,16 +1078,13 @@ var Context = (_class2 = class {
|
|
|
1060
1078
|
this.timeout = Math.min(999999999, Math.max(0, _nullishCoalesce(props.timeout, () => ( 6e4))));
|
|
1061
1079
|
this.loop = _nullishCoalesce(props.loop, () => ( 3));
|
|
1062
1080
|
this.temperature = _nullishCoalesce(props.temperature, () => ( 0.7));
|
|
1063
|
-
this.model = props.model;
|
|
1081
|
+
this.model = _nullishCoalesce(props.model, () => ( "best"));
|
|
1064
1082
|
this.iterations = [];
|
|
1065
1083
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
1066
1084
|
this.snapshot = props.snapshot;
|
|
1067
1085
|
if (this.loop < 1 || this.loop > 100) {
|
|
1068
1086
|
throw new Error("Invalid loop. Expected a number between 1 and 100.");
|
|
1069
1087
|
}
|
|
1070
|
-
if (this.temperature < 0 || this.temperature > 2) {
|
|
1071
|
-
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1072
|
-
}
|
|
1073
1088
|
}
|
|
1074
1089
|
toJSON() {
|
|
1075
1090
|
var _a;
|
|
@@ -1079,8 +1094,6 @@ var Context = (_class2 = class {
|
|
|
1079
1094
|
iteration: this.iteration,
|
|
1080
1095
|
timeout: this.timeout,
|
|
1081
1096
|
loop: this.loop,
|
|
1082
|
-
temperature: this.temperature,
|
|
1083
|
-
model: this.model,
|
|
1084
1097
|
metadata: this.metadata,
|
|
1085
1098
|
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
1099
|
};
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Cognitive } from '@botpress/cognitive';
|
|
2
1
|
import { Chat } from './chat.js';
|
|
3
2
|
import { Component } from './component.js';
|
|
4
3
|
import { SnapshotSignal } from './errors.js';
|
|
@@ -11,7 +10,7 @@ import { Snapshot } from './snapshots.js';
|
|
|
11
10
|
import { Tool } from './tool.js';
|
|
12
11
|
import { Transcript, TranscriptArray } from './transcript.js';
|
|
13
12
|
import { ObjectMutation, Serializable, Trace } from './types.js';
|
|
14
|
-
type Model =
|
|
13
|
+
export type Model = 'best' | 'fast' | `${string}:${string}` | (string & {});
|
|
15
14
|
export type IterationParameters = {
|
|
16
15
|
transcript: TranscriptArray;
|
|
17
16
|
tools: Tool[];
|
|
@@ -19,6 +18,8 @@ export type IterationParameters = {
|
|
|
19
18
|
exits: Exit[];
|
|
20
19
|
instructions?: string;
|
|
21
20
|
components: Component[];
|
|
21
|
+
model: Model;
|
|
22
|
+
temperature: number;
|
|
22
23
|
};
|
|
23
24
|
export type IterationStatus = IterationStatuses.Pending | IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.Thinking | IterationStatuses.Callback | IterationStatuses.ExitSuccess | IterationStatuses.ExitError | IterationStatuses.Aborted;
|
|
24
25
|
export declare namespace IterationStatuses {
|
|
@@ -306,6 +307,8 @@ export declare namespace Iteration {
|
|
|
306
307
|
messages: LLMzPrompts.Message[];
|
|
307
308
|
code?: string;
|
|
308
309
|
traces: Trace[];
|
|
310
|
+
model: Model;
|
|
311
|
+
temperature: number;
|
|
309
312
|
variables: Record<string, any>;
|
|
310
313
|
started_ts: number;
|
|
311
314
|
ended_ts?: number;
|
|
@@ -347,6 +350,8 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
347
350
|
get transcript(): TranscriptArray;
|
|
348
351
|
get tools(): Tool<import("./types.js").ZuiType, import("./types.js").ZuiType>[];
|
|
349
352
|
get objects(): ObjectInstance[];
|
|
353
|
+
get model(): Model;
|
|
354
|
+
get temperature(): number;
|
|
350
355
|
get exits(): Exit<unknown>[];
|
|
351
356
|
get instructions(): string | undefined;
|
|
352
357
|
llm?: {
|
|
@@ -385,6 +390,8 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
385
390
|
id: string;
|
|
386
391
|
messages: LLMzPrompts.Message[];
|
|
387
392
|
code: string | undefined;
|
|
393
|
+
model: Model;
|
|
394
|
+
temperature: number;
|
|
388
395
|
traces: import("./types.js").Traces.Trace[];
|
|
389
396
|
variables: Record<string, any>;
|
|
390
397
|
started_ts: number;
|
|
@@ -450,8 +457,6 @@ export declare namespace Context {
|
|
|
450
457
|
iteration: number;
|
|
451
458
|
timeout: number;
|
|
452
459
|
loop: number;
|
|
453
|
-
temperature: number;
|
|
454
|
-
model?: Model;
|
|
455
460
|
metadata: Record<string, any>;
|
|
456
461
|
snapshot?: Snapshot.JSON;
|
|
457
462
|
};
|
|
@@ -463,11 +468,11 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
463
468
|
objects?: ValueOrGetter<ObjectInstance[], Context>;
|
|
464
469
|
tools?: ValueOrGetter<Tool[], Context>;
|
|
465
470
|
exits?: ValueOrGetter<Exit[], Context>;
|
|
471
|
+
model?: ValueOrGetter<Model, Context>;
|
|
472
|
+
temperature: ValueOrGetter<number, Context>;
|
|
466
473
|
version: Prompt;
|
|
467
474
|
timeout: number;
|
|
468
475
|
loop: number;
|
|
469
|
-
temperature: number;
|
|
470
|
-
model?: Model;
|
|
471
476
|
metadata: Record<string, any>;
|
|
472
477
|
snapshot?: Snapshot;
|
|
473
478
|
iteration: number;
|
|
@@ -483,8 +488,8 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
483
488
|
tools?: ValueOrGetter<Tool[], Context>;
|
|
484
489
|
exits?: ValueOrGetter<Exit[], Context>;
|
|
485
490
|
loop?: number;
|
|
486
|
-
temperature?: number
|
|
487
|
-
model?: Model
|
|
491
|
+
temperature?: ValueOrGetter<number, Context>;
|
|
492
|
+
model?: ValueOrGetter<Model, Context>;
|
|
488
493
|
metadata?: Record<string, any>;
|
|
489
494
|
snapshot?: Snapshot;
|
|
490
495
|
timeout?: number;
|
|
@@ -495,6 +500,8 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
495
500
|
id: string;
|
|
496
501
|
messages: LLMzPrompts.Message[];
|
|
497
502
|
code: string | undefined;
|
|
503
|
+
model: Model;
|
|
504
|
+
temperature: number;
|
|
498
505
|
traces: import("./types.js").Traces.Trace[];
|
|
499
506
|
variables: Record<string, any>;
|
|
500
507
|
started_ts: number;
|
|
@@ -555,8 +562,6 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
555
562
|
iteration: number;
|
|
556
563
|
timeout: number;
|
|
557
564
|
loop: number;
|
|
558
|
-
temperature: number;
|
|
559
|
-
model: "best" | "fast" | `${string}:${string}` | undefined;
|
|
560
565
|
metadata: Record<string, any>;
|
|
561
566
|
snapshot: {
|
|
562
567
|
id: string;
|
|
@@ -581,4 +586,3 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
581
586
|
} | undefined;
|
|
582
587
|
};
|
|
583
588
|
}
|
|
584
|
-
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkUGXCQIHBcjs = require('./chunk-UGXCQIHB.cjs');
|
|
12
12
|
require('./chunk-PIDLNYIP.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
@@ -1103,11 +1103,11 @@ 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-HRL52DC6.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-HRL52DC6.cjs")));
|
|
1111
1111
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
1112
1112
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-O4SFRIE4.cjs")));
|
|
1113
1113
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
|
|
@@ -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 = _chunkUGXCQIHBcjs.DefaultExit; exports.ErrorExecutionResult = _chunkUGXCQIHBcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkUGXCQIHBcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkUGXCQIHBcjs.ListenExit; exports.LoopExceededError = _chunkJDABP4SDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkUGXCQIHBcjs.PartialExecutionResult; exports.Snapshot = _chunkUGXCQIHBcjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkUGXCQIHBcjs.SuccessExecutionResult; exports.ThinkExit = _chunkUGXCQIHBcjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunkXGJOEQMWcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkUGXCQIHBcjs.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,9 @@ 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.
|
|
42
|
+
* @param props.model - Optional model name (static or dynamic function)
|
|
43
|
+
* @param props.temperature - Optional temperature value (static or dynamic function)
|
|
44
|
+
* @param props.options - Optional execution options (loop limit, timeout)
|
|
43
45
|
* @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
|
|
44
46
|
* @param props.onIterationEnd - Optional blocking hook called after each iteration
|
|
45
47
|
* @param props.onExit - Optional blocking hook called when an exit is reached (can prevent exit)
|
|
@@ -80,7 +82,9 @@ export declare const utils: {
|
|
|
80
82
|
* client: cognitiveClient,
|
|
81
83
|
* instructions: (ctx) => `Process ${ctx.variables.dataCount} records`,
|
|
82
84
|
* tools: async (ctx) => await getContextualTools(ctx),
|
|
83
|
-
*
|
|
85
|
+
* model: 'best',
|
|
86
|
+
* temperature: 0.1,
|
|
87
|
+
* options: { loop: 10 },
|
|
84
88
|
* onTrace: ({ trace, iteration }) => console.log(trace),
|
|
85
89
|
* onExit: async (result) => await validateResult(result)
|
|
86
90
|
* })
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
10
|
getValue
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DBRWIHIH.js";
|
|
12
12
|
import "./chunk-2D2DE7CD.js";
|
|
13
13
|
import {
|
|
14
14
|
Tool
|
|
@@ -1103,11 +1103,11 @@ 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-M5AWNDMV.js");
|
|
1107
1107
|
return executeContext(props);
|
|
1108
1108
|
};
|
|
1109
1109
|
var init = async () => {
|
|
1110
|
-
await import("./llmz-
|
|
1110
|
+
await import("./llmz-M5AWNDMV.js");
|
|
1111
1111
|
await import("./component-WFVDVSDK.js");
|
|
1112
1112
|
await import("./tool-PCOYOCRH.js");
|
|
1113
1113
|
await import("./exit-YLO7BY7Z.js");
|
|
@@ -7,7 +7,7 @@ var _chunkBNDY7RGXcjs = require('./chunk-BNDY7RGX.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkUGXCQIHBcjs = require('./chunk-UGXCQIHB.cjs');
|
|
11
11
|
require('./chunk-PIDLNYIP.cjs');
|
|
12
12
|
require('./chunk-XGJOEQMW.cjs');
|
|
13
13
|
require('./chunk-FZJHYLM2.cjs');
|
|
@@ -100,27 +100,27 @@ var executeContext = async (props) => {
|
|
|
100
100
|
return result;
|
|
101
101
|
};
|
|
102
102
|
var _executeContext = async (props) => {
|
|
103
|
-
var _a, _b
|
|
103
|
+
var _a, _b;
|
|
104
104
|
const controller = createJoinedAbortController([props.signal]);
|
|
105
105
|
const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
106
106
|
const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
|
|
107
107
|
const cleanups = [];
|
|
108
|
-
const ctx = new (0,
|
|
108
|
+
const ctx = new (0, _chunkUGXCQIHBcjs.Context)({
|
|
109
109
|
chat: props.chat,
|
|
110
110
|
instructions: props.instructions,
|
|
111
111
|
objects: props.objects,
|
|
112
112
|
tools: props.tools,
|
|
113
113
|
loop: (_a = props.options) == null ? void 0 : _a.loop,
|
|
114
|
-
|
|
115
|
-
model: (_c = props.options) == null ? void 0 : _c.model,
|
|
116
|
-
timeout: (_d = props.options) == null ? void 0 : _d.timeout,
|
|
114
|
+
timeout: (_b = props.options) == null ? void 0 : _b.timeout,
|
|
117
115
|
exits: props.exits,
|
|
118
|
-
snapshot: props.snapshot
|
|
116
|
+
snapshot: props.snapshot,
|
|
117
|
+
model: props.model,
|
|
118
|
+
temperature: props.temperature
|
|
119
119
|
});
|
|
120
120
|
try {
|
|
121
121
|
while (true) {
|
|
122
122
|
if (ctx.iterations.length >= ctx.loop) {
|
|
123
|
-
return new (0,
|
|
123
|
+
return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, new (0, _chunkJDABP4SDcjs.LoopExceededError)());
|
|
124
124
|
}
|
|
125
125
|
const iteration = await ctx.nextIteration();
|
|
126
126
|
if (controller.signal.aborted) {
|
|
@@ -130,7 +130,7 @@ var _executeContext = async (props) => {
|
|
|
130
130
|
reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
return new (0,
|
|
133
|
+
return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
134
134
|
}
|
|
135
135
|
cleanups.push(
|
|
136
136
|
iteration.traces.onPush((traces) => {
|
|
@@ -166,25 +166,25 @@ var _executeContext = async (props) => {
|
|
|
166
166
|
}
|
|
167
167
|
if (iteration.status.type === "exit_success") {
|
|
168
168
|
const exitName = iteration.status.exit_success.exit_name;
|
|
169
|
-
return new (0,
|
|
169
|
+
return new (0, _chunkUGXCQIHBcjs.SuccessExecutionResult)(ctx, {
|
|
170
170
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
171
171
|
result: iteration.status.exit_success.return_value
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
if (iteration.status.type === "callback_requested") {
|
|
175
|
-
return new (0,
|
|
175
|
+
return new (0, _chunkUGXCQIHBcjs.PartialExecutionResult)(
|
|
176
176
|
ctx,
|
|
177
177
|
iteration.status.callback_requested.signal,
|
|
178
|
-
|
|
178
|
+
_chunkUGXCQIHBcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
return new (0,
|
|
184
|
+
return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
|
|
185
185
|
}
|
|
186
186
|
} catch (error) {
|
|
187
|
-
return new (0,
|
|
187
|
+
return new (0, _chunkUGXCQIHBcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
188
188
|
} finally {
|
|
189
189
|
for (const cleanup of cleanups) {
|
|
190
190
|
try {
|
|
@@ -207,7 +207,7 @@ var executeIteration = async ({
|
|
|
207
207
|
var _a, _b, _c, _d, _e;
|
|
208
208
|
let startedAt = Date.now();
|
|
209
209
|
const traces = iteration.traces;
|
|
210
|
-
const model = await cognitive.getModelDetails(_nullishCoalesce(
|
|
210
|
+
const model = await cognitive.getModelDetails(_nullishCoalesce(iteration.model, () => ( "best")));
|
|
211
211
|
const modelLimit = model.input.maxTokens;
|
|
212
212
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
213
213
|
const messages = _chunkGZPN7RGHcjs.truncateWrappedContent.call(void 0, {
|
|
@@ -231,7 +231,7 @@ var executeIteration = async ({
|
|
|
231
231
|
signal: controller.signal,
|
|
232
232
|
systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
|
|
233
233
|
model: model.ref,
|
|
234
|
-
temperature:
|
|
234
|
+
temperature: iteration.temperature,
|
|
235
235
|
responseFormat: "text",
|
|
236
236
|
messages: messages.filter((x) => x.role !== "system"),
|
|
237
237
|
stopSequences: ctx.version.getStopTokens()
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
PartialExecutionResult,
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DBRWIHIH.js";
|
|
11
11
|
import "./chunk-2D2DE7CD.js";
|
|
12
12
|
import "./chunk-A7QHWVD7.js";
|
|
13
13
|
import "./chunk-EE6NVDID.js";
|
|
@@ -100,7 +100,7 @@ var executeContext = async (props) => {
|
|
|
100
100
|
return result;
|
|
101
101
|
};
|
|
102
102
|
var _executeContext = async (props) => {
|
|
103
|
-
var _a, _b
|
|
103
|
+
var _a, _b;
|
|
104
104
|
const controller = createJoinedAbortController([props.signal]);
|
|
105
105
|
const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
106
106
|
const cognitive = Cognitive.isCognitiveClient(props.client) ? props.client : new Cognitive({ client: props.client });
|
|
@@ -111,11 +111,11 @@ var _executeContext = async (props) => {
|
|
|
111
111
|
objects: props.objects,
|
|
112
112
|
tools: props.tools,
|
|
113
113
|
loop: (_a = props.options) == null ? void 0 : _a.loop,
|
|
114
|
-
|
|
115
|
-
model: (_c = props.options) == null ? void 0 : _c.model,
|
|
116
|
-
timeout: (_d = props.options) == null ? void 0 : _d.timeout,
|
|
114
|
+
timeout: (_b = props.options) == null ? void 0 : _b.timeout,
|
|
117
115
|
exits: props.exits,
|
|
118
|
-
snapshot: props.snapshot
|
|
116
|
+
snapshot: props.snapshot,
|
|
117
|
+
model: props.model,
|
|
118
|
+
temperature: props.temperature
|
|
119
119
|
});
|
|
120
120
|
try {
|
|
121
121
|
while (true) {
|
|
@@ -207,7 +207,7 @@ var executeIteration = async ({
|
|
|
207
207
|
var _a, _b, _c, _d, _e;
|
|
208
208
|
let startedAt = Date.now();
|
|
209
209
|
const traces = iteration.traces;
|
|
210
|
-
const model = await cognitive.getModelDetails(
|
|
210
|
+
const model = await cognitive.getModelDetails(iteration.model ?? "best");
|
|
211
211
|
const modelLimit = model.input.maxTokens;
|
|
212
212
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
213
213
|
const messages = truncateWrappedContent({
|
|
@@ -231,7 +231,7 @@ var executeIteration = async ({
|
|
|
231
231
|
signal: controller.signal,
|
|
232
232
|
systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
|
|
233
233
|
model: model.ref,
|
|
234
|
-
temperature:
|
|
234
|
+
temperature: iteration.temperature,
|
|
235
235
|
responseFormat: "text",
|
|
236
236
|
messages: messages.filter((x) => x.role !== "system"),
|
|
237
237
|
stopSequences: ctx.version.getStopTokens()
|
package/dist/llmz.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cognitive, type BotpressClientLike } from '@botpress/cognitive';
|
|
2
2
|
import { Chat } from './chat.js';
|
|
3
|
-
import { Context, Iteration } from './context.js';
|
|
3
|
+
import { Context, Iteration, Model } 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';
|
|
@@ -92,7 +92,7 @@ export type ExecutionHooks = {
|
|
|
92
92
|
output?: any;
|
|
93
93
|
} | void>;
|
|
94
94
|
};
|
|
95
|
-
type Options = Partial<Pick<Context, 'loop' | '
|
|
95
|
+
type Options = Partial<Pick<Context, 'loop' | 'timeout'>>;
|
|
96
96
|
export type ExecutionProps = {
|
|
97
97
|
/**
|
|
98
98
|
* If provided, the execution will be run in "Chat Mode".
|
|
@@ -171,6 +171,19 @@ export type ExecutionProps = {
|
|
|
171
171
|
* Providing an unsettled snapshot will throw an error.
|
|
172
172
|
*/
|
|
173
173
|
snapshot?: Snapshot;
|
|
174
|
+
/**
|
|
175
|
+
* The model to use for the LLM.
|
|
176
|
+
* This can be a static model name or a function that returns a model name based on the current context.
|
|
177
|
+
*/
|
|
178
|
+
model?: ValueOrGetter<Model, Context>;
|
|
179
|
+
/**
|
|
180
|
+
* The temperature to use for the LLM.
|
|
181
|
+
* This can be a static temperature or a function that returns a temperature based on the current context.
|
|
182
|
+
* The temperature must be between 0 and 2.
|
|
183
|
+
* If the temperature is outside this range, it will be clamped to the nearest valid value.
|
|
184
|
+
* If no temperature is provided, the default temperature of 0.7 will be used.
|
|
185
|
+
*/
|
|
186
|
+
temperature?: ValueOrGetter<number, Context>;
|
|
174
187
|
} & ExecutionHooks;
|
|
175
188
|
export declare const executeContext: (props: ExecutionProps) => Promise<ExecutionResult>;
|
|
176
189
|
export declare const _executeContext: (props: ExecutionProps) => Promise<ExecutionResult>;
|
package/dist/result.d.ts
CHANGED
|
@@ -388,6 +388,8 @@ 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("./context.js").Model;
|
|
392
|
+
temperature: number;
|
|
391
393
|
traces: import("./types.js").Traces.Trace[];
|
|
392
394
|
variables: Record<string, any>;
|
|
393
395
|
started_ts: number;
|
|
@@ -448,8 +450,6 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
|
|
|
448
450
|
iteration: number;
|
|
449
451
|
timeout: number;
|
|
450
452
|
loop: number;
|
|
451
|
-
temperature: number;
|
|
452
|
-
model: "best" | "fast" | `${string}:${string}` | undefined;
|
|
453
453
|
metadata: Record<string, any>;
|
|
454
454
|
snapshot: {
|
|
455
455
|
id: string;
|
|
@@ -543,6 +543,8 @@ 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("./context.js").Model;
|
|
547
|
+
temperature: number;
|
|
546
548
|
traces: import("./types.js").Traces.Trace[];
|
|
547
549
|
variables: Record<string, any>;
|
|
548
550
|
started_ts: number;
|
|
@@ -603,8 +605,6 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
|
|
|
603
605
|
iteration: number;
|
|
604
606
|
timeout: number;
|
|
605
607
|
loop: number;
|
|
606
|
-
temperature: number;
|
|
607
|
-
model: "best" | "fast" | `${string}:${string}` | undefined;
|
|
608
608
|
metadata: Record<string, any>;
|
|
609
609
|
snapshot: {
|
|
610
610
|
id: string;
|
|
@@ -718,6 +718,8 @@ 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("./context.js").Model;
|
|
722
|
+
temperature: number;
|
|
721
723
|
traces: import("./types.js").Traces.Trace[];
|
|
722
724
|
variables: Record<string, any>;
|
|
723
725
|
started_ts: number;
|
|
@@ -778,8 +780,6 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
|
|
|
778
780
|
iteration: number;
|
|
779
781
|
timeout: number;
|
|
780
782
|
loop: number;
|
|
781
|
-
temperature: number;
|
|
782
|
-
model: "best" | "fast" | `${string}:${string}` | undefined;
|
|
783
783
|
metadata: Record<string, any>;
|
|
784
784
|
snapshot: {
|
|
785
785
|
id: string;
|
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.25",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"@babel/standalone": "^7.26.4",
|
|
35
35
|
"@babel/traverse": "^7.26.4",
|
|
36
36
|
"@babel/types": "^7.26.3",
|
|
37
|
-
"@botpress/client": "1.24.2",
|
|
38
37
|
"bytes": "^3.1.2",
|
|
39
38
|
"exponential-backoff": "^3.1.1",
|
|
40
39
|
"handlebars": "^4.7.8",
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"chalk": "^4.1.2",
|
|
60
59
|
"diff": "^8.0.1",
|
|
61
60
|
"dotenv": "^16.4.4",
|
|
62
|
-
"esbuild": "^0.
|
|
61
|
+
"esbuild": "^0.25.10",
|
|
63
62
|
"glob": "^9.3.4",
|
|
64
63
|
"source-map-js": "1.2.1",
|
|
65
64
|
"ts-node": "^10.9.2",
|
|
@@ -67,7 +66,8 @@
|
|
|
67
66
|
"tsx": "^4.19.2"
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
|
70
|
-
"@botpress/
|
|
69
|
+
"@botpress/client": "^1.25.0",
|
|
70
|
+
"@botpress/cognitive": "^0.1.44",
|
|
71
71
|
"@bpinternal/thicktoken": "^1.0.5",
|
|
72
72
|
"@bpinternal/zui": "^1.0.1"
|
|
73
73
|
},
|
|
@@ -77,6 +77,9 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
|
+
"@botpress/client": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
80
83
|
"@botpress/cognitive": {
|
|
81
84
|
"optional": false
|
|
82
85
|
},
|