llmz 0.1.1 → 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.
@@ -88,7 +88,7 @@ var getModelOutputLimit = (inputLength) => _chunkHC2QZTVTcjs.clamp_default.call(
88
88
  RESPONSE_LENGTH_BUFFER.MIN_TOKENS,
89
89
  RESPONSE_LENGTH_BUFFER.MAX_TOKENS
90
90
  );
91
- var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
91
+ var generateCode = async ({ iteration, ctx, cognitive, controller, metadata }) => {
92
92
  var _a, _b, _c;
93
93
  const startedAt = Date.now();
94
94
  const traces = iteration.traces;
@@ -118,7 +118,8 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
118
118
  responseFormat: "text",
119
119
  reasoningEffort: iteration.reasoningEffort,
120
120
  messages: messages.filter((x) => x.role !== "system"),
121
- stopSequences: ctx.version.getStopTokens()
121
+ stopSequences: ctx.version.getStopTokens(),
122
+ meta: metadata ? { metadata } : void 0
122
123
  }).catch((thrown) => {
123
124
  throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkFPLSJF4Scjs.getErrorMessage.call(void 0, thrown)}`);
124
125
  });
@@ -597,7 +598,8 @@ var executeContextInternal = async (props) => {
597
598
  onBeforeExecution,
598
599
  onAfterTool,
599
600
  onBeforeTool,
600
- onIterationEnd
601
+ onIterationEnd,
602
+ metadata: props.metadata
601
603
  });
602
604
  if (iterationResult.type === "return") {
603
605
  return iterationResult.result;
@@ -664,7 +666,8 @@ var executeIterationWithErrorHandling = async ({
664
666
  onBeforeExecution,
665
667
  onAfterTool,
666
668
  onBeforeTool,
667
- onIterationEnd
669
+ onIterationEnd,
670
+ metadata
668
671
  }) => {
669
672
  try {
670
673
  await executeIteration({
@@ -675,7 +678,8 @@ var executeIterationWithErrorHandling = async ({
675
678
  onExit,
676
679
  onBeforeExecution,
677
680
  onAfterTool,
678
- onBeforeTool
681
+ onBeforeTool,
682
+ metadata
679
683
  });
680
684
  await finalizeIteration({ iteration, controller, onIterationEnd });
681
685
  return { type: "proceed" };
@@ -766,9 +770,10 @@ var executeIteration = async ({
766
770
  onExit,
767
771
  onBeforeExecution,
768
772
  onBeforeTool,
769
- onAfterTool
773
+ onAfterTool,
774
+ metadata
770
775
  }) => {
771
- await generateCode({ iteration, ctx, cognitive, controller });
776
+ await generateCode({ iteration, ctx, cognitive, controller, metadata });
772
777
  if (typeof onBeforeExecution === "function") {
773
778
  try {
774
779
  const hookRes = await onBeforeExecution(iteration, controller);
@@ -88,7 +88,7 @@ var getModelOutputLimit = (inputLength) => clamp_default(
88
88
  RESPONSE_LENGTH_BUFFER.MIN_TOKENS,
89
89
  RESPONSE_LENGTH_BUFFER.MAX_TOKENS
90
90
  );
91
- var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
91
+ var generateCode = async ({ iteration, ctx, cognitive, controller, metadata }) => {
92
92
  var _a, _b, _c;
93
93
  const startedAt = Date.now();
94
94
  const traces = iteration.traces;
@@ -118,7 +118,8 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
118
118
  responseFormat: "text",
119
119
  reasoningEffort: iteration.reasoningEffort,
120
120
  messages: messages.filter((x) => x.role !== "system"),
121
- stopSequences: ctx.version.getStopTokens()
121
+ stopSequences: ctx.version.getStopTokens(),
122
+ meta: metadata ? { metadata } : void 0
122
123
  }).catch((thrown) => {
123
124
  throw new CognitiveError(`LLM generation failed: ${getErrorMessage(thrown)}`);
124
125
  });
@@ -597,7 +598,8 @@ var executeContextInternal = async (props) => {
597
598
  onBeforeExecution,
598
599
  onAfterTool,
599
600
  onBeforeTool,
600
- onIterationEnd
601
+ onIterationEnd,
602
+ metadata: props.metadata
601
603
  });
602
604
  if (iterationResult.type === "return") {
603
605
  return iterationResult.result;
@@ -664,7 +666,8 @@ var executeIterationWithErrorHandling = async ({
664
666
  onBeforeExecution,
665
667
  onAfterTool,
666
668
  onBeforeTool,
667
- onIterationEnd
669
+ onIterationEnd,
670
+ metadata
668
671
  }) => {
669
672
  try {
670
673
  await executeIteration({
@@ -675,7 +678,8 @@ var executeIterationWithErrorHandling = async ({
675
678
  onExit,
676
679
  onBeforeExecution,
677
680
  onAfterTool,
678
- onBeforeTool
681
+ onBeforeTool,
682
+ metadata
679
683
  });
680
684
  await finalizeIteration({ iteration, controller, onIterationEnd });
681
685
  return { type: "proceed" };
@@ -766,9 +770,10 @@ var executeIteration = async ({
766
770
  onExit,
767
771
  onBeforeExecution,
768
772
  onBeforeTool,
769
- onAfterTool
773
+ onAfterTool,
774
+ metadata
770
775
  }) => {
771
- await generateCode({ iteration, ctx, cognitive, controller });
776
+ await generateCode({ iteration, ctx, cognitive, controller, metadata });
772
777
  if (typeof onBeforeExecution === "function") {
773
778
  try {
774
779
  const hookRes = await onBeforeExecution(iteration, controller);
package/dist/index.cjs CHANGED
@@ -54,7 +54,7 @@ var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
54
54
  var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
55
55
 
56
56
  // package.json
57
- var version = "0.1.1";
57
+ var version = "0.1.2";
58
58
 
59
59
  // src/objects.ts
60
60
  var _zui = require('@bpinternal/zui');
@@ -1116,11 +1116,11 @@ var utils = {
1116
1116
  truncateWrappedContent: _chunkZPHRTTQXcjs.truncateWrappedContent
1117
1117
  };
1118
1118
  var execute = async (props) => {
1119
- const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-7MDJHUHO.cjs")));
1119
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-22PSGL7P.cjs")));
1120
1120
  return executeContext(props);
1121
1121
  };
1122
1122
  var init = async () => {
1123
- await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-7MDJHUHO.cjs")));
1123
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-22PSGL7P.cjs")));
1124
1124
  await Promise.resolve().then(() => _interopRequireWildcard(require("./component-NNHBHD72.cjs")));
1125
1125
  await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-GJ6ZXWS2.cjs")));
1126
1126
  await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-LUJY7JIG.cjs")));
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export declare const utils: {
44
44
  * @param props.signal - Optional AbortSignal to cancel execution
45
45
  * @param props.model - Optional model name (or array or models to use as fallback) (static or dynamic function)
46
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
47
48
  * @param props.options - Optional execution options (loop limit, timeout)
48
49
  * @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
49
50
  * @param props.onIterationEnd - Optional blocking hook called after each iteration
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  } from "./chunk-34GJUS6U.js";
55
55
 
56
56
  // package.json
57
- var version = "0.1.1";
57
+ var version = "0.1.2";
58
58
 
59
59
  // src/objects.ts
60
60
  import { z } from "@bpinternal/zui";
@@ -1116,11 +1116,11 @@ var utils = {
1116
1116
  truncateWrappedContent
1117
1117
  };
1118
1118
  var execute = async (props) => {
1119
- const { executeContext } = await import("./execute-TPUSOWBP.js");
1119
+ const { executeContext } = await import("./execute-ZENBZBWL.js");
1120
1120
  return executeContext(props);
1121
1121
  };
1122
1122
  var init = async () => {
1123
- await import("./execute-TPUSOWBP.js");
1123
+ await import("./execute-ZENBZBWL.js");
1124
1124
  await import("./component-2Z3KLWLX.js");
1125
1125
  await import("./tool-DNHVW3KC.js");
1126
1126
  await import("./exit-VJATJTQI.js");
@@ -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 {};
@@ -206,6 +206,10 @@ export type ExecutionProps = {
206
206
  * If not provided, the model will not use reasoning for models with optional reasoning.
207
207
  */
208
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>;
209
213
  } & ExecutionHooks;
210
214
  export type RuntimeCognitive = Pick<Cognitive, 'getModelDetails' | 'generateContent'>;
211
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.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",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@botpress/client": "1.47.0",
75
- "@botpress/cognitive": "0.6.1",
75
+ "@botpress/cognitive": "0.6.2",
76
76
  "@bpinternal/thicktoken": "^2.0.0",
77
77
  "@bpinternal/zui": "^2.3.0"
78
78
  },