llmz 0.1.0 → 0.1.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/{chunk-PQGZQQA6.cjs → chunk-C7T6OJB4.cjs} +11 -2
- package/dist/{chunk-NK2NCYSY.js → chunk-TIZWOIDF.js} +10 -1
- package/dist/custom-client.d.ts +18 -0
- package/dist/{execute-2BVFYTJT.cjs → execute-22PSGL7P.cjs} +27 -21
- package/dist/{execute-EZXXBWB6.js → execute-ZENBZBWL.js} +15 -9
- package/dist/index.cjs +7 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -4
- package/dist/runtime/generate.d.ts +2 -1
- package/dist/runtime/types.d.ts +6 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -1423,6 +1423,15 @@ var Context = (_class2 = class {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
}, _class2);
|
|
1425
1425
|
|
|
1426
|
+
// src/custom-client.ts
|
|
1427
|
+
var _CustomModelClient = (_class3 = class __CustomModelClient {constructor() { _class3.prototype.__init6.call(this); }
|
|
1428
|
+
__init6() {this["$$COGNITIVE"] = "runtime"}
|
|
1429
|
+
static isCustomClient(obj) {
|
|
1430
|
+
return obj instanceof __CustomModelClient || (obj == null ? void 0 : obj["$$COGNITIVE"]) === "runtime";
|
|
1431
|
+
}
|
|
1432
|
+
}, _class3);
|
|
1433
|
+
|
|
1434
|
+
|
|
1426
1435
|
|
|
1427
1436
|
|
|
1428
1437
|
|
|
@@ -1435,4 +1444,4 @@ var Context = (_class2 = class {
|
|
|
1435
1444
|
|
|
1436
1445
|
|
|
1437
1446
|
|
|
1438
|
-
exports.parseExit = parseExit; exports.Snapshot = Snapshot; exports.ExecutionResult = ExecutionResult; exports.SuccessExecutionResult = SuccessExecutionResult; exports.ErrorExecutionResult = ErrorExecutionResult; exports.PartialExecutionResult = PartialExecutionResult; exports.getValue = getValue; exports.ThinkExit = ThinkExit; exports.ListenExit = ListenExit; exports.DefaultExit = DefaultExit; exports.Context = Context;
|
|
1447
|
+
exports.parseExit = parseExit; exports.Snapshot = Snapshot; exports.ExecutionResult = ExecutionResult; exports.SuccessExecutionResult = SuccessExecutionResult; exports.ErrorExecutionResult = ErrorExecutionResult; exports.PartialExecutionResult = PartialExecutionResult; exports.getValue = getValue; exports.ThinkExit = ThinkExit; exports.ListenExit = ListenExit; exports.DefaultExit = DefaultExit; exports.Context = Context; exports._CustomModelClient = _CustomModelClient;
|
|
@@ -1423,6 +1423,14 @@ var Context = class {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
1425
1425
|
|
|
1426
|
+
// src/custom-client.ts
|
|
1427
|
+
var _CustomModelClient = class __CustomModelClient {
|
|
1428
|
+
["$$COGNITIVE"] = "runtime";
|
|
1429
|
+
static isCustomClient(obj) {
|
|
1430
|
+
return obj instanceof __CustomModelClient || (obj == null ? void 0 : obj["$$COGNITIVE"]) === "runtime";
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1426
1434
|
export {
|
|
1427
1435
|
parseExit,
|
|
1428
1436
|
Snapshot,
|
|
@@ -1434,5 +1442,6 @@ export {
|
|
|
1434
1442
|
ThinkExit,
|
|
1435
1443
|
ListenExit,
|
|
1436
1444
|
DefaultExit,
|
|
1437
|
-
Context
|
|
1445
|
+
Context,
|
|
1446
|
+
_CustomModelClient
|
|
1438
1447
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Model } from '@botpress/cognitive';
|
|
2
|
+
import { RuntimeCognitive } from './runtime/types.js';
|
|
3
|
+
export type RuntimeGenerateContentInput = Parameters<RuntimeCognitive['generateContent']>[0];
|
|
4
|
+
export type RuntimeGenerateContentOutput = Awaited<ReturnType<RuntimeCognitive['generateContent']>>;
|
|
5
|
+
/**
|
|
6
|
+
* Internal escape hatch for supplying a custom model client that bypasses Cognitive.
|
|
7
|
+
*
|
|
8
|
+
* Intended for use by the Botpress engineering team only (e.g. running benchmarks
|
|
9
|
+
* against arbitrary models). It is intentionally undocumented and offers no stability
|
|
10
|
+
* guarantees — the API may change or be removed without notice. Avoid it unless you
|
|
11
|
+
* fully understand the implications.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class _CustomModelClient implements RuntimeCognitive {
|
|
14
|
+
private readonly ['$$COGNITIVE'];
|
|
15
|
+
static isCustomClient(obj: any): obj is _CustomModelClient;
|
|
16
|
+
abstract getModelDetails(model: string): Promise<Model>;
|
|
17
|
+
abstract generateContent(input: RuntimeGenerateContentInput): Promise<RuntimeGenerateContentOutput>;
|
|
18
|
+
}
|
|
@@ -8,7 +8,8 @@ var _chunkJXD2KJVBcjs = require('./chunk-JXD2KJVB.cjs');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkC7T6OJB4cjs = require('./chunk-C7T6OJB4.cjs');
|
|
12
13
|
require('./chunk-BBX2LDZE.cjs');
|
|
13
14
|
require('./chunk-WODK7Y4J.cjs');
|
|
14
15
|
require('./chunk-7LMIOS6H.cjs');
|
|
@@ -87,7 +88,7 @@ var getModelOutputLimit = (inputLength) => _chunkHC2QZTVTcjs.clamp_default.call(
|
|
|
87
88
|
RESPONSE_LENGTH_BUFFER.MIN_TOKENS,
|
|
88
89
|
RESPONSE_LENGTH_BUFFER.MAX_TOKENS
|
|
89
90
|
);
|
|
90
|
-
var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
91
|
+
var generateCode = async ({ iteration, ctx, cognitive, controller, metadata }) => {
|
|
91
92
|
var _a, _b, _c;
|
|
92
93
|
const startedAt = Date.now();
|
|
93
94
|
const traces = iteration.traces;
|
|
@@ -117,7 +118,8 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
|
117
118
|
responseFormat: "text",
|
|
118
119
|
reasoningEffort: iteration.reasoningEffort,
|
|
119
120
|
messages: messages.filter((x) => x.role !== "system"),
|
|
120
|
-
stopSequences: ctx.version.getStopTokens()
|
|
121
|
+
stopSequences: ctx.version.getStopTokens(),
|
|
122
|
+
meta: metadata ? { metadata } : void 0
|
|
121
123
|
}).catch((thrown) => {
|
|
122
124
|
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, thrown)}`);
|
|
123
125
|
});
|
|
@@ -243,7 +245,7 @@ var interpretVMResult = async ({
|
|
|
243
245
|
});
|
|
244
246
|
return;
|
|
245
247
|
}
|
|
246
|
-
const parsedExit =
|
|
248
|
+
const parsedExit = _chunkC7T6OJB4cjs.parseExit.call(void 0, returnValue, iteration.exits);
|
|
247
249
|
if (!parsedExit.success) {
|
|
248
250
|
iteration.end({
|
|
249
251
|
type: "exit_error",
|
|
@@ -537,8 +539,8 @@ var executeContextInternal = async (props) => {
|
|
|
537
539
|
const controller = createJoinedAbortController([props.signal]);
|
|
538
540
|
const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
539
541
|
const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
|
|
540
|
-
const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : _cognitive.CognitiveBeta.isBetaClient(client) ? _cognitive.cognitiveFromBeta.call(void 0, client) : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
|
|
541
|
-
const ctx = new (0,
|
|
542
|
+
const cognitive = _cognitive.Cognitive.isCognitiveClient(client) || _chunkC7T6OJB4cjs._CustomModelClient.isCustomClient(client) ? client : _cognitive.CognitiveBeta.isBetaClient(client) ? _cognitive.cognitiveFromBeta.call(void 0, client) : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
|
|
543
|
+
const ctx = new (0, _chunkC7T6OJB4cjs.Context)({
|
|
542
544
|
chat: props.chat,
|
|
543
545
|
instructions: props.instructions,
|
|
544
546
|
objects: props.objects,
|
|
@@ -554,7 +556,7 @@ var executeContextInternal = async (props) => {
|
|
|
554
556
|
try {
|
|
555
557
|
while (true) {
|
|
556
558
|
if (ctx.iterations.length >= ctx.loop) {
|
|
557
|
-
return new (0,
|
|
559
|
+
return new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
|
|
558
560
|
}
|
|
559
561
|
const iteration = await ctx.nextIteration();
|
|
560
562
|
const unsubscribeTrace = iteration.traces.onPush((traces) => {
|
|
@@ -585,7 +587,7 @@ var executeContextInternal = async (props) => {
|
|
|
585
587
|
}
|
|
586
588
|
}
|
|
587
589
|
});
|
|
588
|
-
return new (0,
|
|
590
|
+
return new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
589
591
|
}
|
|
590
592
|
const iterationResult = await executeIterationWithErrorHandling({
|
|
591
593
|
iteration,
|
|
@@ -596,7 +598,8 @@ var executeContextInternal = async (props) => {
|
|
|
596
598
|
onBeforeExecution,
|
|
597
599
|
onAfterTool,
|
|
598
600
|
onBeforeTool,
|
|
599
|
-
onIterationEnd
|
|
601
|
+
onIterationEnd,
|
|
602
|
+
metadata: props.metadata
|
|
600
603
|
});
|
|
601
604
|
if (iterationResult.type === "return") {
|
|
602
605
|
return iterationResult.result;
|
|
@@ -614,7 +617,7 @@ var executeContextInternal = async (props) => {
|
|
|
614
617
|
}
|
|
615
618
|
}
|
|
616
619
|
} catch (error) {
|
|
617
|
-
return new (0,
|
|
620
|
+
return new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
618
621
|
}
|
|
619
622
|
};
|
|
620
623
|
var executeIterationStartHook = async ({
|
|
@@ -663,7 +666,8 @@ var executeIterationWithErrorHandling = async ({
|
|
|
663
666
|
onBeforeExecution,
|
|
664
667
|
onAfterTool,
|
|
665
668
|
onBeforeTool,
|
|
666
|
-
onIterationEnd
|
|
669
|
+
onIterationEnd,
|
|
670
|
+
metadata
|
|
667
671
|
}) => {
|
|
668
672
|
try {
|
|
669
673
|
await executeIteration({
|
|
@@ -674,7 +678,8 @@ var executeIterationWithErrorHandling = async ({
|
|
|
674
678
|
onExit,
|
|
675
679
|
onBeforeExecution,
|
|
676
680
|
onAfterTool,
|
|
677
|
-
onBeforeTool
|
|
681
|
+
onBeforeTool,
|
|
682
|
+
metadata
|
|
678
683
|
});
|
|
679
684
|
await finalizeIteration({ iteration, controller, onIterationEnd });
|
|
680
685
|
return { type: "proceed" };
|
|
@@ -699,7 +704,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
699
704
|
if (!controller.signal.aborted) {
|
|
700
705
|
return {
|
|
701
706
|
type: "return",
|
|
702
|
-
result: new (0,
|
|
707
|
+
result: new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, err)
|
|
703
708
|
};
|
|
704
709
|
}
|
|
705
710
|
await finalizeIteration({
|
|
@@ -715,7 +720,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
715
720
|
});
|
|
716
721
|
return {
|
|
717
722
|
type: "return",
|
|
718
|
-
result: new (0,
|
|
723
|
+
result: new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")))
|
|
719
724
|
};
|
|
720
725
|
}
|
|
721
726
|
};
|
|
@@ -727,7 +732,7 @@ var transformIterationResult = ({
|
|
|
727
732
|
const exitName = iteration.status.exit_success.exit_name;
|
|
728
733
|
return {
|
|
729
734
|
type: "return",
|
|
730
|
-
result: new (0,
|
|
735
|
+
result: new (0, _chunkC7T6OJB4cjs.SuccessExecutionResult)(ctx, {
|
|
731
736
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
732
737
|
result: iteration.status.exit_success.return_value
|
|
733
738
|
})
|
|
@@ -736,17 +741,17 @@ var transformIterationResult = ({
|
|
|
736
741
|
if (iteration.status.type === "callback_requested") {
|
|
737
742
|
return {
|
|
738
743
|
type: "return",
|
|
739
|
-
result: new (0,
|
|
744
|
+
result: new (0, _chunkC7T6OJB4cjs.PartialExecutionResult)(
|
|
740
745
|
ctx,
|
|
741
746
|
iteration.status.callback_requested.signal,
|
|
742
|
-
|
|
747
|
+
_chunkC7T6OJB4cjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
743
748
|
)
|
|
744
749
|
};
|
|
745
750
|
}
|
|
746
751
|
if (iteration.status.type === "aborted") {
|
|
747
752
|
return {
|
|
748
753
|
type: "return",
|
|
749
|
-
result: new (0,
|
|
754
|
+
result: new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( "The operation was aborted")))
|
|
750
755
|
};
|
|
751
756
|
}
|
|
752
757
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
@@ -754,7 +759,7 @@ var transformIterationResult = ({
|
|
|
754
759
|
}
|
|
755
760
|
return {
|
|
756
761
|
type: "return",
|
|
757
|
-
result: new (0,
|
|
762
|
+
result: new (0, _chunkC7T6OJB4cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)))
|
|
758
763
|
};
|
|
759
764
|
};
|
|
760
765
|
var executeIteration = async ({
|
|
@@ -765,9 +770,10 @@ var executeIteration = async ({
|
|
|
765
770
|
onExit,
|
|
766
771
|
onBeforeExecution,
|
|
767
772
|
onBeforeTool,
|
|
768
|
-
onAfterTool
|
|
773
|
+
onAfterTool,
|
|
774
|
+
metadata
|
|
769
775
|
}) => {
|
|
770
|
-
await generateCode({ iteration, ctx, cognitive, controller });
|
|
776
|
+
await generateCode({ iteration, ctx, cognitive, controller, metadata });
|
|
771
777
|
if (typeof onBeforeExecution === "function") {
|
|
772
778
|
try {
|
|
773
779
|
const hookRes = await onBeforeExecution(iteration, controller);
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
PartialExecutionResult,
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult,
|
|
10
|
+
_CustomModelClient,
|
|
10
11
|
parseExit
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TIZWOIDF.js";
|
|
12
13
|
import "./chunk-2O3UTPVH.js";
|
|
13
14
|
import "./chunk-IRCB4FRM.js";
|
|
14
15
|
import "./chunk-TOGYDN6U.js";
|
|
@@ -87,7 +88,7 @@ var getModelOutputLimit = (inputLength) => clamp_default(
|
|
|
87
88
|
RESPONSE_LENGTH_BUFFER.MIN_TOKENS,
|
|
88
89
|
RESPONSE_LENGTH_BUFFER.MAX_TOKENS
|
|
89
90
|
);
|
|
90
|
-
var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
91
|
+
var generateCode = async ({ iteration, ctx, cognitive, controller, metadata }) => {
|
|
91
92
|
var _a, _b, _c;
|
|
92
93
|
const startedAt = Date.now();
|
|
93
94
|
const traces = iteration.traces;
|
|
@@ -117,7 +118,8 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
|
117
118
|
responseFormat: "text",
|
|
118
119
|
reasoningEffort: iteration.reasoningEffort,
|
|
119
120
|
messages: messages.filter((x) => x.role !== "system"),
|
|
120
|
-
stopSequences: ctx.version.getStopTokens()
|
|
121
|
+
stopSequences: ctx.version.getStopTokens(),
|
|
122
|
+
meta: metadata ? { metadata } : void 0
|
|
121
123
|
}).catch((thrown) => {
|
|
122
124
|
throw new CognitiveError(`LLM generation failed: ${getErrorMessage(thrown)}`);
|
|
123
125
|
});
|
|
@@ -537,7 +539,7 @@ var executeContextInternal = async (props) => {
|
|
|
537
539
|
const controller = createJoinedAbortController([props.signal]);
|
|
538
540
|
const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
539
541
|
const client = props.client ?? new Client();
|
|
540
|
-
const cognitive = Cognitive.isCognitiveClient(client) ? client : CognitiveBeta.isBetaClient(client) ? cognitiveFromBeta(client) : new Cognitive({ client, __experimental_beta: true });
|
|
542
|
+
const cognitive = Cognitive.isCognitiveClient(client) || _CustomModelClient.isCustomClient(client) ? client : CognitiveBeta.isBetaClient(client) ? cognitiveFromBeta(client) : new Cognitive({ client, __experimental_beta: true });
|
|
541
543
|
const ctx = new Context({
|
|
542
544
|
chat: props.chat,
|
|
543
545
|
instructions: props.instructions,
|
|
@@ -596,7 +598,8 @@ var executeContextInternal = async (props) => {
|
|
|
596
598
|
onBeforeExecution,
|
|
597
599
|
onAfterTool,
|
|
598
600
|
onBeforeTool,
|
|
599
|
-
onIterationEnd
|
|
601
|
+
onIterationEnd,
|
|
602
|
+
metadata: props.metadata
|
|
600
603
|
});
|
|
601
604
|
if (iterationResult.type === "return") {
|
|
602
605
|
return iterationResult.result;
|
|
@@ -663,7 +666,8 @@ var executeIterationWithErrorHandling = async ({
|
|
|
663
666
|
onBeforeExecution,
|
|
664
667
|
onAfterTool,
|
|
665
668
|
onBeforeTool,
|
|
666
|
-
onIterationEnd
|
|
669
|
+
onIterationEnd,
|
|
670
|
+
metadata
|
|
667
671
|
}) => {
|
|
668
672
|
try {
|
|
669
673
|
await executeIteration({
|
|
@@ -674,7 +678,8 @@ var executeIterationWithErrorHandling = async ({
|
|
|
674
678
|
onExit,
|
|
675
679
|
onBeforeExecution,
|
|
676
680
|
onAfterTool,
|
|
677
|
-
onBeforeTool
|
|
681
|
+
onBeforeTool,
|
|
682
|
+
metadata
|
|
678
683
|
});
|
|
679
684
|
await finalizeIteration({ iteration, controller, onIterationEnd });
|
|
680
685
|
return { type: "proceed" };
|
|
@@ -765,9 +770,10 @@ var executeIteration = async ({
|
|
|
765
770
|
onExit,
|
|
766
771
|
onBeforeExecution,
|
|
767
772
|
onBeforeTool,
|
|
768
|
-
onAfterTool
|
|
773
|
+
onAfterTool,
|
|
774
|
+
metadata
|
|
769
775
|
}) => {
|
|
770
|
-
await generateCode({ iteration, ctx, cognitive, controller });
|
|
776
|
+
await generateCode({ iteration, ctx, cognitive, controller, metadata });
|
|
771
777
|
if (typeof onBeforeExecution === "function") {
|
|
772
778
|
try {
|
|
773
779
|
const hookRes = await onBeforeExecution(iteration, controller);
|
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
var _chunkC7T6OJB4cjs = require('./chunk-C7T6OJB4.cjs');
|
|
13
14
|
require('./chunk-BBX2LDZE.cjs');
|
|
14
15
|
|
|
15
16
|
|
|
@@ -53,7 +54,7 @@ var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
|
53
54
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
54
55
|
|
|
55
56
|
// package.json
|
|
56
|
-
var version = "0.1.
|
|
57
|
+
var version = "0.1.2";
|
|
57
58
|
|
|
58
59
|
// src/objects.ts
|
|
59
60
|
var _zui = require('@bpinternal/zui');
|
|
@@ -1115,11 +1116,11 @@ var utils = {
|
|
|
1115
1116
|
truncateWrappedContent: _chunkZPHRTTQXcjs.truncateWrappedContent
|
|
1116
1117
|
};
|
|
1117
1118
|
var execute = async (props) => {
|
|
1118
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1119
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-22PSGL7P.cjs")));
|
|
1119
1120
|
return executeContext(props);
|
|
1120
1121
|
};
|
|
1121
1122
|
var init = async () => {
|
|
1122
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1123
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-22PSGL7P.cjs")));
|
|
1123
1124
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-NNHBHD72.cjs")));
|
|
1124
1125
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-GJ6ZXWS2.cjs")));
|
|
1125
1126
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-LUJY7JIG.cjs")));
|
|
@@ -1159,4 +1160,5 @@ var init = async () => {
|
|
|
1159
1160
|
|
|
1160
1161
|
|
|
1161
1162
|
|
|
1162
|
-
|
|
1163
|
+
|
|
1164
|
+
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkCQ3UJW76cjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkC7T6OJB4cjs.DefaultExit; exports.ErrorExecutionResult = _chunkC7T6OJB4cjs.ErrorExecutionResult; exports.ExecutionResult = _chunkC7T6OJB4cjs.ExecutionResult; exports.Exit = _chunkD6PU5YAScjs.Exit; exports.ListenExit = _chunkC7T6OJB4cjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkC7T6OJB4cjs.PartialExecutionResult; exports.Snapshot = _chunkC7T6OJB4cjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkC7T6OJB4cjs.SuccessExecutionResult; exports.ThinkExit = _chunkC7T6OJB4cjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkWODK7Y4Jcjs.Tool; exports._CustomModelClient = _chunkC7T6OJB4cjs._CustomModelClient; exports.assertValidComponent = _chunkCQ3UJW76cjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkC7T6OJB4cjs.getValue; exports.init = init; exports.isAnyComponent = _chunkCQ3UJW76cjs.isAnyComponent; exports.isComponent = _chunkCQ3UJW76cjs.isComponent; exports.parseExit = _chunkC7T6OJB4cjs.parseExit; exports.renderToTsx = _chunkCQ3UJW76cjs.renderToTsx; exports.utils = utils; exports.version = version;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { type Iteration, ListenExit, ThinkExit, DefaultExit, IterationStatuses,
|
|
|
19
19
|
export { type Context } from './context.js';
|
|
20
20
|
export type { LLMzPrompts } from './prompts/prompt.js';
|
|
21
21
|
export { type ValueOrGetter, getValue } from './getter.js';
|
|
22
|
+
export * from './custom-client.js';
|
|
22
23
|
export declare const utils: {
|
|
23
24
|
toValidObjectName: (str: string) => string;
|
|
24
25
|
toValidFunctionName: (str: string) => string;
|
|
@@ -43,6 +44,7 @@ export declare const utils: {
|
|
|
43
44
|
* @param props.signal - Optional AbortSignal to cancel execution
|
|
44
45
|
* @param props.model - Optional model name (or array or models to use as fallback) (static or dynamic function)
|
|
45
46
|
* @param props.temperature - Optional temperature value (static or dynamic function)
|
|
47
|
+
* @param props.metadata - Optional metadata attached to cognitive usage records for each LLM call
|
|
46
48
|
* @param props.options - Optional execution options (loop limit, timeout)
|
|
47
49
|
* @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
|
|
48
50
|
* @param props.onIterationEnd - Optional blocking hook called after each iteration
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
Snapshot,
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
|
+
_CustomModelClient,
|
|
10
11
|
getValue,
|
|
11
12
|
parseExit
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TIZWOIDF.js";
|
|
13
14
|
import "./chunk-2O3UTPVH.js";
|
|
14
15
|
import {
|
|
15
16
|
Tool
|
|
@@ -53,7 +54,7 @@ import {
|
|
|
53
54
|
} from "./chunk-34GJUS6U.js";
|
|
54
55
|
|
|
55
56
|
// package.json
|
|
56
|
-
var version = "0.1.
|
|
57
|
+
var version = "0.1.2";
|
|
57
58
|
|
|
58
59
|
// src/objects.ts
|
|
59
60
|
import { z } from "@bpinternal/zui";
|
|
@@ -1115,11 +1116,11 @@ var utils = {
|
|
|
1115
1116
|
truncateWrappedContent
|
|
1116
1117
|
};
|
|
1117
1118
|
var execute = async (props) => {
|
|
1118
|
-
const { executeContext } = await import("./execute-
|
|
1119
|
+
const { executeContext } = await import("./execute-ZENBZBWL.js");
|
|
1119
1120
|
return executeContext(props);
|
|
1120
1121
|
};
|
|
1121
1122
|
var init = async () => {
|
|
1122
|
-
await import("./execute-
|
|
1123
|
+
await import("./execute-ZENBZBWL.js");
|
|
1123
1124
|
await import("./component-2Z3KLWLX.js");
|
|
1124
1125
|
await import("./tool-DNHVW3KC.js");
|
|
1125
1126
|
await import("./exit-VJATJTQI.js");
|
|
@@ -1149,6 +1150,7 @@ export {
|
|
|
1149
1150
|
ThinkExit,
|
|
1150
1151
|
ThinkSignal,
|
|
1151
1152
|
Tool,
|
|
1153
|
+
_CustomModelClient,
|
|
1152
1154
|
assertValidComponent,
|
|
1153
1155
|
execute,
|
|
1154
1156
|
getValue,
|
|
@@ -5,6 +5,7 @@ type GenerateCodeProps = {
|
|
|
5
5
|
ctx: Context;
|
|
6
6
|
cognitive: RuntimeCognitive;
|
|
7
7
|
controller: AbortController;
|
|
8
|
+
metadata?: Record<string, string>;
|
|
8
9
|
};
|
|
9
|
-
export declare const generateCode: ({ iteration, ctx, cognitive, controller }: GenerateCodeProps) => Promise<void>;
|
|
10
|
+
export declare const generateCode: ({ iteration, ctx, cognitive, controller, metadata }: GenerateCodeProps) => Promise<void>;
|
|
10
11
|
export {};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Cognitive, CognitiveBeta, type BotpressClientLike, Models } from '@botpress/cognitive';
|
|
2
2
|
import { Chat } from '../chat.js';
|
|
3
3
|
import { Context, Iteration } from '../context.js';
|
|
4
|
+
import { _CustomModelClient } from '../custom-client.js';
|
|
4
5
|
import { Exit, ExitResult } from '../exit.js';
|
|
5
6
|
import { ValueOrGetter } from '../getter.js';
|
|
6
7
|
import { type ObjectInstance } from '../objects.js';
|
|
@@ -169,7 +170,7 @@ export type ExecutionProps = {
|
|
|
169
170
|
* This is used to generate content using the LLM and to access the Botpress API.
|
|
170
171
|
* If not provided, a default client will be created using environment variables.
|
|
171
172
|
*/
|
|
172
|
-
client?: Cognitive | CognitiveBeta | BotpressClientLike;
|
|
173
|
+
client?: Cognitive | CognitiveBeta | BotpressClientLike | _CustomModelClient;
|
|
173
174
|
/**
|
|
174
175
|
* When provided, the execution will immediately stop when the signal is aborted.
|
|
175
176
|
* This will stop the LLM generation, as well as kill the VM sandbox execution.
|
|
@@ -205,6 +206,10 @@ export type ExecutionProps = {
|
|
|
205
206
|
* If not provided, the model will not use reasoning for models with optional reasoning.
|
|
206
207
|
*/
|
|
207
208
|
reasoningEffort?: ValueOrGetter<'low' | 'medium' | 'high' | 'dynamic' | 'none', Context>;
|
|
209
|
+
/**
|
|
210
|
+
* Arbitrary key-value metadata to attach to cognitive usage records for each LLM call.
|
|
211
|
+
*/
|
|
212
|
+
metadata?: Record<string, string>;
|
|
208
213
|
} & ExecutionHooks;
|
|
209
214
|
export type RuntimeCognitive = Pick<Cognitive, 'getModelDetails' | 'generateContent'>;
|
|
210
215
|
export {};
|
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.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"tsx": "^4.19.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@botpress/client": "1.
|
|
75
|
-
"@botpress/cognitive": "0.6.
|
|
74
|
+
"@botpress/client": "1.47.0",
|
|
75
|
+
"@botpress/cognitive": "0.6.2",
|
|
76
76
|
"@bpinternal/thicktoken": "^2.0.0",
|
|
77
77
|
"@bpinternal/zui": "^2.3.0"
|
|
78
78
|
},
|