modelfusion 0.134.0 → 0.135.0

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/index.cjs CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,10 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
26
  mod
28
27
  ));
29
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => {
31
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
- return value;
33
- };
34
29
 
35
30
  // src/index.ts
36
31
  var src_exports = {};
@@ -95,6 +90,7 @@ __export(src_exports, {
95
90
  OPENAI_TRANSCRIPTION_MODELS: () => OPENAI_TRANSCRIPTION_MODELS,
96
91
  ObjectFromTextGenerationModel: () => ObjectFromTextGenerationModel,
97
92
  ObjectFromTextStreamingModel: () => ObjectFromTextStreamingModel,
93
+ ObjectGeneratorTool: () => ObjectGeneratorTool,
98
94
  ObjectParseError: () => ObjectParseError,
99
95
  ObjectStreamFromResponse: () => ObjectStreamFromResponse,
100
96
  ObjectStreamResponse: () => ObjectStreamResponse,
@@ -239,12 +235,12 @@ var import_nanoid = require("nanoid");
239
235
 
240
236
  // src/core/FunctionEventSource.ts
241
237
  var FunctionEventSource = class {
238
+ observers;
239
+ errorHandler;
242
240
  constructor({
243
241
  observers,
244
242
  errorHandler
245
243
  }) {
246
- __publicField(this, "observers");
247
- __publicField(this, "errorHandler");
248
244
  this.observers = observers;
249
245
  this.errorHandler = errorHandler ?? ((error) => console.error(error));
250
246
  }
@@ -261,6 +257,13 @@ var FunctionEventSource = class {
261
257
 
262
258
  // src/core/DefaultRun.ts
263
259
  var DefaultRun = class {
260
+ runId;
261
+ sessionId;
262
+ userId;
263
+ abortSignal;
264
+ errorHandler;
265
+ events = [];
266
+ functionEventSource;
264
267
  constructor({
265
268
  runId = `run-${(0, import_nanoid.nanoid)()}`,
266
269
  sessionId,
@@ -269,19 +272,6 @@ var DefaultRun = class {
269
272
  observers,
270
273
  errorHandler
271
274
  } = {}) {
272
- __publicField(this, "runId");
273
- __publicField(this, "sessionId");
274
- __publicField(this, "userId");
275
- __publicField(this, "abortSignal");
276
- __publicField(this, "errorHandler");
277
- __publicField(this, "events", []);
278
- __publicField(this, "functionEventSource");
279
- __publicField(this, "functionObserver", {
280
- onFunctionEvent: (event) => {
281
- this.events.push(event);
282
- this.functionEventSource.notify(event);
283
- }
284
- });
285
275
  this.runId = runId;
286
276
  this.sessionId = sessionId;
287
277
  this.userId = userId;
@@ -292,6 +282,12 @@ var DefaultRun = class {
292
282
  errorHandler: this.errorHandler.bind(this)
293
283
  });
294
284
  }
285
+ functionObserver = {
286
+ onFunctionEvent: (event) => {
287
+ this.events.push(event);
288
+ this.functionEventSource.notify(event);
289
+ }
290
+ };
295
291
  };
296
292
 
297
293
  // src/core/ModelFusionConfiguration.ts
@@ -341,6 +337,13 @@ var AbortError = class extends Error {
341
337
 
342
338
  // src/core/api/ApiCallError.ts
343
339
  var ApiCallError = class extends Error {
340
+ url;
341
+ requestBodyValues;
342
+ statusCode;
343
+ responseBody;
344
+ cause;
345
+ isRetryable;
346
+ data;
344
347
  constructor({
345
348
  message,
346
349
  url,
@@ -352,13 +355,6 @@ var ApiCallError = class extends Error {
352
355
  data
353
356
  }) {
354
357
  super(message);
355
- __publicField(this, "url");
356
- __publicField(this, "requestBodyValues");
357
- __publicField(this, "statusCode");
358
- __publicField(this, "responseBody");
359
- __publicField(this, "cause");
360
- __publicField(this, "isRetryable");
361
- __publicField(this, "data");
362
358
  this.name = "ApiCallError";
363
359
  this.url = url;
364
360
  this.requestBodyValues = requestBodyValues;
@@ -416,16 +412,16 @@ function getErrorMessage(error) {
416
412
 
417
413
  // src/core/api/RetryError.ts
418
414
  var RetryError = class extends Error {
415
+ // note: property order determines debugging output
416
+ reason;
417
+ lastError;
418
+ errors;
419
419
  constructor({
420
420
  message,
421
421
  reason,
422
422
  errors
423
423
  }) {
424
424
  super(message);
425
- // note: property order determines debugging output
426
- __publicField(this, "reason");
427
- __publicField(this, "lastError");
428
- __publicField(this, "errors");
429
425
  this.name = "RetryError";
430
426
  this.reason = reason;
431
427
  this.errors = errors;
@@ -493,10 +489,10 @@ async function _retryWithExponentialBackoff(f, {
493
489
 
494
490
  // src/core/api/throttleMaxConcurrency.ts
495
491
  var MaxConcurrencyThrottler = class {
492
+ maxConcurrentCalls;
493
+ activeCallCount;
494
+ callQueue;
496
495
  constructor({ maxConcurrentCalls }) {
497
- __publicField(this, "maxConcurrentCalls");
498
- __publicField(this, "activeCallCount");
499
- __publicField(this, "callQueue");
500
496
  this.maxConcurrentCalls = maxConcurrentCalls;
501
497
  this.activeCallCount = 0;
502
498
  this.callQueue = [];
@@ -540,14 +536,14 @@ var throttleOff = () => (fn) => fn();
540
536
 
541
537
  // src/core/api/AbstractApiConfiguration.ts
542
538
  var AbstractApiConfiguration = class {
539
+ retry;
540
+ throttle;
541
+ customCallHeaders;
543
542
  constructor({
544
543
  retry,
545
544
  throttle,
546
545
  customCallHeaders = () => ({})
547
546
  }) {
548
- __publicField(this, "retry");
549
- __publicField(this, "throttle");
550
- __publicField(this, "customCallHeaders");
551
547
  this.retry = retry;
552
548
  this.throttle = throttle;
553
549
  this.customCallHeaders = customCallHeaders;
@@ -567,6 +563,8 @@ var AbstractApiConfiguration = class {
567
563
 
568
564
  // src/core/api/BaseUrlApiConfiguration.ts
569
565
  var BaseUrlApiConfiguration = class extends AbstractApiConfiguration {
566
+ baseUrl;
567
+ fixedHeadersValue;
570
568
  constructor({
571
569
  baseUrl,
572
570
  headers,
@@ -575,8 +573,6 @@ var BaseUrlApiConfiguration = class extends AbstractApiConfiguration {
575
573
  customCallHeaders
576
574
  }) {
577
575
  super({ retry, throttle, customCallHeaders });
578
- __publicField(this, "baseUrl");
579
- __publicField(this, "fixedHeadersValue");
580
576
  this.baseUrl = typeof baseUrl == "string" ? parseBaseUrl(baseUrl) : baseUrl;
581
577
  this.fixedHeadersValue = headers ?? {};
582
578
  }
@@ -637,9 +633,7 @@ function resolveBaseUrl(baseUrl = {}, baseUrlDefaults) {
637
633
 
638
634
  // src/core/cache/MemoryCache.ts
639
635
  var MemoryCache = class {
640
- constructor() {
641
- __publicField(this, "cache", /* @__PURE__ */ new Map());
642
- }
636
+ cache = /* @__PURE__ */ new Map();
643
637
  hashKey(key) {
644
638
  return JSON.stringify(key);
645
639
  }
@@ -786,9 +780,7 @@ function startDurationMeasurement() {
786
780
  return globalThis.performance != null ? new PerformanceNowDurationMeasurement() : new DateDurationMeasurement();
787
781
  }
788
782
  var PerformanceNowDurationMeasurement = class {
789
- constructor() {
790
- __publicField(this, "startTime", globalThis.performance.now());
791
- }
783
+ startTime = globalThis.performance.now();
792
784
  get startEpochSeconds() {
793
785
  return Math.floor(
794
786
  (globalThis.performance.timeOrigin + this.startTime) / 1e3
@@ -802,9 +794,7 @@ var PerformanceNowDurationMeasurement = class {
802
794
  }
803
795
  };
804
796
  var DateDurationMeasurement = class {
805
- constructor() {
806
- __publicField(this, "startTime", Date.now());
807
- }
797
+ startTime = Date.now();
808
798
  get startEpochSeconds() {
809
799
  return Math.floor(this.startTime / 1e3);
810
800
  }
@@ -924,14 +914,14 @@ async function executeFunction(fn, input, options) {
924
914
 
925
915
  // src/core/schema/JSONParseError.ts
926
916
  var JSONParseError = class extends Error {
917
+ // note: property order determines debugging output
918
+ text;
919
+ cause;
927
920
  constructor({ text: text13, cause }) {
928
921
  super(
929
922
  `JSON parsing failed: Text: ${text13}.
930
923
  Error message: ${getErrorMessage(cause)}`
931
924
  );
932
- // note: property order determines debugging output
933
- __publicField(this, "text");
934
- __publicField(this, "cause");
935
925
  this.name = "JSONParseError";
936
926
  this.cause = cause;
937
927
  this.text = text13;
@@ -949,13 +939,13 @@ Error message: ${getErrorMessage(cause)}`
949
939
 
950
940
  // src/core/schema/TypeValidationError.ts
951
941
  var TypeValidationError = class extends Error {
942
+ value;
943
+ cause;
952
944
  constructor({ value, cause }) {
953
945
  super(
954
946
  `Type validation failed: Value: ${JSON.stringify(value)}.
955
947
  Error message: ${getErrorMessage(cause)}`
956
948
  );
957
- __publicField(this, "value");
958
- __publicField(this, "cause");
959
949
  this.name = "TypeValidationError";
960
950
  this.cause = cause;
961
951
  this.value = value;
@@ -978,7 +968,6 @@ function uncheckedSchema(jsonSchema) {
978
968
  var UncheckedSchema = class {
979
969
  constructor(jsonSchema) {
980
970
  this.jsonSchema = jsonSchema;
981
- __publicField(this, "_type");
982
971
  }
983
972
  validate(value) {
984
973
  return { success: true, value };
@@ -986,6 +975,7 @@ var UncheckedSchema = class {
986
975
  getJsonSchema() {
987
976
  return this.jsonSchema;
988
977
  }
978
+ _type;
989
979
  };
990
980
 
991
981
  // src/core/schema/ZodSchema.ts
@@ -994,16 +984,8 @@ function zodSchema(zodSchema2) {
994
984
  return new ZodSchema(zodSchema2);
995
985
  }
996
986
  var ZodSchema = class {
987
+ zodSchema;
997
988
  constructor(zodSchema2) {
998
- __publicField(this, "zodSchema");
999
- /**
1000
- * Use only for typing purposes. The value is always `undefined`.
1001
- */
1002
- __publicField(this, "_type");
1003
- /**
1004
- * Use only for typing purposes. The value is always `undefined`.
1005
- */
1006
- __publicField(this, "_partialType");
1007
989
  this.zodSchema = zodSchema2;
1008
990
  }
1009
991
  validate(value) {
@@ -1013,6 +995,14 @@ var ZodSchema = class {
1013
995
  getJsonSchema() {
1014
996
  return (0, import_zod_to_json_schema.zodToJsonSchema)(this.zodSchema);
1015
997
  }
998
+ /**
999
+ * Use only for typing purposes. The value is always `undefined`.
1000
+ */
1001
+ _type;
1002
+ /**
1003
+ * Use only for typing purposes. The value is always `undefined`.
1004
+ */
1005
+ _partialType;
1016
1006
  };
1017
1007
 
1018
1008
  // src/core/schema/parseJSON.ts
@@ -1311,13 +1301,13 @@ async function embed({
1311
1301
 
1312
1302
  // src/model-function/classify/EmbeddingSimilarityClassifier.ts
1313
1303
  var EmbeddingSimilarityClassifier = class _EmbeddingSimilarityClassifier {
1304
+ settings;
1305
+ modelInformation = {
1306
+ provider: "modelfusion",
1307
+ modelName: "EmbeddingSimilarityClassifier"
1308
+ };
1309
+ embeddings;
1314
1310
  constructor(settings) {
1315
- __publicField(this, "settings");
1316
- __publicField(this, "modelInformation", {
1317
- provider: "modelfusion",
1318
- modelName: "EmbeddingSimilarityClassifier"
1319
- });
1320
- __publicField(this, "embeddings");
1321
1311
  this.settings = settings;
1322
1312
  }
1323
1313
  async getEmbeddings(options) {
@@ -1414,12 +1404,12 @@ async function classify({
1414
1404
 
1415
1405
  // src/model-function/generate-image/PromptTemplateImageGenerationModel.ts
1416
1406
  var PromptTemplateImageGenerationModel = class _PromptTemplateImageGenerationModel {
1407
+ model;
1408
+ promptTemplate;
1417
1409
  constructor({
1418
1410
  model,
1419
1411
  promptTemplate
1420
1412
  }) {
1421
- __publicField(this, "model");
1422
- __publicField(this, "promptTemplate");
1423
1413
  this.model = model;
1424
1414
  this.promptTemplate = promptTemplate;
1425
1415
  }
@@ -1533,11 +1523,9 @@ async function generateSpeech({
1533
1523
 
1534
1524
  // src/util/AsyncQueue.ts
1535
1525
  var AsyncQueue = class {
1536
- constructor() {
1537
- __publicField(this, "values", Array());
1538
- __publicField(this, "pendingResolvers", []);
1539
- __publicField(this, "closed", false);
1540
- }
1526
+ values = Array();
1527
+ pendingResolvers = [];
1528
+ closed = false;
1541
1529
  processPendingResolvers() {
1542
1530
  while (this.pendingResolvers.length > 0) {
1543
1531
  this.pendingResolvers.shift()?.();
@@ -1903,13 +1891,13 @@ async function generateText({
1903
1891
 
1904
1892
  // src/model-function/generate-object/ObjectParseError.ts
1905
1893
  var ObjectParseError = class extends Error {
1894
+ cause;
1895
+ valueText;
1906
1896
  constructor({ valueText, cause }) {
1907
1897
  super(
1908
1898
  `Object parsing failed. Value: ${valueText}.
1909
1899
  Error message: ${getErrorMessage(cause)}`
1910
1900
  );
1911
- __publicField(this, "cause");
1912
- __publicField(this, "valueText");
1913
1901
  this.name = "ObjectParseError";
1914
1902
  this.cause = cause;
1915
1903
  this.valueText = valueText;
@@ -1927,12 +1915,12 @@ Error message: ${getErrorMessage(cause)}`
1927
1915
 
1928
1916
  // src/model-function/generate-object/ObjectFromTextGenerationModel.ts
1929
1917
  var ObjectFromTextGenerationModel = class _ObjectFromTextGenerationModel {
1918
+ model;
1919
+ template;
1930
1920
  constructor({
1931
1921
  model,
1932
1922
  template
1933
1923
  }) {
1934
- __publicField(this, "model");
1935
- __publicField(this, "template");
1936
1924
  this.model = model;
1937
1925
  this.template = template;
1938
1926
  }
@@ -2453,6 +2441,9 @@ function ObjectStreamToTextStream(stream) {
2453
2441
 
2454
2442
  // src/model-function/generate-object/ObjectValidationError.ts
2455
2443
  var ObjectValidationError = class extends Error {
2444
+ cause;
2445
+ valueText;
2446
+ value;
2456
2447
  constructor({
2457
2448
  value,
2458
2449
  valueText,
@@ -2462,9 +2453,6 @@ var ObjectValidationError = class extends Error {
2462
2453
  `Object validation failed. Value: ${valueText}.
2463
2454
  Error message: ${getErrorMessage(cause)}`
2464
2455
  );
2465
- __publicField(this, "cause");
2466
- __publicField(this, "valueText");
2467
- __publicField(this, "value");
2468
2456
  this.name = "ObjectValidationError";
2469
2457
  this.cause = cause;
2470
2458
  this.value = value;
@@ -2531,7 +2519,7 @@ async function generateObject({
2531
2519
 
2532
2520
  // src/model-function/generate-object/jsonObjectPrompt.ts
2533
2521
  var DEFAULT_SCHEMA_PREFIX = "JSON schema:";
2534
- var DEFAULT_SCHEMA_SUFFIX = "\nYou MUST answer with a JSON object matches the above schema.";
2522
+ var DEFAULT_SCHEMA_SUFFIX = "\nYou MUST answer with a JSON object that matches the JSON schema above.";
2535
2523
  var jsonObjectPrompt = {
2536
2524
  custom(createPrompt) {
2537
2525
  return { createPrompt, extractObject };
@@ -2578,6 +2566,7 @@ function createSystemPrompt({
2578
2566
  }) {
2579
2567
  return [
2580
2568
  originalSystemPrompt,
2569
+ originalSystemPrompt != null ? "" : null,
2581
2570
  schemaPrefix,
2582
2571
  JSON.stringify(schema.getJsonSchema()),
2583
2572
  schemaSuffix
@@ -2697,6 +2686,9 @@ async function streamObject({
2697
2686
 
2698
2687
  // src/tool/generate-tool-call/ToolCallParseError.ts
2699
2688
  var ToolCallParseError = class extends Error {
2689
+ toolName;
2690
+ valueText;
2691
+ cause;
2700
2692
  constructor({
2701
2693
  toolName,
2702
2694
  valueText,
@@ -2706,9 +2698,6 @@ var ToolCallParseError = class extends Error {
2706
2698
  `Tool call parsing failed for '${toolName}'. Value: ${valueText}.
2707
2699
  Error message: ${getErrorMessage(cause)}`
2708
2700
  );
2709
- __publicField(this, "toolName");
2710
- __publicField(this, "valueText");
2711
- __publicField(this, "cause");
2712
2701
  this.name = "ToolCallParseError";
2713
2702
  this.toolName = toolName;
2714
2703
  this.cause = cause;
@@ -2728,14 +2717,14 @@ Error message: ${getErrorMessage(cause)}`
2728
2717
 
2729
2718
  // src/tool/generate-tool-call/TextGenerationToolCallModel.ts
2730
2719
  var TextGenerationToolCallModel = class _TextGenerationToolCallModel {
2720
+ model;
2721
+ template;
2731
2722
  constructor({
2732
2723
  model,
2733
- format
2724
+ template
2734
2725
  }) {
2735
- __publicField(this, "model");
2736
- __publicField(this, "format");
2737
2726
  this.model = model;
2738
- this.format = format;
2727
+ this.template = template;
2739
2728
  }
2740
2729
  get modelInformation() {
2741
2730
  return this.model.modelInformation;
@@ -2746,17 +2735,26 @@ var TextGenerationToolCallModel = class _TextGenerationToolCallModel {
2746
2735
  get settingsForEvent() {
2747
2736
  return this.model.settingsForEvent;
2748
2737
  }
2738
+ getModelWithJsonOutput(schema) {
2739
+ if (this.template.withJsonOutput != null) {
2740
+ return this.template.withJsonOutput({
2741
+ model: this.model,
2742
+ schema
2743
+ });
2744
+ }
2745
+ return this.model;
2746
+ }
2749
2747
  async doGenerateToolCall(tool, prompt, options) {
2750
2748
  const { rawResponse, text: text13, metadata } = await generateText({
2751
- model: this.model,
2752
- prompt: this.format.createPrompt(prompt, tool),
2749
+ model: this.getModelWithJsonOutput(tool.parameters),
2750
+ prompt: this.template.createPrompt(prompt, tool),
2753
2751
  fullResponse: true,
2754
2752
  ...options
2755
2753
  });
2756
2754
  try {
2757
2755
  return {
2758
2756
  rawResponse,
2759
- toolCall: this.format.extractToolCall(text13, tool),
2757
+ toolCall: this.template.extractToolCall(text13, tool),
2760
2758
  usage: metadata?.usage
2761
2759
  };
2762
2760
  } catch (error) {
@@ -2770,20 +2768,20 @@ var TextGenerationToolCallModel = class _TextGenerationToolCallModel {
2770
2768
  withSettings(additionalSettings) {
2771
2769
  return new _TextGenerationToolCallModel({
2772
2770
  model: this.model.withSettings(additionalSettings),
2773
- format: this.format
2771
+ template: this.template
2774
2772
  });
2775
2773
  }
2776
2774
  };
2777
2775
 
2778
2776
  // src/tool/generate-tool-calls/ToolCallsParseError.ts
2779
2777
  var ToolCallsParseError = class extends Error {
2778
+ valueText;
2779
+ cause;
2780
2780
  constructor({ valueText, cause }) {
2781
2781
  super(
2782
2782
  `Tool calls parsing failed. Value: ${valueText}.
2783
2783
  Error message: ${getErrorMessage(cause)}`
2784
2784
  );
2785
- __publicField(this, "valueText");
2786
- __publicField(this, "cause");
2787
2785
  this.name = "ToolCallsParseError";
2788
2786
  this.cause = cause;
2789
2787
  this.valueText = valueText;
@@ -2801,12 +2799,12 @@ Error message: ${getErrorMessage(cause)}`
2801
2799
 
2802
2800
  // src/tool/generate-tool-calls/TextGenerationToolCallsModel.ts
2803
2801
  var TextGenerationToolCallsModel = class _TextGenerationToolCallsModel {
2802
+ model;
2803
+ template;
2804
2804
  constructor({
2805
2805
  model,
2806
2806
  template
2807
2807
  }) {
2808
- __publicField(this, "model");
2809
- __publicField(this, "template");
2810
2808
  this.model = model;
2811
2809
  this.template = template;
2812
2810
  }
@@ -2855,12 +2853,12 @@ var TextGenerationToolCallsModel = class _TextGenerationToolCallsModel {
2855
2853
 
2856
2854
  // src/model-function/generate-text/PromptTemplateTextGenerationModel.ts
2857
2855
  var PromptTemplateTextGenerationModel = class _PromptTemplateTextGenerationModel {
2856
+ model;
2857
+ promptTemplate;
2858
2858
  constructor({
2859
2859
  model,
2860
2860
  promptTemplate
2861
2861
  }) {
2862
- __publicField(this, "model");
2863
- __publicField(this, "promptTemplate");
2864
2862
  this.model = model;
2865
2863
  this.promptTemplate = promptTemplate;
2866
2864
  }
@@ -2900,7 +2898,7 @@ var PromptTemplateTextGenerationModel = class _PromptTemplateTextGenerationModel
2900
2898
  asToolCallGenerationModel(promptTemplate) {
2901
2899
  return new TextGenerationToolCallModel({
2902
2900
  model: this,
2903
- format: promptTemplate
2901
+ template: promptTemplate
2904
2902
  });
2905
2903
  }
2906
2904
  asToolCallsOrTextGenerationModel(promptTemplate) {
@@ -3000,9 +2998,9 @@ __export(AlpacaPromptTemplate_exports, {
3000
2998
 
3001
2999
  // src/model-function/generate-text/prompt-template/InvalidPromptError.ts
3002
3000
  var InvalidPromptError = class extends Error {
3001
+ prompt;
3003
3002
  constructor(message, prompt) {
3004
3003
  super(message);
3005
- __publicField(this, "prompt");
3006
3004
  this.name = "InvalidPromptError";
3007
3005
  this.prompt = prompt;
3008
3006
  }
@@ -4017,8 +4015,8 @@ var callWithRetryAndThrottle = async ({
4017
4015
 
4018
4016
  // src/model-function/AbstractModel.ts
4019
4017
  var AbstractModel = class {
4018
+ settings;
4020
4019
  constructor({ settings }) {
4021
- __publicField(this, "settings");
4022
4020
  this.settings = settings;
4023
4021
  }
4024
4022
  // implemented as a separate accessor to remove all other properties from the model
@@ -4041,8 +4039,8 @@ function mapBasicPromptToAutomatic1111Format() {
4041
4039
  var Automatic1111ImageGenerationModel = class _Automatic1111ImageGenerationModel extends AbstractModel {
4042
4040
  constructor(settings) {
4043
4041
  super({ settings });
4044
- __publicField(this, "provider", "Automatic1111");
4045
4042
  }
4043
+ provider = "Automatic1111";
4046
4044
  get modelName() {
4047
4045
  return this.settings.model;
4048
4046
  }
@@ -4218,8 +4216,8 @@ var import_zod5 = require("zod");
4218
4216
  // src/model-provider/cohere/CohereTokenizer.ts
4219
4217
  var import_zod4 = require("zod");
4220
4218
  var CohereTokenizer = class {
4219
+ settings;
4221
4220
  constructor(settings) {
4222
- __publicField(this, "settings");
4223
4221
  this.settings = settings;
4224
4222
  }
4225
4223
  async callTokenizeAPI(text13, callOptions) {
@@ -4341,12 +4339,6 @@ var COHERE_TEXT_EMBEDDING_MODELS = {
4341
4339
  var CohereTextEmbeddingModel = class _CohereTextEmbeddingModel extends AbstractModel {
4342
4340
  constructor(settings) {
4343
4341
  super({ settings });
4344
- __publicField(this, "provider", "cohere");
4345
- __publicField(this, "maxValuesPerCall", 96);
4346
- __publicField(this, "isParallelizable", true);
4347
- __publicField(this, "dimensions");
4348
- __publicField(this, "contextWindowSize");
4349
- __publicField(this, "tokenizer");
4350
4342
  this.contextWindowSize = COHERE_TEXT_EMBEDDING_MODELS[this.modelName].contextWindowSize;
4351
4343
  this.tokenizer = new CohereTokenizer({
4352
4344
  api: this.settings.api,
@@ -4354,9 +4346,15 @@ var CohereTextEmbeddingModel = class _CohereTextEmbeddingModel extends AbstractM
4354
4346
  });
4355
4347
  this.dimensions = COHERE_TEXT_EMBEDDING_MODELS[this.modelName].dimensions;
4356
4348
  }
4349
+ provider = "cohere";
4357
4350
  get modelName() {
4358
4351
  return this.settings.model;
4359
4352
  }
4353
+ maxValuesPerCall = 96;
4354
+ isParallelizable = true;
4355
+ dimensions;
4356
+ contextWindowSize;
4357
+ tokenizer;
4360
4358
  async tokenize(text13) {
4361
4359
  return this.tokenizer.tokenize(text13);
4362
4360
  }
@@ -4502,18 +4500,18 @@ var COHERE_TEXT_GENERATION_MODELS = {
4502
4500
  var CohereTextGenerationModel = class _CohereTextGenerationModel extends AbstractModel {
4503
4501
  constructor(settings) {
4504
4502
  super({ settings });
4505
- __publicField(this, "provider", "cohere");
4506
- __publicField(this, "contextWindowSize");
4507
- __publicField(this, "tokenizer");
4508
4503
  this.contextWindowSize = COHERE_TEXT_GENERATION_MODELS[this.settings.model].contextWindowSize;
4509
4504
  this.tokenizer = new CohereTokenizer({
4510
4505
  api: this.settings.api,
4511
4506
  model: this.settings.model
4512
4507
  });
4513
4508
  }
4509
+ provider = "cohere";
4514
4510
  get modelName() {
4515
4511
  return this.settings.model;
4516
4512
  }
4513
+ contextWindowSize;
4514
+ tokenizer;
4517
4515
  async countPromptTokens(input) {
4518
4516
  return countTokens(this.tokenizer, input);
4519
4517
  }
@@ -4771,8 +4769,8 @@ var defaultModel = "eleven_monolingual_v1";
4771
4769
  var ElevenLabsSpeechModel = class _ElevenLabsSpeechModel extends AbstractModel {
4772
4770
  constructor(settings) {
4773
4771
  super({ settings });
4774
- __publicField(this, "provider", "elevenlabs");
4775
4772
  }
4773
+ provider = "elevenlabs";
4776
4774
  get modelName() {
4777
4775
  return this.settings.voice;
4778
4776
  }
@@ -5003,19 +5001,18 @@ var import_zod9 = require("zod");
5003
5001
  var HuggingFaceTextEmbeddingModel = class _HuggingFaceTextEmbeddingModel extends AbstractModel {
5004
5002
  constructor(settings) {
5005
5003
  super({ settings });
5006
- __publicField(this, "provider", "huggingface");
5007
- __publicField(this, "maxValuesPerCall");
5008
- __publicField(this, "isParallelizable", true);
5009
- __publicField(this, "contextWindowSize");
5010
- __publicField(this, "dimensions");
5011
- __publicField(this, "tokenizer");
5012
- __publicField(this, "countPromptTokens");
5013
5004
  this.maxValuesPerCall = settings.maxValuesPerCall ?? 1024;
5014
5005
  this.dimensions = settings.dimensions;
5015
5006
  }
5007
+ provider = "huggingface";
5016
5008
  get modelName() {
5017
5009
  return this.settings.model;
5018
5010
  }
5011
+ maxValuesPerCall;
5012
+ isParallelizable = true;
5013
+ contextWindowSize = void 0;
5014
+ dimensions;
5015
+ tokenizer = void 0;
5019
5016
  async callAPI(texts, callOptions) {
5020
5017
  if (texts.length > this.maxValuesPerCall) {
5021
5018
  throw new Error(
@@ -5056,6 +5053,7 @@ var HuggingFaceTextEmbeddingModel = class _HuggingFaceTextEmbeddingModel extends
5056
5053
  options: this.settings.options
5057
5054
  };
5058
5055
  }
5056
+ countPromptTokens = void 0;
5059
5057
  async doEmbedValues(texts, options) {
5060
5058
  const rawResponse = await this.callAPI(texts, options);
5061
5059
  return {
@@ -5076,14 +5074,14 @@ var import_zod10 = require("zod");
5076
5074
  var HuggingFaceTextGenerationModel = class _HuggingFaceTextGenerationModel extends AbstractModel {
5077
5075
  constructor(settings) {
5078
5076
  super({ settings });
5079
- __publicField(this, "provider", "huggingface");
5080
- __publicField(this, "contextWindowSize");
5081
- __publicField(this, "tokenizer");
5082
- __publicField(this, "countPromptTokens");
5083
5077
  }
5078
+ provider = "huggingface";
5084
5079
  get modelName() {
5085
5080
  return this.settings.model;
5086
5081
  }
5082
+ contextWindowSize = void 0;
5083
+ tokenizer = void 0;
5084
+ countPromptTokens = void 0;
5087
5085
  async callAPI(prompt, callOptions) {
5088
5086
  const api = this.settings.api ?? new HuggingFaceApiConfiguration();
5089
5087
  const abortSignal = callOptions?.run?.abortSignal;
@@ -5427,8 +5425,8 @@ var BakLLaVA1 = LlamaCppBakLLaVA1PromptTemplate_exports;
5427
5425
  // src/model-provider/llamacpp/LlamaCppTokenizer.ts
5428
5426
  var import_zod12 = require("zod");
5429
5427
  var LlamaCppTokenizer = class {
5428
+ api;
5430
5429
  constructor(api = new LlamaCppApiConfiguration()) {
5431
- __publicField(this, "api");
5432
5430
  this.api = api;
5433
5431
  }
5434
5432
  async callTokenizeAPI(text13, callOptions) {
@@ -5481,9 +5479,7 @@ var PRIMITIVE_RULES = {
5481
5479
  null: '"null" space'
5482
5480
  };
5483
5481
  var RuleMap = class {
5484
- constructor() {
5485
- __publicField(this, "rules", /* @__PURE__ */ new Map());
5486
- }
5482
+ rules = /* @__PURE__ */ new Map();
5487
5483
  add(name, rule) {
5488
5484
  const escapedName = this.escapeRuleName(name, rule);
5489
5485
  this.rules.set(escapedName, rule);
@@ -5575,16 +5571,16 @@ function visit(schema, name, rules) {
5575
5571
  var LlamaCppCompletionModel = class _LlamaCppCompletionModel extends AbstractModel {
5576
5572
  constructor(settings = {}) {
5577
5573
  super({ settings });
5578
- __publicField(this, "provider", "llamacpp");
5579
- __publicField(this, "tokenizer");
5580
5574
  this.tokenizer = new LlamaCppTokenizer(this.settings.api);
5581
5575
  }
5576
+ provider = "llamacpp";
5582
5577
  get modelName() {
5583
5578
  return null;
5584
5579
  }
5585
5580
  get contextWindowSize() {
5586
5581
  return this.settings.contextWindowSize;
5587
5582
  }
5583
+ tokenizer;
5588
5584
  async callAPI(prompt, callOptions, options) {
5589
5585
  const api = this.settings.api ?? new LlamaCppApiConfiguration();
5590
5586
  const responseFormat = options.responseFormat;
@@ -5884,21 +5880,21 @@ var import_zod14 = require("zod");
5884
5880
  var LlamaCppTextEmbeddingModel = class _LlamaCppTextEmbeddingModel extends AbstractModel {
5885
5881
  constructor(settings = {}) {
5886
5882
  super({ settings });
5887
- __publicField(this, "provider", "llamacpp");
5888
- __publicField(this, "maxValuesPerCall", 1);
5889
- __publicField(this, "contextWindowSize");
5890
- __publicField(this, "tokenizer");
5891
5883
  this.tokenizer = new LlamaCppTokenizer(this.settings.api);
5892
5884
  }
5885
+ provider = "llamacpp";
5893
5886
  get modelName() {
5894
5887
  return null;
5895
5888
  }
5889
+ maxValuesPerCall = 1;
5896
5890
  get isParallelizable() {
5897
5891
  return this.settings.isParallelizable ?? false;
5898
5892
  }
5893
+ contextWindowSize = void 0;
5899
5894
  get dimensions() {
5900
5895
  return this.settings.dimensions;
5901
5896
  }
5897
+ tokenizer;
5902
5898
  async tokenize(text13) {
5903
5899
  return this.tokenizer.tokenize(text13);
5904
5900
  }
@@ -6081,8 +6077,8 @@ var import_zod15 = require("zod");
6081
6077
  var LmntSpeechModel = class _LmntSpeechModel extends AbstractModel {
6082
6078
  constructor(settings) {
6083
6079
  super({ settings });
6084
- __publicField(this, "provider", "lmnt");
6085
6080
  }
6081
+ provider = "lmnt";
6086
6082
  get modelName() {
6087
6083
  return this.settings.voice;
6088
6084
  }
@@ -6326,14 +6322,14 @@ var failedMistralCallResponseHandler = createJsonErrorResponseHandler({
6326
6322
  var MistralChatModel = class _MistralChatModel extends AbstractModel {
6327
6323
  constructor(settings) {
6328
6324
  super({ settings });
6329
- __publicField(this, "provider", "mistral");
6330
- __publicField(this, "contextWindowSize");
6331
- __publicField(this, "tokenizer");
6332
- __publicField(this, "countPromptTokens");
6333
6325
  }
6326
+ provider = "mistral";
6334
6327
  get modelName() {
6335
6328
  return this.settings.model;
6336
6329
  }
6330
+ contextWindowSize = void 0;
6331
+ tokenizer = void 0;
6332
+ countPromptTokens = void 0;
6337
6333
  async callAPI(prompt, callOptions, options) {
6338
6334
  const api = this.settings.api ?? new MistralApiConfiguration();
6339
6335
  const abortSignal = callOptions.run?.abortSignal;
@@ -6518,18 +6514,18 @@ var import_zod18 = require("zod");
6518
6514
  var MistralTextEmbeddingModel = class _MistralTextEmbeddingModel extends AbstractModel {
6519
6515
  constructor(settings) {
6520
6516
  super({ settings });
6521
- __publicField(this, "provider", "mistral");
6522
- __publicField(this, "maxValuesPerCall", 32);
6523
- /**
6524
- * Parallel calls are technically possible, but I have been hitting rate limits and disabled
6525
- * them for now.
6526
- */
6527
- __publicField(this, "isParallelizable", false);
6528
- __publicField(this, "dimensions", 1024);
6529
6517
  }
6518
+ provider = "mistral";
6530
6519
  get modelName() {
6531
6520
  return this.settings.model;
6532
6521
  }
6522
+ maxValuesPerCall = 32;
6523
+ /**
6524
+ * Parallel calls are technically possible, but I have been hitting rate limits and disabled
6525
+ * them for now.
6526
+ */
6527
+ isParallelizable = false;
6528
+ dimensions = 1024;
6533
6529
  async callAPI(texts, callOptions) {
6534
6530
  if (texts.length > this.maxValuesPerCall) {
6535
6531
  throw new Error(
@@ -6724,14 +6720,14 @@ var failedOllamaCallResponseHandler = createJsonErrorResponseHandler({
6724
6720
  var OllamaChatModel = class _OllamaChatModel extends AbstractModel {
6725
6721
  constructor(settings) {
6726
6722
  super({ settings });
6727
- __publicField(this, "provider", "ollama");
6728
- __publicField(this, "tokenizer");
6729
- __publicField(this, "countPromptTokens");
6730
- __publicField(this, "contextWindowSize");
6731
6723
  }
6724
+ provider = "ollama";
6732
6725
  get modelName() {
6733
6726
  return this.settings.model;
6734
6727
  }
6728
+ tokenizer = void 0;
6729
+ countPromptTokens = void 0;
6730
+ contextWindowSize = void 0;
6735
6731
  async callAPI(prompt, callOptions, options) {
6736
6732
  const { responseFormat } = options;
6737
6733
  const api = this.settings.api ?? new OllamaApiConfiguration();
@@ -6840,7 +6836,7 @@ var OllamaChatModel = class _OllamaChatModel extends AbstractModel {
6840
6836
  asToolCallGenerationModel(promptTemplate) {
6841
6837
  return new TextGenerationToolCallModel({
6842
6838
  model: this,
6843
- format: promptTemplate
6839
+ template: promptTemplate
6844
6840
  });
6845
6841
  }
6846
6842
  asToolCallsOrTextGenerationModel(promptTemplate) {
@@ -7025,13 +7021,13 @@ var Vicuna2 = asOllamaCompletionTextPromptTemplateProvider(VicunaPromptTemplate_
7025
7021
  var OllamaCompletionModel = class _OllamaCompletionModel extends AbstractModel {
7026
7022
  constructor(settings) {
7027
7023
  super({ settings });
7028
- __publicField(this, "provider", "ollama");
7029
- __publicField(this, "tokenizer");
7030
- __publicField(this, "countPromptTokens");
7031
7024
  }
7025
+ provider = "ollama";
7032
7026
  get modelName() {
7033
7027
  return this.settings.model;
7034
7028
  }
7029
+ tokenizer = void 0;
7030
+ countPromptTokens = void 0;
7035
7031
  get contextWindowSize() {
7036
7032
  return this.settings.contextWindowSize;
7037
7033
  }
@@ -7162,7 +7158,7 @@ var OllamaCompletionModel = class _OllamaCompletionModel extends AbstractModel {
7162
7158
  asToolCallGenerationModel(promptTemplate) {
7163
7159
  return new TextGenerationToolCallModel({
7164
7160
  model: this,
7165
- format: promptTemplate
7161
+ template: promptTemplate
7166
7162
  });
7167
7163
  }
7168
7164
  asToolCallsOrTextGenerationModel(promptTemplate) {
@@ -7310,12 +7306,12 @@ var import_zod22 = require("zod");
7310
7306
  var OllamaTextEmbeddingModel = class _OllamaTextEmbeddingModel extends AbstractModel {
7311
7307
  constructor(settings) {
7312
7308
  super({ settings });
7313
- __publicField(this, "provider", "ollama");
7314
- __publicField(this, "maxValuesPerCall", 1);
7315
7309
  }
7310
+ provider = "ollama";
7316
7311
  get modelName() {
7317
7312
  return null;
7318
7313
  }
7314
+ maxValuesPerCall = 1;
7319
7315
  get isParallelizable() {
7320
7316
  return this.settings.isParallelizable ?? false;
7321
7317
  }
@@ -7876,11 +7872,11 @@ var import_zod26 = require("zod");
7876
7872
  var AbstractOpenAITextEmbeddingModel = class extends AbstractModel {
7877
7873
  constructor(settings) {
7878
7874
  super({ settings });
7879
- __publicField(this, "isParallelizable", true);
7880
7875
  }
7881
7876
  get maxValuesPerCall() {
7882
7877
  return this.settings.maxValuesPerCall ?? 2048;
7883
7878
  }
7879
+ isParallelizable = true;
7884
7880
  async callAPI(texts, callOptions) {
7885
7881
  const api = this.settings.api ?? new OpenAIApiConfiguration();
7886
7882
  const abortSignal = callOptions.run?.abortSignal;
@@ -7941,6 +7937,10 @@ var openAITextEmbeddingResponseSchema = import_zod26.z.object({
7941
7937
 
7942
7938
  // src/model-provider/openai/AzureOpenAIApiConfiguration.ts
7943
7939
  var AzureOpenAIApiConfiguration = class extends AbstractApiConfiguration {
7940
+ resourceName;
7941
+ deploymentId;
7942
+ apiVersion;
7943
+ fixedHeaderValue;
7944
7944
  constructor({
7945
7945
  resourceName,
7946
7946
  deploymentId,
@@ -7950,10 +7950,6 @@ var AzureOpenAIApiConfiguration = class extends AbstractApiConfiguration {
7950
7950
  throttle
7951
7951
  }) {
7952
7952
  super({ retry, throttle });
7953
- __publicField(this, "resourceName");
7954
- __publicField(this, "deploymentId");
7955
- __publicField(this, "apiVersion");
7956
- __publicField(this, "fixedHeaderValue");
7957
7953
  this.resourceName = resourceName;
7958
7954
  this.deploymentId = deploymentId;
7959
7955
  this.apiVersion = apiVersion;
@@ -8152,16 +8148,16 @@ function chat12() {
8152
8148
 
8153
8149
  // src/model-provider/openai/OpenAIChatFunctionCallObjectGenerationModel.ts
8154
8150
  var OpenAIChatFunctionCallObjectGenerationModel = class _OpenAIChatFunctionCallObjectGenerationModel {
8151
+ model;
8152
+ fnName;
8153
+ fnDescription;
8154
+ promptTemplate;
8155
8155
  constructor({
8156
8156
  model,
8157
8157
  fnName,
8158
8158
  fnDescription,
8159
8159
  promptTemplate
8160
8160
  }) {
8161
- __publicField(this, "model");
8162
- __publicField(this, "fnName");
8163
- __publicField(this, "fnDescription");
8164
- __publicField(this, "promptTemplate");
8165
8161
  this.model = model;
8166
8162
  this.fnName = fnName;
8167
8163
  this.fnDescription = fnDescription;
@@ -8303,9 +8299,9 @@ var TikTokenTokenizer = class {
8303
8299
  * Get a TikToken tokenizer for a specific model or encoding.
8304
8300
  */
8305
8301
  constructor(settings) {
8306
- __publicField(this, "tiktoken");
8307
8302
  this.tiktoken = new import_lite.Tiktoken(getTiktokenBPE(settings.model));
8308
8303
  }
8304
+ tiktoken;
8309
8305
  async tokenize(text13) {
8310
8306
  return this.tiktoken.encode(text13);
8311
8307
  }
@@ -8519,18 +8515,18 @@ var calculateOpenAIChatCostInMillicents = ({
8519
8515
  var OpenAIChatModel = class _OpenAIChatModel extends AbstractOpenAIChatModel {
8520
8516
  constructor(settings) {
8521
8517
  super(settings);
8522
- __publicField(this, "provider", "openai");
8523
- __publicField(this, "contextWindowSize");
8524
- __publicField(this, "tokenizer");
8525
8518
  const modelInformation = getOpenAIChatModelInformation(this.settings.model);
8526
8519
  this.tokenizer = new TikTokenTokenizer({
8527
8520
  model: modelInformation.baseModel
8528
8521
  });
8529
8522
  this.contextWindowSize = modelInformation.contextWindowSize;
8530
8523
  }
8524
+ provider = "openai";
8531
8525
  get modelName() {
8532
8526
  return this.settings.model;
8533
8527
  }
8528
+ contextWindowSize;
8529
+ tokenizer;
8534
8530
  /**
8535
8531
  * Counts the prompt tokens required for the messages. This includes the message base tokens
8536
8532
  * and the prompt base tokens.
@@ -8632,9 +8628,6 @@ var calculateOpenAICompletionCostInMillicents = ({
8632
8628
  var OpenAICompletionModel = class _OpenAICompletionModel extends AbstractOpenAICompletionModel {
8633
8629
  constructor(settings) {
8634
8630
  super(settings);
8635
- __publicField(this, "provider", "openai");
8636
- __publicField(this, "contextWindowSize");
8637
- __publicField(this, "tokenizer");
8638
8631
  const modelInformation = getOpenAICompletionModelInformation(
8639
8632
  this.settings.model
8640
8633
  );
@@ -8643,9 +8636,12 @@ var OpenAICompletionModel = class _OpenAICompletionModel extends AbstractOpenAIC
8643
8636
  });
8644
8637
  this.contextWindowSize = modelInformation.contextWindowSize;
8645
8638
  }
8639
+ provider = "openai";
8646
8640
  get modelName() {
8647
8641
  return this.settings.model;
8648
8642
  }
8643
+ contextWindowSize;
8644
+ tokenizer;
8649
8645
  async countPromptTokens(input) {
8650
8646
  return countTokens(this.tokenizer, input);
8651
8647
  }
@@ -8770,8 +8766,8 @@ var calculateOpenAIImageGenerationCostInMillicents = ({
8770
8766
  var OpenAIImageGenerationModel = class _OpenAIImageGenerationModel extends AbstractModel {
8771
8767
  constructor(settings) {
8772
8768
  super({ settings });
8773
- __publicField(this, "provider", "openai");
8774
8769
  }
8770
+ provider = "openai";
8775
8771
  get modelName() {
8776
8772
  return this.settings.model;
8777
8773
  }
@@ -8892,8 +8888,8 @@ var calculateOpenAISpeechCostInMillicents = ({
8892
8888
  var OpenAISpeechModel = class _OpenAISpeechModel extends AbstractModel {
8893
8889
  constructor(settings) {
8894
8890
  super({ settings });
8895
- __publicField(this, "provider", "openai");
8896
8891
  }
8892
+ provider = "openai";
8897
8893
  get voice() {
8898
8894
  return this.settings.voice;
8899
8895
  }
@@ -8978,17 +8974,17 @@ var calculateOpenAIEmbeddingCostInMillicents = ({
8978
8974
  var OpenAITextEmbeddingModel = class _OpenAITextEmbeddingModel extends AbstractOpenAITextEmbeddingModel {
8979
8975
  constructor(settings) {
8980
8976
  super(settings);
8981
- __publicField(this, "provider", "openai");
8982
- __publicField(this, "dimensions");
8983
- __publicField(this, "tokenizer");
8984
- __publicField(this, "contextWindowSize");
8985
8977
  this.tokenizer = new TikTokenTokenizer({ model: this.modelName });
8986
8978
  this.contextWindowSize = OPENAI_TEXT_EMBEDDING_MODELS[this.modelName].contextWindowSize;
8987
8979
  this.dimensions = this.settings.dimensions ?? OPENAI_TEXT_EMBEDDING_MODELS[this.modelName].dimensions;
8988
8980
  }
8981
+ provider = "openai";
8989
8982
  get modelName() {
8990
8983
  return this.settings.model;
8991
8984
  }
8985
+ dimensions;
8986
+ tokenizer;
8987
+ contextWindowSize;
8992
8988
  async countTokens(input) {
8993
8989
  return countTokens(this.tokenizer, input);
8994
8990
  }
@@ -9052,8 +9048,8 @@ var calculateOpenAITranscriptionCostInMillicents = ({
9052
9048
  var OpenAITranscriptionModel = class _OpenAITranscriptionModel extends AbstractModel {
9053
9049
  constructor(settings) {
9054
9050
  super({ settings });
9055
- __publicField(this, "provider", "openai");
9056
9051
  }
9052
+ provider = "openai";
9057
9053
  get modelName() {
9058
9054
  return this.settings.model;
9059
9055
  }
@@ -9233,17 +9229,14 @@ var FireworksAIApiConfiguration = class extends BaseUrlApiConfigurationWithDefau
9233
9229
  path: "/inference/v1"
9234
9230
  }
9235
9231
  });
9236
- __publicField(this, "provider", "openaicompatible-fireworksai");
9237
9232
  }
9233
+ provider = "openaicompatible-fireworksai";
9238
9234
  };
9239
9235
 
9240
9236
  // src/model-provider/openai-compatible/OpenAICompatibleChatModel.ts
9241
9237
  var OpenAICompatibleChatModel = class _OpenAICompatibleChatModel extends AbstractOpenAIChatModel {
9242
9238
  constructor(settings) {
9243
9239
  super(settings);
9244
- __publicField(this, "contextWindowSize");
9245
- __publicField(this, "tokenizer");
9246
- __publicField(this, "countPromptTokens");
9247
9240
  }
9248
9241
  get provider() {
9249
9242
  return this.settings.provider ?? this.settings.api.provider ?? "openaicompatible";
@@ -9251,6 +9244,9 @@ var OpenAICompatibleChatModel = class _OpenAICompatibleChatModel extends Abstrac
9251
9244
  get modelName() {
9252
9245
  return this.settings.model;
9253
9246
  }
9247
+ contextWindowSize = void 0;
9248
+ tokenizer = void 0;
9249
+ countPromptTokens = void 0;
9254
9250
  get settingsForEvent() {
9255
9251
  const eventSettingProperties = [
9256
9252
  ...textGenerationModelProperties,
@@ -9313,9 +9309,6 @@ var OpenAICompatibleChatModel = class _OpenAICompatibleChatModel extends Abstrac
9313
9309
  var OpenAICompatibleCompletionModel = class _OpenAICompatibleCompletionModel extends AbstractOpenAICompletionModel {
9314
9310
  constructor(settings) {
9315
9311
  super(settings);
9316
- __publicField(this, "contextWindowSize");
9317
- __publicField(this, "tokenizer");
9318
- __publicField(this, "countPromptTokens");
9319
9312
  }
9320
9313
  get provider() {
9321
9314
  return this.settings.provider ?? this.settings.api.provider ?? "openaicompatible";
@@ -9323,6 +9316,9 @@ var OpenAICompatibleCompletionModel = class _OpenAICompatibleCompletionModel ext
9323
9316
  get modelName() {
9324
9317
  return this.settings.model;
9325
9318
  }
9319
+ contextWindowSize = void 0;
9320
+ tokenizer = void 0;
9321
+ countPromptTokens = void 0;
9326
9322
  get settingsForEvent() {
9327
9323
  const eventSettingProperties = [
9328
9324
  ...textGenerationModelProperties,
@@ -9426,8 +9422,8 @@ var PerplexityApiConfiguration = class extends BaseUrlApiConfigurationWithDefaul
9426
9422
  path: ""
9427
9423
  }
9428
9424
  });
9429
- __publicField(this, "provider", "openaicompatible-perplexity");
9430
9425
  }
9426
+ provider = "openaicompatible-perplexity";
9431
9427
  };
9432
9428
 
9433
9429
  // src/model-provider/openai-compatible/TogetherAIApiConfiguration.ts
@@ -9449,8 +9445,8 @@ var TogetherAIApiConfiguration = class extends BaseUrlApiConfigurationWithDefaul
9449
9445
  path: "/v1"
9450
9446
  }
9451
9447
  });
9452
- __publicField(this, "provider", "openaicompatible-togetherai");
9453
9448
  }
9449
+ provider = "openaicompatible-togetherai";
9454
9450
  };
9455
9451
 
9456
9452
  // src/model-provider/openai-compatible/OpenAICompatibleFacade.ts
@@ -9526,8 +9522,8 @@ function mapBasicPromptToStabilityFormat() {
9526
9522
  var StabilityImageGenerationModel = class _StabilityImageGenerationModel extends AbstractModel {
9527
9523
  constructor(settings) {
9528
9524
  super({ settings });
9529
- __publicField(this, "provider", "stability");
9530
9525
  }
9526
+ provider = "stability";
9531
9527
  get modelName() {
9532
9528
  return this.settings.model;
9533
9529
  }
@@ -9647,9 +9643,9 @@ var import_zod31 = require("zod");
9647
9643
  var WhisperCppTranscriptionModel = class _WhisperCppTranscriptionModel extends AbstractModel {
9648
9644
  constructor(settings) {
9649
9645
  super({ settings });
9650
- __publicField(this, "provider", "whispercpp");
9651
- __publicField(this, "modelName", null);
9652
9646
  }
9647
+ provider = "whispercpp";
9648
+ modelName = null;
9653
9649
  async doTranscribe({
9654
9650
  audioData,
9655
9651
  mimeType
@@ -9875,6 +9871,9 @@ async function splitTextChunk(splitFunction, input) {
9875
9871
 
9876
9872
  // src/tool/NoSuchToolDefinitionError.ts
9877
9873
  var NoSuchToolDefinitionError = class extends Error {
9874
+ toolName;
9875
+ cause;
9876
+ parameters;
9878
9877
  constructor({
9879
9878
  toolName,
9880
9879
  parameters
@@ -9882,9 +9881,6 @@ var NoSuchToolDefinitionError = class extends Error {
9882
9881
  super(
9883
9882
  `Tool definition '${toolName}' not found. Parameters: ${JSON.stringify(parameters)}.`
9884
9883
  );
9885
- __publicField(this, "toolName");
9886
- __publicField(this, "cause");
9887
- __publicField(this, "parameters");
9888
9884
  this.name = "NoSuchToolDefinitionError";
9889
9885
  this.toolName = toolName;
9890
9886
  this.parameters = parameters;
@@ -9903,6 +9899,28 @@ var NoSuchToolDefinitionError = class extends Error {
9903
9899
 
9904
9900
  // src/tool/Tool.ts
9905
9901
  var Tool = class {
9902
+ /**
9903
+ * The name of the tool.
9904
+ * Should be understandable for language models and unique among the tools that they know.
9905
+ */
9906
+ name;
9907
+ /**
9908
+ * A optional description of what the tool does. Will be used by the language model to decide whether to use the tool.
9909
+ */
9910
+ description;
9911
+ /**
9912
+ * The schema of the input that the tool expects. The language model will use this to generate the input.
9913
+ * Use descriptions to make the input understandable for the language model.
9914
+ */
9915
+ parameters;
9916
+ /**
9917
+ * An optional schema of the output that the tool produces. This will be used to validate the output.
9918
+ */
9919
+ returnType;
9920
+ /**
9921
+ * The actual execution function of the tool.
9922
+ */
9923
+ execute;
9906
9924
  constructor({
9907
9925
  name,
9908
9926
  description,
@@ -9910,28 +9928,6 @@ var Tool = class {
9910
9928
  returnType,
9911
9929
  execute
9912
9930
  }) {
9913
- /**
9914
- * The name of the tool.
9915
- * Should be understandable for language models and unique among the tools that they know.
9916
- */
9917
- __publicField(this, "name");
9918
- /**
9919
- * A description of what the tool does. Will be used by the language model to decide whether to use the tool.
9920
- */
9921
- __publicField(this, "description");
9922
- /**
9923
- * The schema of the input that the tool expects. The language model will use this to generate the input.
9924
- * Use descriptions to make the input understandable for the language model.
9925
- */
9926
- __publicField(this, "parameters");
9927
- /**
9928
- * An optional schema of the output that the tool produces. This will be used to validate the output.
9929
- */
9930
- __publicField(this, "returnType");
9931
- /**
9932
- * The actual execution function of the tool.
9933
- */
9934
- __publicField(this, "execute");
9935
9931
  this.name = name;
9936
9932
  this.description = description;
9937
9933
  this.parameters = parameters;
@@ -9940,8 +9936,36 @@ var Tool = class {
9940
9936
  }
9941
9937
  };
9942
9938
 
9939
+ // src/tool/ObjectGeneratorTool.ts
9940
+ var ObjectGeneratorTool = class extends Tool {
9941
+ constructor({
9942
+ name = "object-generator",
9943
+ // eslint-disable-line @typescript-eslint/no-explicit-any
9944
+ description,
9945
+ model,
9946
+ parameters,
9947
+ objectSchema,
9948
+ prompt
9949
+ }) {
9950
+ super({
9951
+ name,
9952
+ description,
9953
+ parameters,
9954
+ execute: async (input, options) => generateObject({
9955
+ model,
9956
+ schema: objectSchema,
9957
+ prompt: prompt(input),
9958
+ ...options
9959
+ })
9960
+ });
9961
+ }
9962
+ };
9963
+
9943
9964
  // src/tool/ToolCallArgumentsValidationError.ts
9944
9965
  var ToolCallArgumentsValidationError = class extends Error {
9966
+ toolName;
9967
+ cause;
9968
+ args;
9945
9969
  constructor({
9946
9970
  toolName,
9947
9971
  args,
@@ -9952,9 +9976,6 @@ var ToolCallArgumentsValidationError = class extends Error {
9952
9976
  Arguments: ${JSON.stringify(args)}.
9953
9977
  Error message: ${getErrorMessage(cause)}`
9954
9978
  );
9955
- __publicField(this, "toolName");
9956
- __publicField(this, "cause");
9957
- __publicField(this, "args");
9958
9979
  this.name = "ToolCallArgumentsValidationError";
9959
9980
  this.toolName = toolName;
9960
9981
  this.cause = cause;
@@ -9974,14 +9995,14 @@ Error message: ${getErrorMessage(cause)}`
9974
9995
 
9975
9996
  // src/tool/ToolCallError.ts
9976
9997
  var ToolCallError = class extends Error {
9998
+ toolCall;
9999
+ cause;
9977
10000
  constructor({
9978
10001
  cause,
9979
10002
  toolCall,
9980
10003
  message = getErrorMessage(cause)
9981
10004
  }) {
9982
10005
  super(`Tool call for tool '${toolCall.name}' failed: ${message}`);
9983
- __publicField(this, "toolCall");
9984
- __publicField(this, "cause");
9985
10006
  this.name = "ToolCallError";
9986
10007
  this.toolCall = toolCall;
9987
10008
  this.cause = cause;
@@ -9999,12 +10020,12 @@ var ToolCallError = class extends Error {
9999
10020
 
10000
10021
  // src/tool/ToolCallGenerationError.ts
10001
10022
  var ToolCallGenerationError = class extends Error {
10023
+ toolName;
10024
+ cause;
10002
10025
  constructor({ toolName, cause }) {
10003
10026
  super(
10004
10027
  `Tool call generation failed for tool '${toolName}'. Error message: ${getErrorMessage(cause)}`
10005
10028
  );
10006
- __publicField(this, "toolName");
10007
- __publicField(this, "cause");
10008
10029
  this.name = "ToolCallsGenerationError";
10009
10030
  this.toolName = toolName;
10010
10031
  this.cause = cause;
@@ -10022,6 +10043,9 @@ var ToolCallGenerationError = class extends Error {
10022
10043
 
10023
10044
  // src/tool/ToolExecutionError.ts
10024
10045
  var ToolExecutionError = class extends Error {
10046
+ toolName;
10047
+ input;
10048
+ cause;
10025
10049
  constructor({
10026
10050
  toolName,
10027
10051
  input,
@@ -10029,9 +10053,6 @@ var ToolExecutionError = class extends Error {
10029
10053
  message = getErrorMessage(cause)
10030
10054
  }) {
10031
10055
  super(`Error executing tool '${toolName}': ${message}`);
10032
- __publicField(this, "toolName");
10033
- __publicField(this, "input");
10034
- __publicField(this, "cause");
10035
10056
  this.name = "ToolExecutionError";
10036
10057
  this.toolName = toolName;
10037
10058
  this.input = input;
@@ -10253,29 +10274,63 @@ async function generateToolCall({
10253
10274
 
10254
10275
  // src/tool/generate-tool-call/jsonToolCallPrompt.ts
10255
10276
  var import_nanoid6 = require("nanoid");
10277
+ var DEFAULT_TOOL_PROMPT = (tool) => [
10278
+ `You are calling the function "${tool.name}".`,
10279
+ tool.description != null ? `Function description: ${tool.description}` : null,
10280
+ `Function parameters JSON schema: ${JSON.stringify(
10281
+ tool.parameters.getJsonSchema()
10282
+ )}`,
10283
+ ``,
10284
+ `You MUST answer with a JSON object that matches the JSON schema above.`
10285
+ ].filter(Boolean).join("\n");
10256
10286
  var jsonToolCallPrompt = {
10257
- text() {
10287
+ text({
10288
+ toolPrompt
10289
+ } = {}) {
10258
10290
  return {
10259
- createPrompt(instruction13, tool) {
10291
+ createPrompt(prompt, tool) {
10260
10292
  return {
10261
- system: [
10262
- `You are calling a function "${tool.name}".`,
10263
- tool.description != null ? ` Function description: ${tool.description}` : null,
10264
- ` Function parameters JSON schema: ${JSON.stringify(
10265
- tool.parameters.getJsonSchema()
10266
- )}`,
10267
- ``,
10268
- `You MUST answer with a JSON object matches the above schema for the arguments.`
10269
- ].filter(Boolean).join("\n"),
10270
- instruction: instruction13
10293
+ system: createSystemPrompt2({ tool, toolPrompt }),
10294
+ instruction: prompt
10271
10295
  };
10272
10296
  },
10273
- extractToolCall(response) {
10274
- return { id: (0, import_nanoid6.nanoid)(), args: parseJSON({ text: response }) };
10275
- }
10297
+ extractToolCall,
10298
+ withJsonOutput: ({ model, schema }) => model.withJsonOutput(schema)
10299
+ };
10300
+ },
10301
+ instruction({
10302
+ toolPrompt
10303
+ } = {}) {
10304
+ return {
10305
+ createPrompt(prompt, tool) {
10306
+ return {
10307
+ system: createSystemPrompt2({
10308
+ originalSystemPrompt: prompt.system,
10309
+ tool,
10310
+ toolPrompt
10311
+ }),
10312
+ instruction: prompt.instruction
10313
+ };
10314
+ },
10315
+ extractToolCall,
10316
+ withJsonOutput: ({ model, schema }) => model.withJsonOutput(schema)
10276
10317
  };
10277
10318
  }
10278
10319
  };
10320
+ function createSystemPrompt2({
10321
+ originalSystemPrompt,
10322
+ toolPrompt = DEFAULT_TOOL_PROMPT,
10323
+ tool
10324
+ }) {
10325
+ return [
10326
+ originalSystemPrompt,
10327
+ originalSystemPrompt != null ? "" : null,
10328
+ toolPrompt(tool)
10329
+ ].filter(Boolean).join("\n");
10330
+ }
10331
+ function extractToolCall(response) {
10332
+ return { id: (0, import_nanoid6.nanoid)(), args: parseJSON({ text: response }) };
10333
+ }
10279
10334
 
10280
10335
  // src/tool/generate-tool-calls/generateToolCalls.ts
10281
10336
  async function generateToolCalls({
@@ -10463,6 +10518,9 @@ function createEventSourceStream(events) {
10463
10518
 
10464
10519
  // src/vector-index/VectorIndexRetriever.ts
10465
10520
  var VectorIndexRetriever = class _VectorIndexRetriever {
10521
+ vectorIndex;
10522
+ embeddingModel;
10523
+ settings;
10466
10524
  constructor({
10467
10525
  vectorIndex,
10468
10526
  embeddingModel,
@@ -10470,9 +10528,6 @@ var VectorIndexRetriever = class _VectorIndexRetriever {
10470
10528
  similarityThreshold,
10471
10529
  filter
10472
10530
  }) {
10473
- __publicField(this, "vectorIndex");
10474
- __publicField(this, "embeddingModel");
10475
- __publicField(this, "settings");
10476
10531
  this.vectorIndex = vectorIndex;
10477
10532
  this.embeddingModel = embeddingModel;
10478
10533
  this.settings = {
@@ -10517,9 +10572,6 @@ var jsonDataSchema = zodSchema(
10517
10572
  )
10518
10573
  );
10519
10574
  var MemoryVectorIndex = class _MemoryVectorIndex {
10520
- constructor() {
10521
- __publicField(this, "entries", /* @__PURE__ */ new Map());
10522
- }
10523
10575
  static async deserialize({
10524
10576
  serializedData,
10525
10577
  schema
@@ -10539,6 +10591,7 @@ var MemoryVectorIndex = class _MemoryVectorIndex {
10539
10591
  );
10540
10592
  return vectorIndex;
10541
10593
  }
10594
+ entries = /* @__PURE__ */ new Map();
10542
10595
  async upsertMany(data) {
10543
10596
  for (const entry of data) {
10544
10597
  this.entries.set(entry.id, entry);
@@ -10661,6 +10714,7 @@ async function upsertIntoVectorIndex({
10661
10714
  OPENAI_TRANSCRIPTION_MODELS,
10662
10715
  ObjectFromTextGenerationModel,
10663
10716
  ObjectFromTextStreamingModel,
10717
+ ObjectGeneratorTool,
10664
10718
  ObjectParseError,
10665
10719
  ObjectStreamFromResponse,
10666
10720
  ObjectStreamResponse,