@digipair/skill-dsp 0.42.0 → 0.43.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.
Files changed (3) hide show
  1. package/index.cjs.js +296 -204
  2. package/index.esm.js +1481 -902
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -1101,7 +1101,7 @@ var RespTransformStream = /*#__PURE__*/ function(TransformStream) {
1101
1101
  }
1102
1102
  (web.TransformStream);
1103
1103
 
1104
- function _array_like_to_array$a(arr, len) {
1104
+ function _array_like_to_array$b(arr, len) {
1105
1105
  if (len == null || len > arr.length) len = arr.length;
1106
1106
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1107
1107
  return arr2;
@@ -1212,7 +1212,7 @@ function _object_spread$i(target) {
1212
1212
  }
1213
1213
  return target;
1214
1214
  }
1215
- function ownKeys$7(object, enumerableOnly) {
1215
+ function ownKeys$8(object, enumerableOnly) {
1216
1216
  var keys = Object.keys(object);
1217
1217
  if (Object.getOwnPropertySymbols) {
1218
1218
  var symbols = Object.getOwnPropertySymbols(object);
@@ -1225,27 +1225,27 @@ function ownKeys$7(object, enumerableOnly) {
1225
1225
  }
1226
1226
  return keys;
1227
1227
  }
1228
- function _object_spread_props$7(target, source) {
1228
+ function _object_spread_props$8(target, source) {
1229
1229
  source = source != null ? source : {};
1230
1230
  if (Object.getOwnPropertyDescriptors) {
1231
1231
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1232
1232
  } else {
1233
- ownKeys$7(Object(source)).forEach(function(key) {
1233
+ ownKeys$8(Object(source)).forEach(function(key) {
1234
1234
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1235
1235
  });
1236
1236
  }
1237
1237
  return target;
1238
1238
  }
1239
1239
  function _sliced_to_array$5(arr, i) {
1240
- return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$5();
1240
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$b(arr, i) || _non_iterable_rest$5();
1241
1241
  }
1242
- function _unsupported_iterable_to_array$a(o, minLen) {
1242
+ function _unsupported_iterable_to_array$b(o, minLen) {
1243
1243
  if (!o) return;
1244
- if (typeof o === "string") return _array_like_to_array$a(o, minLen);
1244
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
1245
1245
  var n = Object.prototype.toString.call(o).slice(8, -1);
1246
1246
  if (n === "Object" && o.constructor) n = o.constructor.name;
1247
1247
  if (n === "Map" || n === "Set") return Array.from(n);
1248
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
1248
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
1249
1249
  }
1250
1250
  function _ts_generator$8(thisArg, body) {
1251
1251
  var f, y, t, g, _ = {
@@ -1447,7 +1447,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
1447
1447
  {
1448
1448
  key: "getModelInfo",
1449
1449
  value: function getModelInfo() {
1450
- return _object_spread_props$7(_object_spread$i({}, this._getModelInfo(this.models.model)), {
1450
+ return _object_spread_props$8(_object_spread$i({}, this._getModelInfo(this.models.model)), {
1451
1451
  provider: this.name
1452
1452
  });
1453
1453
  }
@@ -1456,7 +1456,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
1456
1456
  key: "getEmbedModelInfo",
1457
1457
  value: function getEmbedModelInfo() {
1458
1458
  if (this.models.embedModel) {
1459
- return _object_spread_props$7(_object_spread$i({}, this._getModelInfo(this.models.embedModel)), {
1459
+ return _object_spread_props$8(_object_spread$i({}, this._getModelInfo(this.models.embedModel)), {
1460
1460
  provider: this.name
1461
1461
  });
1462
1462
  }
@@ -1568,10 +1568,10 @@ var AxBaseAI = /*#__PURE__*/ function() {
1568
1568
  if (chatReq.functions && chatReq.functions.length > 0) {
1569
1569
  functions = chatReq.functions;
1570
1570
  }
1571
- req = _object_spread_props$7(_object_spread$i({}, chatReq), {
1571
+ req = _object_spread_props$8(_object_spread$i({}, chatReq), {
1572
1572
  model: model,
1573
1573
  functions: functions,
1574
- modelConfig: _object_spread_props$7(_object_spread$i({}, chatReq.modelConfig), {
1574
+ modelConfig: _object_spread_props$8(_object_spread$i({}, chatReq.modelConfig), {
1575
1575
  stream: stream
1576
1576
  })
1577
1577
  });
@@ -1781,7 +1781,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
1781
1781
  if (!_this.generateEmbedResp) {
1782
1782
  throw new Error("generateEmbedResp not implemented");
1783
1783
  }
1784
- req = _object_spread_props$7(_object_spread$i({}, embedReq), {
1784
+ req = _object_spread_props$8(_object_spread$i({}, embedReq), {
1785
1785
  embedModel: embedModel
1786
1786
  });
1787
1787
  fn = function() {
@@ -3211,7 +3211,7 @@ var axModelInfoCohere = [
3211
3211
  }
3212
3212
  ];
3213
3213
 
3214
- function _array_like_to_array$9(arr, len) {
3214
+ function _array_like_to_array$a(arr, len) {
3215
3215
  if (len == null || len > arr.length) len = arr.length;
3216
3216
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3217
3217
  return arr2;
@@ -3318,7 +3318,7 @@ function _object_spread$d(target) {
3318
3318
  }
3319
3319
  return target;
3320
3320
  }
3321
- function ownKeys$6(object, enumerableOnly) {
3321
+ function ownKeys$7(object, enumerableOnly) {
3322
3322
  var keys = Object.keys(object);
3323
3323
  if (Object.getOwnPropertySymbols) {
3324
3324
  var symbols = Object.getOwnPropertySymbols(object);
@@ -3331,12 +3331,12 @@ function ownKeys$6(object, enumerableOnly) {
3331
3331
  }
3332
3332
  return keys;
3333
3333
  }
3334
- function _object_spread_props$6(target, source) {
3334
+ function _object_spread_props$7(target, source) {
3335
3335
  source = source != null ? source : {};
3336
3336
  if (Object.getOwnPropertyDescriptors) {
3337
3337
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3338
3338
  } else {
3339
- ownKeys$6(Object(source)).forEach(function(key) {
3339
+ ownKeys$7(Object(source)).forEach(function(key) {
3340
3340
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3341
3341
  });
3342
3342
  }
@@ -3356,19 +3356,19 @@ function _set_prototype_of$c(o, p) {
3356
3356
  return _set_prototype_of$c(o, p);
3357
3357
  }
3358
3358
  function _sliced_to_array$4(arr, i) {
3359
- return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$4();
3359
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$4();
3360
3360
  }
3361
3361
  function _type_of$d(obj) {
3362
3362
  "@swc/helpers - typeof";
3363
3363
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
3364
3364
  }
3365
- function _unsupported_iterable_to_array$9(o, minLen) {
3365
+ function _unsupported_iterable_to_array$a(o, minLen) {
3366
3366
  if (!o) return;
3367
- if (typeof o === "string") return _array_like_to_array$9(o, minLen);
3367
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
3368
3368
  var n = Object.prototype.toString.call(o).slice(8, -1);
3369
3369
  if (n === "Object" && o.constructor) n = o.constructor.name;
3370
3370
  if (n === "Map" || n === "Set") return Array.from(n);
3371
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
3371
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
3372
3372
  }
3373
3373
  function _is_native_reflect_construct$c() {
3374
3374
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
@@ -3504,7 +3504,7 @@ var AxAICohere = /*#__PURE__*/ function(AxBaseAI) {
3504
3504
  name: "/v1/chat"
3505
3505
  };
3506
3506
  var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topK, _req_modelConfig_topP, _req_modelConfig_frequencyPenalty, _req_modelConfig_presencePenalty, _req_modelConfig_stopSequences;
3507
- var reqValue = _object_spread_props$6(_object_spread$d({
3507
+ var reqValue = _object_spread_props$7(_object_spread$d({
3508
3508
  message: message,
3509
3509
  model: model,
3510
3510
  tools: tools
@@ -4023,22 +4023,9 @@ var safetySettings = [
4023
4023
  }
4024
4024
  case "assistant":
4025
4025
  {
4026
- if ("content" in msg && typeof msg.content === "string") {
4027
- var parts1 = [
4028
- {
4029
- text: msg.content
4030
- }
4031
- ];
4032
- return {
4033
- role: "model",
4034
- parts: parts1
4035
- };
4036
- }
4037
- var parts2 = [];
4038
- if ("functionCalls" in msg) {
4039
- var _msg_functionCalls;
4040
- var _msg_functionCalls_map;
4041
- parts2 = (_msg_functionCalls_map = (_msg_functionCalls = msg.functionCalls) === null || _msg_functionCalls === void 0 ? void 0 : _msg_functionCalls.map(function(f) {
4026
+ var parts1 = [];
4027
+ if (msg.functionCalls) {
4028
+ parts1 = msg.functionCalls.map(function(f) {
4042
4029
  var args = typeof f.function.params === "string" ? JSON.parse(f.function.params) : f.function.params;
4043
4030
  return {
4044
4031
  functionCall: {
@@ -4046,11 +4033,26 @@ var safetySettings = [
4046
4033
  args: args
4047
4034
  }
4048
4035
  };
4049
- })) !== null && _msg_functionCalls_map !== void 0 ? _msg_functionCalls_map : [];
4036
+ });
4037
+ if (!parts1) {
4038
+ throw new Error("Function call is empty");
4039
+ }
4040
+ return {
4041
+ role: "model",
4042
+ parts: parts1
4043
+ };
4044
+ }
4045
+ if (!msg.content) {
4046
+ throw new Error("Assistant content is empty");
4050
4047
  }
4048
+ parts1 = [
4049
+ {
4050
+ text: msg.content
4051
+ }
4052
+ ];
4051
4053
  return {
4052
4054
  role: "model",
4053
- parts: parts2
4055
+ parts: parts1
4054
4056
  };
4055
4057
  }
4056
4058
  case "function":
@@ -4058,7 +4060,7 @@ var safetySettings = [
4058
4060
  if (!("functionId" in msg)) {
4059
4061
  throw new Error("Chat prompt functionId is empty (index: ".concat(i, ")"));
4060
4062
  }
4061
- var parts3 = [
4063
+ var parts2 = [
4062
4064
  {
4063
4065
  functionResponse: {
4064
4066
  name: msg.functionId,
@@ -4070,7 +4072,7 @@ var safetySettings = [
4070
4072
  ];
4071
4073
  return {
4072
4074
  role: "function",
4073
- parts: parts3
4075
+ parts: parts2
4074
4076
  };
4075
4077
  }
4076
4078
  default:
@@ -4080,12 +4082,12 @@ var safetySettings = [
4080
4082
  var tools = [];
4081
4083
  if (req.functions && req.functions.length > 0) {
4082
4084
  tools.push({
4083
- functionDeclarations: req.functions
4085
+ function_declarations: req.functions
4084
4086
  });
4085
4087
  }
4086
4088
  if ((_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.codeExecution) {
4087
4089
  tools.push({
4088
- codeExecution: {}
4090
+ code_execution: {}
4089
4091
  });
4090
4092
  }
4091
4093
  if (tools.length === 0) {
@@ -4192,6 +4194,9 @@ var safetySettings = [
4192
4194
  case "RECITATION":
4193
4195
  throw new Error("Finish reason: RECITATION");
4194
4196
  }
4197
+ if (!candidate.content.parts) {
4198
+ return result;
4199
+ }
4195
4200
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4196
4201
  try {
4197
4202
  for(var _iterator = candidate.content.parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -4325,7 +4330,7 @@ var axModelInfoAnthropic = [
4325
4330
  }
4326
4331
  ];
4327
4332
 
4328
- function _array_like_to_array$8(arr, len) {
4333
+ function _array_like_to_array$9(arr, len) {
4329
4334
  if (len == null || len > arr.length) len = arr.length;
4330
4335
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4331
4336
  return arr2;
@@ -4432,7 +4437,7 @@ function _object_spread$b(target) {
4432
4437
  }
4433
4438
  return target;
4434
4439
  }
4435
- function ownKeys$5(object, enumerableOnly) {
4440
+ function ownKeys$6(object, enumerableOnly) {
4436
4441
  var keys = Object.keys(object);
4437
4442
  if (Object.getOwnPropertySymbols) {
4438
4443
  var symbols = Object.getOwnPropertySymbols(object);
@@ -4445,12 +4450,12 @@ function ownKeys$5(object, enumerableOnly) {
4445
4450
  }
4446
4451
  return keys;
4447
4452
  }
4448
- function _object_spread_props$5(target, source) {
4453
+ function _object_spread_props$6(target, source) {
4449
4454
  source = source != null ? source : {};
4450
4455
  if (Object.getOwnPropertyDescriptors) {
4451
4456
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4452
4457
  } else {
4453
- ownKeys$5(Object(source)).forEach(function(key) {
4458
+ ownKeys$6(Object(source)).forEach(function(key) {
4454
4459
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4455
4460
  });
4456
4461
  }
@@ -4470,19 +4475,19 @@ function _set_prototype_of$a(o, p) {
4470
4475
  return _set_prototype_of$a(o, p);
4471
4476
  }
4472
4477
  function _sliced_to_array$3(arr, i) {
4473
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$8(arr, i) || _non_iterable_rest$3();
4478
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$3();
4474
4479
  }
4475
4480
  function _type_of$b(obj) {
4476
4481
  "@swc/helpers - typeof";
4477
4482
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4478
4483
  }
4479
- function _unsupported_iterable_to_array$8(o, minLen) {
4484
+ function _unsupported_iterable_to_array$9(o, minLen) {
4480
4485
  if (!o) return;
4481
- if (typeof o === "string") return _array_like_to_array$8(o, minLen);
4486
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
4482
4487
  var n = Object.prototype.toString.call(o).slice(8, -1);
4483
4488
  if (n === "Object" && o.constructor) n = o.constructor.name;
4484
4489
  if (n === "Map" || n === "Set") return Array.from(n);
4485
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
4490
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
4486
4491
  }
4487
4492
  function _is_native_reflect_construct$a() {
4488
4493
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
@@ -4576,7 +4581,7 @@ var AxAIAnthropic = /*#__PURE__*/ function(AxBaseAI) {
4576
4581
  var _req_modelConfig_stream;
4577
4582
  var stream = (_req_modelConfig_stream = (_req_modelConfig = req.modelConfig) === null || _req_modelConfig === void 0 ? void 0 : _req_modelConfig.stream) !== null && _req_modelConfig_stream !== void 0 ? _req_modelConfig_stream : _this.config.stream;
4578
4583
  var _req_modelConfig_maxTokens, _req_modelConfig_stopSequences, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK;
4579
- var reqValue = _object_spread_props$5(_object_spread$b({
4584
+ var reqValue = _object_spread_props$6(_object_spread$b({
4580
4585
  model: model,
4581
4586
  max_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
4582
4587
  stop_sequences: (_req_modelConfig_stopSequences = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences,
@@ -5334,7 +5339,7 @@ function _object_spread$a(target) {
5334
5339
  }
5335
5340
  return target;
5336
5341
  }
5337
- function ownKeys$4(object, enumerableOnly) {
5342
+ function ownKeys$5(object, enumerableOnly) {
5338
5343
  var keys = Object.keys(object);
5339
5344
  if (Object.getOwnPropertySymbols) {
5340
5345
  var symbols = Object.getOwnPropertySymbols(object);
@@ -5347,12 +5352,12 @@ function ownKeys$4(object, enumerableOnly) {
5347
5352
  }
5348
5353
  return keys;
5349
5354
  }
5350
- function _object_spread_props$4(target, source) {
5355
+ function _object_spread_props$5(target, source) {
5351
5356
  source = source != null ? source : {};
5352
5357
  if (Object.getOwnPropertyDescriptors) {
5353
5358
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
5354
5359
  } else {
5355
- ownKeys$4(Object(source)).forEach(function(key) {
5360
+ ownKeys$5(Object(source)).forEach(function(key) {
5356
5361
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
5357
5362
  });
5358
5363
  }
@@ -5517,7 +5522,7 @@ var AxAIGroq = /*#__PURE__*/ function(AxAIOpenAI) {
5517
5522
  throw new Error("Groq API key not set");
5518
5523
  }
5519
5524
  var _config = _object_spread$a({}, axAIGroqDefaultConfig(), config);
5520
- var _options = _object_spread_props$4(_object_spread$a({}, options), {
5525
+ var _options = _object_spread_props$5(_object_spread$a({}, options), {
5521
5526
  streamingUsage: false
5522
5527
  });
5523
5528
  _this = _super.call(this, {
@@ -5530,7 +5535,7 @@ var AxAIGroq = /*#__PURE__*/ function(AxAIOpenAI) {
5530
5535
  });
5531
5536
  _define_property$i(_assert_this_initialized$9(_this), "setOptions", function(options) {
5532
5537
  var rateLimiter = _this.newRateLimiter(options);
5533
- _get$3((_assert_this_initialized$9(_this), _get_prototype_of$9(AxAIGroq.prototype)), "setOptions", _this).call(_this, _object_spread_props$4(_object_spread$a({}, options), {
5538
+ _get$3((_assert_this_initialized$9(_this), _get_prototype_of$9(AxAIGroq.prototype)), "setOptions", _this).call(_this, _object_spread_props$5(_object_spread$a({}, options), {
5534
5539
  rateLimiter: rateLimiter
5535
5540
  }));
5536
5541
  });
@@ -6053,7 +6058,7 @@ function _object_spread$7(target) {
6053
6058
  }
6054
6059
  return target;
6055
6060
  }
6056
- function ownKeys$3(object, enumerableOnly) {
6061
+ function ownKeys$4(object, enumerableOnly) {
6057
6062
  var keys = Object.keys(object);
6058
6063
  if (Object.getOwnPropertySymbols) {
6059
6064
  var symbols = Object.getOwnPropertySymbols(object);
@@ -6066,12 +6071,12 @@ function ownKeys$3(object, enumerableOnly) {
6066
6071
  }
6067
6072
  return keys;
6068
6073
  }
6069
- function _object_spread_props$3(target, source) {
6074
+ function _object_spread_props$4(target, source) {
6070
6075
  source = source != null ? source : {};
6071
6076
  if (Object.getOwnPropertyDescriptors) {
6072
6077
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
6073
6078
  } else {
6074
- ownKeys$3(Object(source)).forEach(function(key) {
6079
+ ownKeys$4(Object(source)).forEach(function(key) {
6075
6080
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
6076
6081
  });
6077
6082
  }
@@ -6126,7 +6131,7 @@ function _create_super$6(Derived) {
6126
6131
  };
6127
6132
  }
6128
6133
  var axAIOllamaDefaultConfig = function() {
6129
- return structuredClone(_object_spread_props$3(_object_spread$7({}, axBaseAIDefaultConfig()), {
6134
+ return structuredClone(_object_spread_props$4(_object_spread$7({}, axBaseAIDefaultConfig()), {
6130
6135
  model: "nous-hermes2",
6131
6136
  embedModel: "all-minilm"
6132
6137
  }));
@@ -6814,13 +6819,13 @@ var AxAI = /*#__PURE__*/ function() {
6814
6819
  }
6815
6820
  ();
6816
6821
 
6817
- function _array_like_to_array$7(arr, len) {
6822
+ function _array_like_to_array$8(arr, len) {
6818
6823
  if (len == null || len > arr.length) len = arr.length;
6819
6824
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6820
6825
  return arr2;
6821
6826
  }
6822
- function _array_without_holes$4(arr) {
6823
- if (Array.isArray(arr)) return _array_like_to_array$7(arr);
6827
+ function _array_without_holes$5(arr) {
6828
+ if (Array.isArray(arr)) return _array_like_to_array$8(arr);
6824
6829
  }
6825
6830
  function _class_call_check$c(instance, Constructor) {
6826
6831
  if (!(instance instanceof Constructor)) {
@@ -6854,10 +6859,10 @@ function _define_property$c(obj, key, value) {
6854
6859
  }
6855
6860
  return obj;
6856
6861
  }
6857
- function _iterable_to_array$4(iter) {
6862
+ function _iterable_to_array$5(iter) {
6858
6863
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
6859
6864
  }
6860
- function _non_iterable_spread$4() {
6865
+ function _non_iterable_spread$5() {
6861
6866
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6862
6867
  }
6863
6868
  function _object_spread$5(target) {
@@ -6875,16 +6880,16 @@ function _object_spread$5(target) {
6875
6880
  }
6876
6881
  return target;
6877
6882
  }
6878
- function _to_consumable_array$4(arr) {
6879
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$4();
6883
+ function _to_consumable_array$5(arr) {
6884
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$5();
6880
6885
  }
6881
- function _unsupported_iterable_to_array$7(o, minLen) {
6886
+ function _unsupported_iterable_to_array$8(o, minLen) {
6882
6887
  if (!o) return;
6883
- if (typeof o === "string") return _array_like_to_array$7(o, minLen);
6888
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
6884
6889
  var n = Object.prototype.toString.call(o).slice(8, -1);
6885
6890
  if (n === "Object" && o.constructor) n = o.constructor.name;
6886
6891
  if (n === "Map" || n === "Set") return Array.from(n);
6887
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
6892
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
6888
6893
  }
6889
6894
  var AxMemory = /*#__PURE__*/ function() {
6890
6895
  function AxMemory() {
@@ -6906,7 +6911,7 @@ var AxMemory = /*#__PURE__*/ function() {
6906
6911
  var n = 0;
6907
6912
  if (Array.isArray(value)) {
6908
6913
  var _d;
6909
- n = (_d = d).push.apply(_d, _to_consumable_array$4(structuredClone(value)));
6914
+ n = (_d = d).push.apply(_d, _to_consumable_array$5(structuredClone(value)));
6910
6915
  } else {
6911
6916
  n = d.push(_object_spread$5({}, structuredClone(value)));
6912
6917
  }
@@ -14395,7 +14400,7 @@ moment.tz.load(require$$1);
14395
14400
 
14396
14401
  var moment$1 = momentTimezone$1.exports;
14397
14402
 
14398
- function _array_like_to_array$6(arr, len) {
14403
+ function _array_like_to_array$7(arr, len) {
14399
14404
  if (len == null || len > arr.length) len = arr.length;
14400
14405
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
14401
14406
  return arr2;
@@ -14431,15 +14436,15 @@ function _non_iterable_rest$2() {
14431
14436
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14432
14437
  }
14433
14438
  function _sliced_to_array$2(arr, i) {
14434
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$2();
14439
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$7(arr, i) || _non_iterable_rest$2();
14435
14440
  }
14436
- function _unsupported_iterable_to_array$6(o, minLen) {
14441
+ function _unsupported_iterable_to_array$7(o, minLen) {
14437
14442
  if (!o) return;
14438
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
14443
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
14439
14444
  var n = Object.prototype.toString.call(o).slice(8, -1);
14440
14445
  if (n === "Object" && o.constructor) n = o.constructor.name;
14441
14446
  if (n === "Map" || n === "Set") return Array.from(n);
14442
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
14447
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
14443
14448
  }
14444
14449
  // eslint-disable-next-line @typescript-eslint/naming-convention
14445
14450
  function parseLLMFriendlyDate(field, dateStr) {
@@ -14511,7 +14516,7 @@ var formatDateWithTimezone = function(date) {
14511
14516
  return momentDate.format("YYYY-MM-DD HH:mm:ss UTC");
14512
14517
  };
14513
14518
 
14514
- /* eslint-disable @typescript-eslint/naming-convention */ function _array_like_to_array$5(arr, len) {
14519
+ /* eslint-disable @typescript-eslint/naming-convention */ function _array_like_to_array$6(arr, len) {
14515
14520
  if (len == null || len > arr.length) len = arr.length;
14516
14521
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
14517
14522
  return arr2;
@@ -14623,19 +14628,19 @@ function _set_prototype_of$3(o, p) {
14623
14628
  return _set_prototype_of$3(o, p);
14624
14629
  }
14625
14630
  function _sliced_to_array$1(arr, i) {
14626
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$1();
14631
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$1();
14627
14632
  }
14628
14633
  function _type_of$4(obj) {
14629
14634
  "@swc/helpers - typeof";
14630
14635
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
14631
14636
  }
14632
- function _unsupported_iterable_to_array$5(o, minLen) {
14637
+ function _unsupported_iterable_to_array$6(o, minLen) {
14633
14638
  if (!o) return;
14634
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
14639
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
14635
14640
  var n = Object.prototype.toString.call(o).slice(8, -1);
14636
14641
  if (n === "Object" && o.constructor) n = o.constructor.name;
14637
14642
  if (n === "Map" || n === "Set") return Array.from(n);
14638
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
14643
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
14639
14644
  }
14640
14645
  function _wrap_native_super(Class) {
14641
14646
  var _cache = typeof Map === "function" ? new Map() : undefined;
@@ -15000,6 +15005,14 @@ try {
15000
15005
  }
15001
15006
  */
15002
15007
 
15008
+ function _array_like_to_array$5(arr, len) {
15009
+ if (len == null || len > arr.length) len = arr.length;
15010
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
15011
+ return arr2;
15012
+ }
15013
+ function _array_without_holes$4(arr) {
15014
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
15015
+ }
15003
15016
  function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
15004
15017
  try {
15005
15018
  var info = gen[key](arg);
@@ -15047,6 +15060,23 @@ function _define_property$9(obj, key, value) {
15047
15060
  }
15048
15061
  return obj;
15049
15062
  }
15063
+ function _iterable_to_array$4(iter) {
15064
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
15065
+ }
15066
+ function _non_iterable_spread$4() {
15067
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15068
+ }
15069
+ function _to_consumable_array$4(arr) {
15070
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$4();
15071
+ }
15072
+ function _unsupported_iterable_to_array$5(o, minLen) {
15073
+ if (!o) return;
15074
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
15075
+ var n = Object.prototype.toString.call(o).slice(8, -1);
15076
+ if (n === "Object" && o.constructor) n = o.constructor.name;
15077
+ if (n === "Map" || n === "Set") return Array.from(n);
15078
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
15079
+ }
15050
15080
  function _ts_generator$4(thisArg, body) {
15051
15081
  var f, y, t, g, _ = {
15052
15082
  label: 0,
@@ -15144,7 +15174,7 @@ function _ts_generator$4(thisArg, body) {
15144
15174
  }
15145
15175
  var AxFunctionProcessor = function AxFunctionProcessor(funcList) {
15146
15176
  _class_call_check$9(this, AxFunctionProcessor);
15147
- _define_property$9(this, "funcList", void 0);
15177
+ _define_property$9(this, "funcList", []);
15148
15178
  _define_property$9(this, "executeFunction", function() {
15149
15179
  var _ref = _async_to_generator$3(function(fnSpec, func, options) {
15150
15180
  var args, opt, res, _tmp, res1, _tmp1;
@@ -15268,14 +15298,121 @@ var AxFunctionProcessor = function AxFunctionProcessor(funcList) {
15268
15298
  return _ref.apply(this, arguments);
15269
15299
  };
15270
15300
  }());
15271
- funcList.filter(function(v) {
15272
- return v.parameters;
15273
- }).forEach(function(v) {
15274
- return validateJSONSchema(v.parameters);
15275
- });
15276
15301
  this.funcList = funcList;
15277
- }
15278
- ;
15302
+ };
15303
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15304
+ var parseFunctions = function(newFuncs, existingFuncs) {
15305
+ if (newFuncs.length === 0) {
15306
+ return _to_consumable_array$4(existingFuncs !== null && existingFuncs !== void 0 ? existingFuncs : []);
15307
+ }
15308
+ var functions = newFuncs.map(function(f) {
15309
+ if ("toFunction" in f) {
15310
+ return f.toFunction();
15311
+ }
15312
+ return f;
15313
+ });
15314
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
15315
+ try {
15316
+ for(var _iterator = functions.filter(function(v) {
15317
+ return v.parameters;
15318
+ })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
15319
+ var fn = _step.value;
15320
+ validateJSONSchema(fn.parameters);
15321
+ }
15322
+ } catch (err) {
15323
+ _didIteratorError = true;
15324
+ _iteratorError = err;
15325
+ } finally{
15326
+ try {
15327
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
15328
+ _iterator.return();
15329
+ }
15330
+ } finally{
15331
+ if (_didIteratorError) {
15332
+ throw _iteratorError;
15333
+ }
15334
+ }
15335
+ }
15336
+ return _to_consumable_array$4(existingFuncs !== null && existingFuncs !== void 0 ? existingFuncs : []).concat(_to_consumable_array$4(functions));
15337
+ };
15338
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15339
+ var processFunctions = function() {
15340
+ var _ref = _async_to_generator$3(function(ai, functionList, functionCalls, mem, sessionId, traceId) {
15341
+ var funcProc, promises, results;
15342
+ return _ts_generator$4(this, function(_state) {
15343
+ switch(_state.label){
15344
+ case 0:
15345
+ funcProc = new AxFunctionProcessor(functionList);
15346
+ // Map each function call to a promise that resolves to the function result or null
15347
+ promises = functionCalls.map(function(func) {
15348
+ return funcProc === null || funcProc === void 0 ? void 0 : funcProc.execute(func, {
15349
+ sessionId: sessionId,
15350
+ traceId: traceId,
15351
+ ai: ai
15352
+ }).then(function(fres) {
15353
+ if (fres === null || fres === void 0 ? void 0 : fres.id) {
15354
+ var _fres_result;
15355
+ return {
15356
+ role: "function",
15357
+ result: (_fres_result = fres.result) !== null && _fres_result !== void 0 ? _fres_result : "",
15358
+ functionId: fres.id
15359
+ };
15360
+ }
15361
+ return null; // Returning null for function calls that don't meet the condition
15362
+ });
15363
+ });
15364
+ return [
15365
+ 4,
15366
+ Promise.all(promises)
15367
+ ];
15368
+ case 1:
15369
+ results = _state.sent();
15370
+ results.forEach(function(result) {
15371
+ if (result) {
15372
+ mem.add(result, sessionId);
15373
+ }
15374
+ });
15375
+ return [
15376
+ 2
15377
+ ];
15378
+ }
15379
+ });
15380
+ });
15381
+ return function processFunctions(ai, functionList, functionCalls, mem, sessionId, traceId) {
15382
+ return _ref.apply(this, arguments);
15383
+ };
15384
+ }();
15385
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15386
+ function parseFunctionCalls(ai, functionCalls, values, model) {
15387
+ if (!functionCalls || functionCalls.length === 0) {
15388
+ return;
15389
+ }
15390
+ if (ai.getFeatures(model).functions) {
15391
+ var funcs = functionCalls.map(function(f) {
15392
+ return {
15393
+ id: f.id,
15394
+ name: f.function.name,
15395
+ args: f.function.params
15396
+ };
15397
+ });
15398
+ // for (const [i, f] of funcs.entries()) {
15399
+ // values['functionName' + i] = f.name;
15400
+ // values['functionArguments' + i] =
15401
+ // typeof f.args === 'object' ? JSON.stringify(f.args) : f.args;
15402
+ // }
15403
+ return funcs;
15404
+ } else if (values["functionName"]) {
15405
+ var functionName = values.functionName, functionArguments = values.functionArguments;
15406
+ delete values["functionName"];
15407
+ delete values["functionArguments"];
15408
+ return [
15409
+ {
15410
+ name: functionName,
15411
+ args: functionArguments
15412
+ }
15413
+ ];
15414
+ }
15415
+ }
15279
15416
 
15280
15417
  function _class_call_check$8(instance, Constructor) {
15281
15418
  if (!(instance instanceof Constructor)) {
@@ -15837,7 +15974,7 @@ function _object_spread$4(target) {
15837
15974
  }
15838
15975
  return target;
15839
15976
  }
15840
- function ownKeys$2(object, enumerableOnly) {
15977
+ function ownKeys$3(object, enumerableOnly) {
15841
15978
  var keys = Object.keys(object);
15842
15979
  if (Object.getOwnPropertySymbols) {
15843
15980
  var symbols = Object.getOwnPropertySymbols(object);
@@ -15850,12 +15987,12 @@ function ownKeys$2(object, enumerableOnly) {
15850
15987
  }
15851
15988
  return keys;
15852
15989
  }
15853
- function _object_spread_props$2(target, source) {
15990
+ function _object_spread_props$3(target, source) {
15854
15991
  source = source != null ? source : {};
15855
15992
  if (Object.getOwnPropertyDescriptors) {
15856
15993
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
15857
15994
  } else {
15858
- ownKeys$2(Object(source)).forEach(function(key) {
15995
+ ownKeys$3(Object(source)).forEach(function(key) {
15859
15996
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
15860
15997
  });
15861
15998
  }
@@ -15902,7 +16039,7 @@ var AxSignature = function AxSignature(signature) {
15902
16039
  if (field.type && (!field.type.name || field.type.name.length === 0)) {
15903
16040
  throw new Error("Field type name is required: " + field.name);
15904
16041
  }
15905
- return _object_spread_props$2(_object_spread$4({}, field), {
16042
+ return _object_spread_props$3(_object_spread$4({}, field), {
15906
16043
  title: title
15907
16044
  });
15908
16045
  });
@@ -17314,6 +17451,30 @@ function _object_spread$2(target) {
17314
17451
  }
17315
17452
  return target;
17316
17453
  }
17454
+ function ownKeys$2(object, enumerableOnly) {
17455
+ var keys = Object.keys(object);
17456
+ if (Object.getOwnPropertySymbols) {
17457
+ var symbols = Object.getOwnPropertySymbols(object);
17458
+ if (enumerableOnly) {
17459
+ symbols = symbols.filter(function(sym) {
17460
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17461
+ });
17462
+ }
17463
+ keys.push.apply(keys, symbols);
17464
+ }
17465
+ return keys;
17466
+ }
17467
+ function _object_spread_props$2(target, source) {
17468
+ source = source != null ? source : {};
17469
+ if (Object.getOwnPropertyDescriptors) {
17470
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
17471
+ } else {
17472
+ ownKeys$2(Object(source)).forEach(function(key) {
17473
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
17474
+ });
17475
+ }
17476
+ return target;
17477
+ }
17317
17478
  function _possible_constructor_return$2(self, call) {
17318
17479
  if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
17319
17480
  return call;
@@ -17456,7 +17617,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17456
17617
  function AxGen(signature, options) {
17457
17618
  _class_call_check$3(this, AxGen);
17458
17619
  var _this;
17459
- var _options_functions, _this_options, _this_options1, _this_functions;
17620
+ var _this_options, _this_options1;
17460
17621
  _this = _super.call(this, signature, {
17461
17622
  description: options === null || options === void 0 ? void 0 : options.description
17462
17623
  });
@@ -17465,8 +17626,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17465
17626
  _define_property$2(_assert_this_initialized$2(_this), "streamingAsserts", void 0);
17466
17627
  _define_property$2(_assert_this_initialized$2(_this), "options", void 0);
17467
17628
  _define_property$2(_assert_this_initialized$2(_this), "functions", void 0);
17468
- _define_property$2(_assert_this_initialized$2(_this), "funcProc", void 0);
17469
- _define_property$2(_assert_this_initialized$2(_this), "functionList", void 0);
17470
17629
  _define_property$2(_assert_this_initialized$2(_this), "updateSigForFunctions", function(ai, model) {
17471
17630
  // AI supports function calling natively so
17472
17631
  // no need to add fields for function call
@@ -17502,59 +17661,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17502
17661
  optional: optional
17503
17662
  });
17504
17663
  });
17505
- var _this1 = _assert_this_initialized$2(_this);
17506
- _define_property$2(_assert_this_initialized$2(_this), "processFunctions", function() {
17507
- var _ref = _async_to_generator$1(function(ai, functionCalls, mem, sessionId, traceId) {
17508
- var promises, results;
17509
- return _ts_generator$1(this, function(_state) {
17510
- switch(_state.label){
17511
- case 0:
17512
- // Map each function call to a promise that resolves to the function result or null
17513
- promises = functionCalls.map(function(func) {
17514
- var _this_funcProc;
17515
- return (_this_funcProc = _this1.funcProc) === null || _this_funcProc === void 0 ? void 0 : _this_funcProc.execute(func, {
17516
- sessionId: sessionId,
17517
- traceId: traceId,
17518
- ai: ai
17519
- }).then(function(fres) {
17520
- if (fres === null || fres === void 0 ? void 0 : fres.id) {
17521
- var _fres_result;
17522
- return {
17523
- role: "function",
17524
- result: (_fres_result = fres.result) !== null && _fres_result !== void 0 ? _fres_result : "",
17525
- functionId: fres.id
17526
- };
17527
- }
17528
- return null; // Returning null for function calls that don't meet the condition
17529
- });
17530
- });
17531
- return [
17532
- 4,
17533
- Promise.all(promises)
17534
- ];
17535
- case 1:
17536
- results = _state.sent();
17537
- results.forEach(function(result) {
17538
- if (result) {
17539
- mem.add(result, sessionId);
17540
- }
17541
- });
17542
- return [
17543
- 2
17544
- ];
17545
- }
17546
- });
17547
- });
17548
- return function(ai, functionCalls, mem, sessionId, traceId) {
17549
- return _ref.apply(this, arguments);
17550
- };
17551
- }());
17552
- _this.functions = options === null || options === void 0 ? void 0 : (_options_functions = options.functions) === null || _options_functions === void 0 ? void 0 : _options_functions.map(function(f) {
17553
- if ("toFunction" in f) {
17554
- return f.toFunction();
17555
- }
17556
- return f;
17557
- });
17558
17664
  _this.options = options;
17559
17665
  var _options_promptTemplate;
17560
17666
  _this.pt = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature);
@@ -17562,12 +17668,9 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17562
17668
  _this.asserts = (_this_options_asserts = (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.asserts) !== null && _this_options_asserts !== void 0 ? _this_options_asserts : [];
17563
17669
  var _this_options_streamingAsserts;
17564
17670
  _this.streamingAsserts = (_this_options_streamingAsserts = (_this_options1 = _this.options) === null || _this_options1 === void 0 ? void 0 : _this_options1.streamingAsserts) !== null && _this_options_streamingAsserts !== void 0 ? _this_options_streamingAsserts : [];
17565
- _this.functionList = (_this_functions = _this.functions) === null || _this_functions === void 0 ? void 0 : _this_functions.map(function(f) {
17566
- return f.name;
17567
- }).join(", ");
17568
17671
  _this.usage = [];
17569
- if (_this.functions) {
17570
- _this.funcProc = new AxFunctionProcessor(_this.functions);
17672
+ if (options === null || options === void 0 ? void 0 : options.functions) {
17673
+ _this.functions = parseFunctions(options.functions);
17571
17674
  }
17572
17675
  return _this;
17573
17676
  }
@@ -17575,10 +17678,10 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17575
17678
  {
17576
17679
  key: "forwardSendRequest",
17577
17680
  value: function forwardSendRequest(param) {
17578
- var mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, ai = param.ai, mc = param.modelConfig, stream = param.stream, model = param.model, rateLimiter = param.rateLimiter;
17681
+ var mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, ai = param.ai, mc = param.modelConfig, stream = param.stream, model = param.model, rateLimiter = param.rateLimiter, functions = param.functions;
17579
17682
  var _this = this;
17580
17683
  return _async_to_generator$1(function() {
17581
- var _this_options, _mem_history, chatPrompt, functions, functionCall, hasJSON, modelConfig, res;
17684
+ var _this_options, _mem_history, chatPrompt, functionCall, hasJSON, modelConfig, res;
17582
17685
  return _ts_generator$1(this, function(_state) {
17583
17686
  switch(_state.label){
17584
17687
  case 0:
@@ -17586,7 +17689,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17586
17689
  if (chatPrompt.length === 0) {
17587
17690
  throw new Error("No chat prompt found");
17588
17691
  }
17589
- functions = _this.functions;
17590
17692
  functionCall = (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.functionCall;
17591
17693
  hasJSON = _this.signature.getOutputFields().some(function(f) {
17592
17694
  var _f_type, _f_type1;
@@ -17624,7 +17726,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17624
17726
  {
17625
17727
  key: "forwardCore",
17626
17728
  value: function forwardCore(param) {
17627
- var sig = param.sig, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, ai = param.ai, modelConfig = param.modelConfig, model = param.model, rateLimiter = param.rateLimiter, _param_stream = param.stream, stream = _param_stream === void 0 ? false : _param_stream;
17729
+ var sig = param.sig, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, ai = param.ai, modelConfig = param.modelConfig, model = param.model, rateLimiter = param.rateLimiter, _param_stream = param.stream, stream = _param_stream === void 0 ? false : _param_stream, functions = param.functions;
17628
17730
  var _this = this;
17629
17731
  return _async_to_generator$1(function() {
17630
17732
  var usageInfo, res;
@@ -17645,7 +17747,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17645
17747
  stream: stream,
17646
17748
  modelConfig: modelConfig,
17647
17749
  model: model,
17648
- rateLimiter: rateLimiter
17750
+ rateLimiter: rateLimiter,
17751
+ functions: functions
17649
17752
  })
17650
17753
  ];
17651
17754
  case 1:
@@ -17664,7 +17767,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17664
17767
  usageInfo: usageInfo,
17665
17768
  mem: mem,
17666
17769
  traceId: traceId,
17667
- sessionId: sessionId
17770
+ sessionId: sessionId,
17771
+ functions: functions
17668
17772
  })
17669
17773
  ];
17670
17774
  case 2:
@@ -17683,7 +17787,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17683
17787
  usageInfo: usageInfo,
17684
17788
  mem: mem,
17685
17789
  traceId: traceId,
17686
- sessionId: sessionId
17790
+ sessionId: sessionId,
17791
+ functions: functions
17687
17792
  })
17688
17793
  ];
17689
17794
  case 4:
@@ -17699,7 +17804,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17699
17804
  {
17700
17805
  key: "processSteamingResponse",
17701
17806
  value: function processSteamingResponse(param) {
17702
- var ai = param.ai, sig = param.sig, model = param.model, res = param.res, usageInfo = param.usageInfo, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId;
17807
+ var ai = param.ai, sig = param.sig, model = param.model, res = param.res, usageInfo = param.usageInfo, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, functions = param.functions;
17703
17808
  var _this = this;
17704
17809
  return _async_to_generator$1(function() {
17705
17810
  var functionCalls, values, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, _v_results, _iteratorNormalCompletion, _didIteratorError1, _iteratorError1, _iterator1, _step1, result, err, funcs;
@@ -17833,14 +17938,17 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17833
17938
  7
17834
17939
  ];
17835
17940
  case 12:
17836
- funcs = parseFunctions(ai, functionCalls, values, model);
17941
+ funcs = parseFunctionCalls(ai, functionCalls, values, model);
17837
17942
  if (!funcs) return [
17838
17943
  3,
17839
17944
  14
17840
17945
  ];
17946
+ if (!functions) {
17947
+ throw new Error("Functions are not defined");
17948
+ }
17841
17949
  return [
17842
17950
  4,
17843
- _this.processFunctions(ai, funcs, mem, sessionId, traceId)
17951
+ processFunctions(ai, functions, funcs, mem, sessionId, traceId)
17844
17952
  ];
17845
17953
  case 13:
17846
17954
  _state.sent();
@@ -17860,7 +17968,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17860
17968
  {
17861
17969
  key: "processResponse",
17862
17970
  value: function processResponse(param) {
17863
- var ai = param.ai, res = param.res, usageInfo = param.usageInfo, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId;
17971
+ var ai = param.ai, res = param.res, usageInfo = param.usageInfo, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, functions = param.functions;
17864
17972
  var _this = this;
17865
17973
  return _async_to_generator$1(function() {
17866
17974
  var values, _res_results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, funcs, err;
@@ -17897,14 +18005,17 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
17897
18005
  3,
17898
18006
  4
17899
18007
  ];
17900
- funcs = parseFunctions(ai, result.functionCalls, values);
18008
+ funcs = parseFunctionCalls(ai, result.functionCalls, values);
17901
18009
  if (!funcs) return [
17902
18010
  3,
17903
18011
  4
17904
18012
  ];
18013
+ if (!functions) {
18014
+ throw new Error("Functions are not defined");
18015
+ }
17905
18016
  return [
17906
18017
  4,
17907
- _this.processFunctions(ai, funcs, mem, sessionId, traceId)
18018
+ processFunctions(ai, functions, funcs, mem, sessionId, traceId)
17908
18019
  ];
17909
18020
  case 3:
17910
18021
  _state.sent();
@@ -18012,7 +18123,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
18012
18123
  model: options === null || options === void 0 ? void 0 : options.model,
18013
18124
  stream: canStream && (options === null || options === void 0 ? void 0 : options.stream),
18014
18125
  maxSteps: options === null || options === void 0 ? void 0 : options.maxSteps,
18015
- rateLimiter: options === null || options === void 0 ? void 0 : options.rateLimiter
18126
+ rateLimiter: options === null || options === void 0 ? void 0 : options.rateLimiter,
18127
+ functions: options === null || options === void 0 ? void 0 : options.functions
18016
18128
  })
18017
18129
  ];
18018
18130
  case 4:
@@ -18090,19 +18202,25 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
18090
18202
  value: function forward(ai, values, options) {
18091
18203
  var _this = this;
18092
18204
  return _async_to_generator$1(function() {
18093
- var _this_options, _this_updateSigForFunctions, sig, _this_options_tracer, tracer, _this_functionList, _obj, attributes;
18205
+ var _this_options, _this_updateSigForFunctions, sig, _this_options_tracer, tracer, functions, funcNames, _obj, attributes;
18094
18206
  return _ts_generator$1(this, function(_state) {
18095
18207
  switch(_state.label){
18096
18208
  case 0:
18097
18209
  sig = (_this_updateSigForFunctions = _this.updateSigForFunctions(ai, options === null || options === void 0 ? void 0 : options.model)) !== null && _this_updateSigForFunctions !== void 0 ? _this_updateSigForFunctions : _this.signature;
18098
18210
  tracer = (_this_options_tracer = (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.tracer) !== null && _this_options_tracer !== void 0 ? _this_options_tracer : options === null || options === void 0 ? void 0 : options.tracer;
18211
+ functions = _this.functions;
18212
+ if (options === null || options === void 0 ? void 0 : options.functions) {
18213
+ functions = parseFunctions(options.functions, _this.functions);
18214
+ }
18099
18215
  if (!!tracer) return [
18100
18216
  3,
18101
18217
  2
18102
18218
  ];
18103
18219
  return [
18104
18220
  4,
18105
- _this._forward(ai, sig, values, options)
18221
+ _this._forward(ai, sig, values, _object_spread_props$2(_object_spread$2({}, options), {
18222
+ functions: functions
18223
+ }))
18106
18224
  ];
18107
18225
  case 1:
18108
18226
  return [
@@ -18110,7 +18228,10 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
18110
18228
  _state.sent()
18111
18229
  ];
18112
18230
  case 2:
18113
- attributes = (_obj = {}, _define_property$2(_obj, "generate.signature", sig.toString()), _define_property$2(_obj, "generate.functions", (_this_functionList = _this.functionList) !== null && _this_functionList !== void 0 ? _this_functionList : "none"), _obj);
18231
+ funcNames = functions === null || functions === void 0 ? void 0 : functions.map(function(f) {
18232
+ return f.name;
18233
+ }).join(",");
18234
+ attributes = (_obj = {}, _define_property$2(_obj, "generate.signature", sig.toString()), _define_property$2(_obj, "generate.functions", funcNames !== null && funcNames !== void 0 ? funcNames : ""), _obj);
18114
18235
  return [
18115
18236
  4,
18116
18237
  tracer.startActiveSpan("Generate", {
@@ -18145,37 +18266,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
18145
18266
  }
18146
18267
  ]);
18147
18268
  return AxGen;
18148
- }(AxProgramWithSignature);
18149
- function parseFunctions(ai, functionCalls, values, model) {
18150
- if (!functionCalls || functionCalls.length === 0) {
18151
- return;
18152
- }
18153
- if (ai.getFeatures(model).functions) {
18154
- var funcs = functionCalls.map(function(f) {
18155
- return {
18156
- id: f.id,
18157
- name: f.function.name,
18158
- args: f.function.params
18159
- };
18160
- });
18161
- // for (const [i, f] of funcs.entries()) {
18162
- // values['functionName' + i] = f.name;
18163
- // values['functionArguments' + i] =
18164
- // typeof f.args === 'object' ? JSON.stringify(f.args) : f.args;
18165
- // }
18166
- return funcs;
18167
- } else if (values["functionName"]) {
18168
- var functionName = values.functionName, functionArguments = values.functionArguments;
18169
- delete values["functionName"];
18170
- delete values["functionArguments"];
18171
- return [
18172
- {
18173
- name: functionName,
18174
- args: functionArguments
18175
- }
18176
- ];
18177
- }
18178
- }
18269
+ }
18270
+ (AxProgramWithSignature);
18179
18271
 
18180
18272
  function _array_like_to_array$1(arr, len) {
18181
18273
  if (len == null || len > arr.length) len = arr.length;