braintrust 0.0.206 → 0.0.207

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.
@@ -573,7 +573,7 @@ interface BackgroundLogger {
573
573
  }
574
574
  declare class HTTPBackgroundLogger implements BackgroundLogger {
575
575
  private apiConn;
576
- private items;
576
+ private queue;
577
577
  private activeFlush;
578
578
  private activeFlushResolved;
579
579
  private activeFlushError;
@@ -582,7 +582,7 @@ declare class HTTPBackgroundLogger implements BackgroundLogger {
582
582
  maxRequestSize: number;
583
583
  defaultBatchSize: number;
584
584
  numTries: number;
585
- queueDropExceedingMaxsize: number | undefined;
585
+ queueDropExceedingMaxsize: number;
586
586
  queueDropLoggingPeriod: number;
587
587
  failedPublishPayloadsDir: string | undefined;
588
588
  allPublishPayloadsDir: string | undefined;
@@ -938,6 +938,19 @@ declare class Prompt<HasId extends boolean = true, HasVersion extends boolean =
938
938
  messages?: Message[];
939
939
  strict?: boolean;
940
940
  }): CompiledPrompt<Flavor>;
941
+ /**
942
+ * This is a special build method that first resolves attachment references, and then
943
+ * calls the regular build method. You should use this if you are building prompts from
944
+ * dataset rows that contain attachments.
945
+ *
946
+ * @param buildArgs Args to forward along to the prompt template.
947
+ */
948
+ buildWithAttachments<Flavor extends "chat" | "completion" = "chat">(buildArgs: unknown, options?: {
949
+ flavor?: Flavor;
950
+ messages?: Message[];
951
+ strict?: boolean;
952
+ state?: BraintrustState;
953
+ }): Promise<CompiledPrompt<Flavor>>;
941
954
  private runBuild;
942
955
  static renderPrompt({ prompt, buildArgs, options, }: {
943
956
  prompt: PromptBlockData;
@@ -1223,13 +1236,13 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1223
1236
  } | undefined;
1224
1237
  }>, z.ZodObject<{
1225
1238
  image_url: z.ZodObject<{
1226
- url: z.ZodString;
1239
+ url: z.ZodEffects<z.ZodString, string, unknown>;
1227
1240
  detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
1228
1241
  }, "strip", z.ZodTypeAny, {
1229
1242
  url: string;
1230
1243
  detail?: "auto" | "low" | "high" | undefined;
1231
1244
  }, {
1232
- url: string;
1245
+ url?: unknown;
1233
1246
  detail?: "auto" | "low" | "high" | undefined;
1234
1247
  }>;
1235
1248
  type: z.ZodLiteral<"image_url">;
@@ -1242,7 +1255,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1242
1255
  }, {
1243
1256
  type: "image_url";
1244
1257
  image_url: {
1245
- url: string;
1258
+ url?: unknown;
1246
1259
  detail?: "auto" | "low" | "high" | undefined;
1247
1260
  };
1248
1261
  }>]>, "many">]>;
@@ -1287,7 +1300,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1287
1300
  } | {
1288
1301
  type: "image_url";
1289
1302
  image_url: {
1290
- url: string;
1303
+ url?: unknown;
1291
1304
  detail?: "auto" | "low" | "high" | undefined;
1292
1305
  };
1293
1306
  })[] | undefined;
@@ -1635,7 +1648,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1635
1648
  } | {
1636
1649
  type: "image_url";
1637
1650
  image_url: {
1638
- url: string;
1651
+ url?: unknown;
1639
1652
  detail?: "auto" | "low" | "high" | undefined;
1640
1653
  };
1641
1654
  })[] | undefined;
@@ -2332,13 +2345,13 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2332
2345
  } | undefined;
2333
2346
  }>, z.ZodObject<{
2334
2347
  image_url: z.ZodObject<{
2335
- url: z.ZodString;
2348
+ url: z.ZodEffects<z.ZodString, string, unknown>;
2336
2349
  detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
2337
2350
  }, "strip", z.ZodTypeAny, {
2338
2351
  url: string;
2339
2352
  detail?: "auto" | "low" | "high" | undefined;
2340
2353
  }, {
2341
- url: string;
2354
+ url?: unknown;
2342
2355
  detail?: "auto" | "low" | "high" | undefined;
2343
2356
  }>;
2344
2357
  type: z.ZodLiteral<"image_url">;
@@ -2351,7 +2364,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2351
2364
  }, {
2352
2365
  type: "image_url";
2353
2366
  image_url: {
2354
- url: string;
2367
+ url?: unknown;
2355
2368
  detail?: "auto" | "low" | "high" | undefined;
2356
2369
  };
2357
2370
  }>]>, "many">]>;
@@ -2396,7 +2409,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2396
2409
  } | {
2397
2410
  type: "image_url";
2398
2411
  image_url: {
2399
- url: string;
2412
+ url?: unknown;
2400
2413
  detail?: "auto" | "low" | "high" | undefined;
2401
2414
  };
2402
2415
  })[] | undefined;
@@ -2744,7 +2757,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2744
2757
  } | {
2745
2758
  type: "image_url";
2746
2759
  image_url: {
2747
- url: string;
2760
+ url?: unknown;
2748
2761
  detail?: "auto" | "low" | "high" | undefined;
2749
2762
  };
2750
2763
  })[] | undefined;
@@ -3630,7 +3643,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
3630
3643
  } | {
3631
3644
  type: "image_url";
3632
3645
  image_url: {
3633
- url: string;
3646
+ url?: unknown;
3634
3647
  detail?: "auto" | "low" | "high" | undefined;
3635
3648
  };
3636
3649
  })[] | undefined;
@@ -573,7 +573,7 @@ interface BackgroundLogger {
573
573
  }
574
574
  declare class HTTPBackgroundLogger implements BackgroundLogger {
575
575
  private apiConn;
576
- private items;
576
+ private queue;
577
577
  private activeFlush;
578
578
  private activeFlushResolved;
579
579
  private activeFlushError;
@@ -582,7 +582,7 @@ declare class HTTPBackgroundLogger implements BackgroundLogger {
582
582
  maxRequestSize: number;
583
583
  defaultBatchSize: number;
584
584
  numTries: number;
585
- queueDropExceedingMaxsize: number | undefined;
585
+ queueDropExceedingMaxsize: number;
586
586
  queueDropLoggingPeriod: number;
587
587
  failedPublishPayloadsDir: string | undefined;
588
588
  allPublishPayloadsDir: string | undefined;
@@ -938,6 +938,19 @@ declare class Prompt<HasId extends boolean = true, HasVersion extends boolean =
938
938
  messages?: Message[];
939
939
  strict?: boolean;
940
940
  }): CompiledPrompt<Flavor>;
941
+ /**
942
+ * This is a special build method that first resolves attachment references, and then
943
+ * calls the regular build method. You should use this if you are building prompts from
944
+ * dataset rows that contain attachments.
945
+ *
946
+ * @param buildArgs Args to forward along to the prompt template.
947
+ */
948
+ buildWithAttachments<Flavor extends "chat" | "completion" = "chat">(buildArgs: unknown, options?: {
949
+ flavor?: Flavor;
950
+ messages?: Message[];
951
+ strict?: boolean;
952
+ state?: BraintrustState;
953
+ }): Promise<CompiledPrompt<Flavor>>;
941
954
  private runBuild;
942
955
  static renderPrompt({ prompt, buildArgs, options, }: {
943
956
  prompt: PromptBlockData;
@@ -1223,13 +1236,13 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1223
1236
  } | undefined;
1224
1237
  }>, z.ZodObject<{
1225
1238
  image_url: z.ZodObject<{
1226
- url: z.ZodString;
1239
+ url: z.ZodEffects<z.ZodString, string, unknown>;
1227
1240
  detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
1228
1241
  }, "strip", z.ZodTypeAny, {
1229
1242
  url: string;
1230
1243
  detail?: "auto" | "low" | "high" | undefined;
1231
1244
  }, {
1232
- url: string;
1245
+ url?: unknown;
1233
1246
  detail?: "auto" | "low" | "high" | undefined;
1234
1247
  }>;
1235
1248
  type: z.ZodLiteral<"image_url">;
@@ -1242,7 +1255,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1242
1255
  }, {
1243
1256
  type: "image_url";
1244
1257
  image_url: {
1245
- url: string;
1258
+ url?: unknown;
1246
1259
  detail?: "auto" | "low" | "high" | undefined;
1247
1260
  };
1248
1261
  }>]>, "many">]>;
@@ -1287,7 +1300,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1287
1300
  } | {
1288
1301
  type: "image_url";
1289
1302
  image_url: {
1290
- url: string;
1303
+ url?: unknown;
1291
1304
  detail?: "auto" | "low" | "high" | undefined;
1292
1305
  };
1293
1306
  })[] | undefined;
@@ -1635,7 +1648,7 @@ declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<
1635
1648
  } | {
1636
1649
  type: "image_url";
1637
1650
  image_url: {
1638
- url: string;
1651
+ url?: unknown;
1639
1652
  detail?: "auto" | "low" | "high" | undefined;
1640
1653
  };
1641
1654
  })[] | undefined;
@@ -2332,13 +2345,13 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2332
2345
  } | undefined;
2333
2346
  }>, z.ZodObject<{
2334
2347
  image_url: z.ZodObject<{
2335
- url: z.ZodString;
2348
+ url: z.ZodEffects<z.ZodString, string, unknown>;
2336
2349
  detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
2337
2350
  }, "strip", z.ZodTypeAny, {
2338
2351
  url: string;
2339
2352
  detail?: "auto" | "low" | "high" | undefined;
2340
2353
  }, {
2341
- url: string;
2354
+ url?: unknown;
2342
2355
  detail?: "auto" | "low" | "high" | undefined;
2343
2356
  }>;
2344
2357
  type: z.ZodLiteral<"image_url">;
@@ -2351,7 +2364,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2351
2364
  }, {
2352
2365
  type: "image_url";
2353
2366
  image_url: {
2354
- url: string;
2367
+ url?: unknown;
2355
2368
  detail?: "auto" | "low" | "high" | undefined;
2356
2369
  };
2357
2370
  }>]>, "many">]>;
@@ -2396,7 +2409,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2396
2409
  } | {
2397
2410
  type: "image_url";
2398
2411
  image_url: {
2399
- url: string;
2412
+ url?: unknown;
2400
2413
  detail?: "auto" | "low" | "high" | undefined;
2401
2414
  };
2402
2415
  })[] | undefined;
@@ -2744,7 +2757,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
2744
2757
  } | {
2745
2758
  type: "image_url";
2746
2759
  image_url: {
2747
- url: string;
2760
+ url?: unknown;
2748
2761
  detail?: "auto" | "low" | "high" | undefined;
2749
2762
  };
2750
2763
  })[] | undefined;
@@ -3630,7 +3643,7 @@ declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodOb
3630
3643
  } | {
3631
3644
  type: "image_url";
3632
3645
  image_url: {
3633
- url: string;
3646
+ url?: unknown;
3634
3647
  detail?: "auto" | "low" | "high" | undefined;
3635
3648
  };
3636
3649
  })[] | undefined;
package/dev/dist/index.js CHANGED
@@ -1084,6 +1084,83 @@ var import_pluralize = __toESM(require("pluralize"));
1084
1084
 
1085
1085
  // src/logger.ts
1086
1086
  var import_uuid = require("uuid");
1087
+
1088
+ // src/queue.ts
1089
+ var DEFAULT_QUEUE_SIZE = 5e3;
1090
+ var Queue = class {
1091
+ buffer;
1092
+ head = 0;
1093
+ // the index of the first item in the queue
1094
+ tail = 0;
1095
+ // the index of the next item to be added
1096
+ size = 0;
1097
+ // the number of items in the queue
1098
+ capacity;
1099
+ // the maximum number of items the queue can hold
1100
+ constructor(maxSize) {
1101
+ if (maxSize < 1) {
1102
+ console.warn(
1103
+ `maxSize ${maxSize} is <1, using default ${DEFAULT_QUEUE_SIZE}`
1104
+ );
1105
+ maxSize = DEFAULT_QUEUE_SIZE;
1106
+ }
1107
+ this.capacity = maxSize;
1108
+ this.buffer = new Array(this.capacity);
1109
+ }
1110
+ push(...items) {
1111
+ const dropped = [];
1112
+ for (const item of items) {
1113
+ if (this.size === this.capacity) {
1114
+ const droppedItem = this.buffer[this.head];
1115
+ if (droppedItem !== void 0) {
1116
+ dropped.push(droppedItem);
1117
+ }
1118
+ this.head = (this.head + 1) % this.capacity;
1119
+ } else {
1120
+ this.size++;
1121
+ }
1122
+ this.buffer[this.tail] = item;
1123
+ this.tail = (this.tail + 1) % this.capacity;
1124
+ }
1125
+ return dropped;
1126
+ }
1127
+ peek() {
1128
+ if (this.size === 0) {
1129
+ return void 0;
1130
+ }
1131
+ return this.buffer[this.head];
1132
+ }
1133
+ drain() {
1134
+ const items = [];
1135
+ if (this.size === 0) {
1136
+ return items;
1137
+ }
1138
+ if (this.head < this.tail) {
1139
+ items.push(...this.buffer.slice(this.head, this.tail));
1140
+ this.buffer.fill(void 0, this.head, this.tail);
1141
+ } else {
1142
+ items.push(...this.buffer.slice(this.head));
1143
+ items.push(...this.buffer.slice(0, this.tail));
1144
+ this.buffer.fill(void 0, this.head, this.capacity);
1145
+ this.buffer.fill(void 0, 0, this.tail);
1146
+ }
1147
+ this.head = 0;
1148
+ this.tail = 0;
1149
+ this.size = 0;
1150
+ return items;
1151
+ }
1152
+ clear() {
1153
+ this.buffer.fill(void 0);
1154
+ this.head = 0;
1155
+ this.tail = 0;
1156
+ this.size = 0;
1157
+ }
1158
+ length() {
1159
+ return this.size;
1160
+ }
1161
+ };
1162
+
1163
+ // src/logger.ts
1087
1164
  var import_core2 = require("@braintrust/core");
1088
1165
  var import_typespecs2 = require("@braintrust/core/typespecs");
1089
1166
  var import_functions = require("@vercel/functions");
@@ -2174,6 +2251,17 @@ var ReadonlyAttachment = class {
2174
2251
  async data() {
2175
2252
  return this._data.get();
2176
2253
  }
2254
+ /**
2255
+ * Returns the attachment contents as a base64-encoded URL that is suitable
2256
+ * for use in a prompt.
2257
+ *
2258
+ * @returns The attachment contents as a base64-encoded URL.
2259
+ */
2260
+ async asBase64Url() {
2261
+ const buf = await (await this.data()).arrayBuffer();
2262
+ const base64 = Buffer.from(buf).toString("base64");
2263
+ return `data:${this.reference.content_type};base64,${base64}`;
2264
+ }
2177
2265
  /**
2178
2266
  * Fetch the attachment metadata, which includes a downloadUrl and a status.
2179
2267
  * This will re-fetch the status each time in case it changes over time.
@@ -2654,7 +2742,7 @@ function now() {
2654
2742
  var BACKGROUND_LOGGER_BASE_SLEEP_TIME_S = 1;
2655
2743
  var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2656
2744
  apiConn;
2657
- items = [];
2745
+ queue;
2658
2746
  activeFlush = Promise.resolve();
2659
2747
  activeFlushResolved = true;
2660
2748
  activeFlushError = void 0;
@@ -2664,7 +2752,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2664
2752
  maxRequestSize = 6 * 1024 * 1024;
2665
2753
  defaultBatchSize = 100;
2666
2754
  numTries = 3;
2667
- queueDropExceedingMaxsize = void 0;
2755
+ queueDropExceedingMaxsize = DEFAULT_QUEUE_SIZE;
2668
2756
  queueDropLoggingPeriod = 60;
2669
2757
  failedPublishPayloadsDir = void 0;
2670
2758
  allPublishPayloadsDir = void 0;
@@ -2700,6 +2788,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2700
2788
  if (!isNaN(queueDropExceedingMaxsizeEnv)) {
2701
2789
  this.queueDropExceedingMaxsize = queueDropExceedingMaxsizeEnv;
2702
2790
  }
2791
+ this.queue = new Queue(this.queueDropExceedingMaxsize);
2703
2792
  const queueDropLoggingPeriodEnv = Number(
2704
2793
  isomorph_default.getEnv("BRAINTRUST_QUEUE_DROP_LOGGING_PERIOD")
2705
2794
  );
@@ -2729,17 +2818,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2729
2818
  if (this._disabled) {
2730
2819
  return;
2731
2820
  }
2732
- const [addedItems, droppedItems] = (() => {
2733
- if (this.queueDropExceedingMaxsize === void 0) {
2734
- return [items, []];
2735
- }
2736
- const numElementsToAdd = Math.min(
2737
- Math.max(this.queueDropExceedingMaxsize - this.items.length, 0),
2738
- items.length
2739
- );
2740
- return [items.slice(0, numElementsToAdd), items.slice(numElementsToAdd)];
2741
- })();
2742
- this.items.push(...addedItems);
2821
+ const droppedItems = this.queue.push(...items);
2743
2822
  if (!this.syncFlush) {
2744
2823
  this.triggerActiveFlush();
2745
2824
  }
@@ -2765,12 +2844,11 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2765
2844
  }
2766
2845
  async flushOnce(args) {
2767
2846
  if (this._disabled) {
2768
- this.items = [];
2847
+ this.queue.clear();
2769
2848
  return;
2770
2849
  }
2771
2850
  const batchSize = args?.batchSize ?? this.defaultBatchSize;
2772
- const wrappedItems = this.items;
2773
- this.items = [];
2851
+ const wrappedItems = this.queue.drain();
2774
2852
  const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
2775
2853
  if (allItems.length === 0) {
2776
2854
  return;
@@ -2822,7 +2900,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
2822
2900
  `Encountered the following errors while uploading attachments:`
2823
2901
  );
2824
2902
  }
2825
- if (this.items.length > 0) {
2903
+ if (this.queue.length() > 0) {
2826
2904
  await this.flushOnce(args);
2827
2905
  }
2828
2906
  }
@@ -3646,6 +3724,19 @@ function enrichAttachments(event, state) {
3646
3724
  }
3647
3725
  return event;
3648
3726
  }
3727
+ async function resolveAttachmentsToBase64(event, state) {
3728
+ for (const [key, value] of Object.entries(event)) {
3729
+ if (value instanceof ReadonlyAttachment) {
3730
+ event[key] = await value.asBase64Url();
3731
+ continue;
3732
+ }
3733
+ if (!(value instanceof Object)) {
3734
+ continue;
3735
+ }
3736
+ await resolveAttachmentsToBase64(value, state);
3737
+ }
3738
+ return event;
3739
+ }
3649
3740
  function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
3650
3741
  if ("input" in event && !isEmpty(event.input) && "inputs" in event && !isEmpty(event.inputs) || !("input" in event) && !("inputs" in event)) {
3651
3742
  throw new Error(
@@ -4623,6 +4714,11 @@ function renderMessage(render, message) {
4623
4714
  case "text":
4624
4715
  return { ...c, text: render(c.text) };
4625
4716
  case "image_url":
4717
+ if ((0, import_core2.isObject)(c.image_url.url)) {
4718
+ throw new Error(
4719
+ "Attachments must be replaced with URLs before calling `build()`"
4720
+ );
4721
+ }
4626
4722
  return {
4627
4723
  ...c,
4628
4724
  image_url: {
@@ -4762,6 +4858,21 @@ var Prompt = class _Prompt {
4762
4858
  strict: options.strict
4763
4859
  });
4764
4860
  }
4861
+ /**
4862
+ * This is a special build method that first resolves attachment references, and then
4863
+ * calls the regular build method. You should use this if you are building prompts from
4864
+ * dataset rows that contain attachments.
4865
+ *
4866
+ * @param buildArgs Args to forward along to the prompt template.
4867
+ */
4868
+ async buildWithAttachments(buildArgs, options = {}) {
4869
+ const hydrated = buildArgs instanceof Object ? await resolveAttachmentsToBase64(buildArgs, options.state) : buildArgs;
4870
+ return this.runBuild(hydrated, {
4871
+ flavor: options.flavor ?? "chat",
4872
+ messages: options.messages,
4873
+ strict: options.strict
4874
+ });
4875
+ }
4765
4876
  runBuild(buildArgs, options) {
4766
4877
  const { flavor } = options;
4767
4878
  const params = {
@@ -4797,15 +4908,6 @@ var Prompt = class _Prompt {
4797
4908
  if (!prompt) {
4798
4909
  throw new Error("Empty prompt");
4799
4910
  }
4800
- const escape = (v) => {
4801
- if (v === void 0) {
4802
- throw new Error("Missing!");
4803
- } else if (typeof v === "string") {
4804
- return v;
4805
- } else {
4806
- return JSON.stringify(v);
4807
- }
4808
- };
4809
4911
  const dictArgParsed = import_zod2.z.record(import_zod2.z.unknown()).safeParse(buildArgs);
4810
4912
  const variables = {
4811
4913
  input: buildArgs,
@@ -4853,6 +4955,10 @@ var Prompt = class _Prompt {
4853
4955
  throw new Error("Missing!");
4854
4956
  } else if (typeof v === "string") {
4855
4957
  return v;
4958
+ } else if (v instanceof ReadonlyAttachment) {
4959
+ throw new Error(
4960
+ "Use buildWithAttachments() to build prompts with attachments"
4961
+ );
4856
4962
  } else {
4857
4963
  return JSON.stringify(v);
4858
4964
  }
@@ -4905,7 +5011,7 @@ var Prompt = class _Prompt {
4905
5011
  };
4906
5012
  } else {
4907
5013
  const _ = prompt;
4908
- throw new Error("never!");
5014
+ throw new Error(`Invalid prompt type: ${_}`);
4909
5015
  }
4910
5016
  }
4911
5017
  getParsedPromptData() {