@digipair/skill-dsp 0.72.9 → 0.73.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.js CHANGED
@@ -114935,10 +114935,10 @@ var apiCall = function() {
114935
114935
  timeoutMs = (_api_timeout = api.timeout) !== null && _api_timeout !== void 0 ? _api_timeout : defaultTimeoutMs;
114936
114936
  metrics = createRequestMetrics();
114937
114937
  baseUrl = new URL((_process_env_PROXY = process.env["PROXY"]) !== null && _process_env_PROXY !== void 0 ? _process_env_PROXY : api.url);
114938
- apiPath = [
114938
+ apiPath = "".concat([
114939
114939
  baseUrl.pathname,
114940
114940
  api.name
114941
- ].filter(Boolean).join("/").replace(/\/+/g, "/");
114941
+ ].filter(Boolean).join("/").replace(/\/+/g, "/")).concat(baseUrl.search);
114942
114942
  apiUrl = new URL(apiPath, baseUrl);
114943
114943
  requestId = crypto.randomUUID();
114944
114944
  if (!api.validateRequest) return [
@@ -120415,16 +120415,36 @@ var validateValue = function(field, value) {
120415
120415
  };
120416
120416
  function mergeProgramUsage(usages) {
120417
120417
  var usageMap = {};
120418
- usages.forEach(function(usage) {
120419
- var key = "".concat(usage.ai, ":").concat(usage.model);
120420
- if (!usageMap[key]) {
120421
- usageMap[key] = _object_spread({}, usage);
120422
- return;
120418
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
120419
+ try {
120420
+ for(var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
120421
+ var usage = _step.value;
120422
+ var key = "".concat(usage.ai, ":").concat(usage.model);
120423
+ if (!usageMap[key]) {
120424
+ usageMap[key] = _object_spread({}, usage);
120425
+ continue;
120426
+ }
120427
+ var currentUsage = usageMap[key];
120428
+ if (currentUsage) {
120429
+ currentUsage.promptTokens += usage.promptTokens;
120430
+ currentUsage.completionTokens += usage.completionTokens;
120431
+ currentUsage.totalTokens += usage.totalTokens;
120432
+ }
120423
120433
  }
120424
- usageMap[key].promptTokens += usage.promptTokens;
120425
- usageMap[key].completionTokens += usage.completionTokens;
120426
- usageMap[key].totalTokens += usage.totalTokens;
120427
- });
120434
+ } catch (err) {
120435
+ _didIteratorError = true;
120436
+ _iteratorError = err;
120437
+ } finally{
120438
+ try {
120439
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
120440
+ _iterator.return();
120441
+ }
120442
+ } finally{
120443
+ if (_didIteratorError) {
120444
+ throw _iteratorError;
120445
+ }
120446
+ }
120447
+ }
120428
120448
  return Object.values(usageMap);
120429
120449
  }
120430
120450
  var parseMarkdownList = function(input) {
@@ -120451,9 +120471,7 @@ var parseMarkdownList = function(input) {
120451
120471
  list.push(trimmedLine.slice(1).trim());
120452
120472
  } else if (numberedListRegex.test(trimmedLine)) {
120453
120473
  list.push(trimmedLine.replace(numberedListRegex, "").trim());
120454
- } else if (list.length === 0) {
120455
- continue;
120456
- } else {
120474
+ } else if (list.length === 0) {} else {
120457
120475
  throw new Error("Could not parse markdown list: mixed content detected");
120458
120476
  }
120459
120477
  }
@@ -120570,7 +120588,7 @@ function matchesContent(content, prefix) {
120570
120588
  var contentEnd = content.slice(Math.max(startIndex, content.length - prefix.length));
120571
120589
  for(var i = 0; i < prefixes.length - 1; i++){
120572
120590
  var partialPrefix = prefixes[i];
120573
- if (contentEnd.endsWith(partialPrefix)) {
120591
+ if (partialPrefix && contentEnd.endsWith(partialPrefix)) {
120574
120592
  return -2;
120575
120593
  }
120576
120594
  }
@@ -120887,7 +120905,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
120887
120905
  var renderedExamples = examples ? [
120888
120906
  {
120889
120907
  type: "text",
120890
- text: "## Examples:\n"
120908
+ text: "\n\n## Examples\n"
120891
120909
  }
120892
120910
  ].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
120893
120911
  var renderedDemos = demos ? _this.renderDemos(demos) : [];
@@ -120982,6 +121000,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
120982
121000
  try {
120983
121001
  var _loop = function() {
120984
121002
  var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
121003
+ var _renderedItem_;
120985
121004
  var renderedInputItem = _this.sig.getInputFields().map(function(field) {
120986
121005
  return _this.renderInField(field, item, true);
120987
121006
  }).filter(function(v) {
@@ -120996,6 +121015,12 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
120996
121015
  throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
120997
121016
  }
120998
121017
  var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
121018
+ if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
121019
+ list.push({
121020
+ type: "text",
121021
+ text: "---\n\n"
121022
+ });
121023
+ }
120999
121024
  renderedItem.forEach(function(v) {
121000
121025
  if ("text" in v) {
121001
121026
  v.text = v.text + "\n";
@@ -121278,10 +121303,7 @@ var processValue = function(field, value) {
121278
121303
  if (typeof value === "string") {
121279
121304
  return value;
121280
121305
  }
121281
- if (Array.isArray(value)) {
121282
- return value;
121283
- }
121284
- return JSON.stringify(value);
121306
+ return JSON.stringify(value, null, 2);
121285
121307
  };
121286
121308
  var toFieldType = function(type) {
121287
121309
  var baseType = function() {
@@ -122775,6 +122797,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
122775
122797
  delta: result.content
122776
122798
  }, sessionId);
122777
122799
  skip = streamingExtractValues(_this.signature, values, xstate, content, streamingValidation);
122800
+ if (skip) {
122801
+ return [
122802
+ 3,
122803
+ 12
122804
+ ];
122805
+ }
122778
122806
  if (!(_this.streamingAsserts.length !== 0)) return [
122779
122807
  3,
122780
122808
  6
@@ -122805,12 +122833,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
122805
122833
  ];
122806
122834
  case 9:
122807
122835
  _state.sent();
122808
- if (skip) {
122809
- return [
122810
- 3,
122811
- 12
122812
- ];
122813
- }
122814
122836
  return [
122815
122837
  4,
122816
122838
  _await_async_generator(assertAssertions(_this.asserts, values))
@@ -124417,6 +124439,30 @@ let DspService = class DspService {
124417
124439
  }), `${context.__PATH__}.functions[${i}]`)
124418
124440
  })));
124419
124441
  }
124442
+ mergeDeltas(base, delta) {
124443
+ for (const key of Object.keys(delta)){
124444
+ const baseValue = base[key];
124445
+ const deltaValue = delta[key];
124446
+ if (baseValue === undefined && Array.isArray(deltaValue)) {
124447
+ base[key] = [
124448
+ ...deltaValue
124449
+ ];
124450
+ } else if (Array.isArray(baseValue) && Array.isArray(deltaValue)) {
124451
+ // Concatenate arrays
124452
+ base[key] = [
124453
+ ...baseValue != null ? baseValue : [],
124454
+ ...deltaValue
124455
+ ];
124456
+ } else if ((baseValue === undefined || typeof baseValue === 'string') && typeof deltaValue === 'string') {
124457
+ // Concatenate strings
124458
+ base[key] = (baseValue != null ? baseValue : '') + deltaValue;
124459
+ } else {
124460
+ // For all other types, overwrite with the new value
124461
+ base[key] = deltaValue;
124462
+ }
124463
+ }
124464
+ return base;
124465
+ }
124420
124466
  async model(params, _pinsSettingsList, _context) {
124421
124467
  const { name, options } = params;
124422
124468
  const modelInstance = new AxAI(_extends({
@@ -124463,12 +124509,25 @@ let DspService = class DspService {
124463
124509
  return modelInstance;
124464
124510
  }
124465
124511
  async generate(params, _pinsSettingsList, context) {
124466
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
124512
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
124467
124513
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124468
124514
  const gen = new AxGen(signature, {
124469
124515
  functions: await this.prepareFunctions(functions, context)
124470
124516
  });
124471
- const result = await gen.forward(modelInstance, input, options);
124517
+ const generator = gen.streamingForward(modelInstance, input, options);
124518
+ let buffer = {};
124519
+ let currentVersion = 0;
124520
+ for await (const item of generator){
124521
+ if (streaming) {
124522
+ await engine.executePinsList(streaming, context, `${context.__PATH__}.streaming`);
124523
+ }
124524
+ if (item.version !== currentVersion) {
124525
+ buffer = {};
124526
+ }
124527
+ currentVersion = item.version;
124528
+ buffer = this.mergeDeltas(buffer, item.delta);
124529
+ }
124530
+ const result = buffer;
124472
124531
  var _modelInstance_ia;
124473
124532
  // add comsumption
124474
124533
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124478,12 +124537,25 @@ let DspService = class DspService {
124478
124537
  return result;
124479
124538
  }
124480
124539
  async chainOfThought(params, _pinsSettingsList, context) {
124481
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
124540
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
124482
124541
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124483
124542
  const gen = new AxChainOfThought(signature, {
124484
124543
  functions: await this.prepareFunctions(functions, context)
124485
124544
  });
124486
- const result = await gen.forward(modelInstance, input, options);
124545
+ const generator = gen.streamingForward(modelInstance, input, options);
124546
+ let buffer = {};
124547
+ let currentVersion = 0;
124548
+ for await (const item of generator){
124549
+ if (streaming) {
124550
+ await engine.executePinsList(streaming, context, `${context.__PATH__}.streaming`);
124551
+ }
124552
+ if (item.version !== currentVersion) {
124553
+ buffer = {};
124554
+ }
124555
+ currentVersion = item.version;
124556
+ buffer = this.mergeDeltas(buffer, item.delta);
124557
+ }
124558
+ const result = buffer;
124487
124559
  var _modelInstance_ia;
124488
124560
  // add comsumption
124489
124561
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124493,7 +124565,7 @@ let DspService = class DspService {
124493
124565
  return result;
124494
124566
  }
124495
124567
  async agent(params, _pinsSettingsList, context) {
124496
- const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, name, description, signature, input } = params;
124568
+ const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, streaming, name, description, signature, input } = params;
124497
124569
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124498
124570
  const agent = new AxAgent({
124499
124571
  name,
@@ -124511,7 +124583,20 @@ let DspService = class DspService {
124511
124583
  if (!forward) {
124512
124584
  return agent;
124513
124585
  }
124514
- const result = await agent.forward(modelInstance, input, options);
124586
+ const generator = agent.streamingForward(modelInstance, input, options);
124587
+ let buffer = {};
124588
+ let currentVersion = 0;
124589
+ for await (const item of generator){
124590
+ if (streaming) {
124591
+ await engine.executePinsList(streaming, context, `${context.__PATH__}.streaming`);
124592
+ }
124593
+ if (item.version !== currentVersion) {
124594
+ buffer = {};
124595
+ }
124596
+ currentVersion = item.version;
124597
+ buffer = this.mergeDeltas(buffer, item.delta);
124598
+ }
124599
+ const result = buffer;
124515
124600
  var _modelInstance_ia;
124516
124601
  // add comsumption
124517
124602
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
package/index.esm.js CHANGED
@@ -142874,10 +142874,10 @@ var apiCall = function() {
142874
142874
  timeoutMs = (_api_timeout = api.timeout) !== null && _api_timeout !== void 0 ? _api_timeout : defaultTimeoutMs;
142875
142875
  metrics = createRequestMetrics();
142876
142876
  baseUrl = new URL((_process_env_PROXY = process.env["PROXY"]) !== null && _process_env_PROXY !== void 0 ? _process_env_PROXY : api.url);
142877
- apiPath = [
142877
+ apiPath = "".concat([
142878
142878
  baseUrl.pathname,
142879
142879
  api.name
142880
- ].filter(Boolean).join("/").replace(/\/+/g, "/");
142880
+ ].filter(Boolean).join("/").replace(/\/+/g, "/")).concat(baseUrl.search);
142881
142881
  apiUrl = new URL(apiPath, baseUrl);
142882
142882
  requestId = crypto.randomUUID();
142883
142883
  if (!api.validateRequest) return [
@@ -148354,16 +148354,36 @@ var validateValue = function(field, value) {
148354
148354
  };
148355
148355
  function mergeProgramUsage(usages) {
148356
148356
  var usageMap = {};
148357
- usages.forEach(function(usage) {
148358
- var key = "".concat(usage.ai, ":").concat(usage.model);
148359
- if (!usageMap[key]) {
148360
- usageMap[key] = _object_spread({}, usage);
148361
- return;
148357
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
148358
+ try {
148359
+ for(var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
148360
+ var usage = _step.value;
148361
+ var key = "".concat(usage.ai, ":").concat(usage.model);
148362
+ if (!usageMap[key]) {
148363
+ usageMap[key] = _object_spread({}, usage);
148364
+ continue;
148365
+ }
148366
+ var currentUsage = usageMap[key];
148367
+ if (currentUsage) {
148368
+ currentUsage.promptTokens += usage.promptTokens;
148369
+ currentUsage.completionTokens += usage.completionTokens;
148370
+ currentUsage.totalTokens += usage.totalTokens;
148371
+ }
148362
148372
  }
148363
- usageMap[key].promptTokens += usage.promptTokens;
148364
- usageMap[key].completionTokens += usage.completionTokens;
148365
- usageMap[key].totalTokens += usage.totalTokens;
148366
- });
148373
+ } catch (err) {
148374
+ _didIteratorError = true;
148375
+ _iteratorError = err;
148376
+ } finally{
148377
+ try {
148378
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
148379
+ _iterator.return();
148380
+ }
148381
+ } finally{
148382
+ if (_didIteratorError) {
148383
+ throw _iteratorError;
148384
+ }
148385
+ }
148386
+ }
148367
148387
  return Object.values(usageMap);
148368
148388
  }
148369
148389
  var parseMarkdownList = function(input) {
@@ -148390,9 +148410,7 @@ var parseMarkdownList = function(input) {
148390
148410
  list.push(trimmedLine.slice(1).trim());
148391
148411
  } else if (numberedListRegex.test(trimmedLine)) {
148392
148412
  list.push(trimmedLine.replace(numberedListRegex, "").trim());
148393
- } else if (list.length === 0) {
148394
- continue;
148395
- } else {
148413
+ } else if (list.length === 0) {} else {
148396
148414
  throw new Error("Could not parse markdown list: mixed content detected");
148397
148415
  }
148398
148416
  }
@@ -148509,7 +148527,7 @@ function matchesContent(content, prefix) {
148509
148527
  var contentEnd = content.slice(Math.max(startIndex, content.length - prefix.length));
148510
148528
  for(var i = 0; i < prefixes.length - 1; i++){
148511
148529
  var partialPrefix = prefixes[i];
148512
- if (contentEnd.endsWith(partialPrefix)) {
148530
+ if (partialPrefix && contentEnd.endsWith(partialPrefix)) {
148513
148531
  return -2;
148514
148532
  }
148515
148533
  }
@@ -148826,7 +148844,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
148826
148844
  var renderedExamples = examples ? [
148827
148845
  {
148828
148846
  type: "text",
148829
- text: "## Examples:\n"
148847
+ text: "\n\n## Examples\n"
148830
148848
  }
148831
148849
  ].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
148832
148850
  var renderedDemos = demos ? _this.renderDemos(demos) : [];
@@ -148921,6 +148939,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
148921
148939
  try {
148922
148940
  var _loop = function() {
148923
148941
  var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
148942
+ var _renderedItem_;
148924
148943
  var renderedInputItem = _this.sig.getInputFields().map(function(field) {
148925
148944
  return _this.renderInField(field, item, true);
148926
148945
  }).filter(function(v) {
@@ -148935,6 +148954,12 @@ var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates)
148935
148954
  throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
148936
148955
  }
148937
148956
  var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
148957
+ if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
148958
+ list.push({
148959
+ type: "text",
148960
+ text: "---\n\n"
148961
+ });
148962
+ }
148938
148963
  renderedItem.forEach(function(v) {
148939
148964
  if ("text" in v) {
148940
148965
  v.text = v.text + "\n";
@@ -149217,10 +149242,7 @@ var processValue = function(field, value) {
149217
149242
  if (typeof value === "string") {
149218
149243
  return value;
149219
149244
  }
149220
- if (Array.isArray(value)) {
149221
- return value;
149222
- }
149223
- return JSON.stringify(value);
149245
+ return JSON.stringify(value, null, 2);
149224
149246
  };
149225
149247
  var toFieldType = function(type) {
149226
149248
  var baseType = function() {
@@ -150714,6 +150736,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
150714
150736
  delta: result.content
150715
150737
  }, sessionId);
150716
150738
  skip = streamingExtractValues(_this.signature, values, xstate, content, streamingValidation);
150739
+ if (skip) {
150740
+ return [
150741
+ 3,
150742
+ 12
150743
+ ];
150744
+ }
150717
150745
  if (!(_this.streamingAsserts.length !== 0)) return [
150718
150746
  3,
150719
150747
  6
@@ -150744,12 +150772,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
150744
150772
  ];
150745
150773
  case 9:
150746
150774
  _state.sent();
150747
- if (skip) {
150748
- return [
150749
- 3,
150750
- 12
150751
- ];
150752
- }
150753
150775
  return [
150754
150776
  4,
150755
150777
  _await_async_generator(assertAssertions(_this.asserts, values))
@@ -152356,6 +152378,30 @@ let DspService = class DspService {
152356
152378
  }), `${context.__PATH__}.functions[${i}]`)
152357
152379
  })));
152358
152380
  }
152381
+ mergeDeltas(base, delta) {
152382
+ for (const key of Object.keys(delta)){
152383
+ const baseValue = base[key];
152384
+ const deltaValue = delta[key];
152385
+ if (baseValue === undefined && Array.isArray(deltaValue)) {
152386
+ base[key] = [
152387
+ ...deltaValue
152388
+ ];
152389
+ } else if (Array.isArray(baseValue) && Array.isArray(deltaValue)) {
152390
+ // Concatenate arrays
152391
+ base[key] = [
152392
+ ...baseValue != null ? baseValue : [],
152393
+ ...deltaValue
152394
+ ];
152395
+ } else if ((baseValue === undefined || typeof baseValue === 'string') && typeof deltaValue === 'string') {
152396
+ // Concatenate strings
152397
+ base[key] = (baseValue != null ? baseValue : '') + deltaValue;
152398
+ } else {
152399
+ // For all other types, overwrite with the new value
152400
+ base[key] = deltaValue;
152401
+ }
152402
+ }
152403
+ return base;
152404
+ }
152359
152405
  async model(params, _pinsSettingsList, _context) {
152360
152406
  const { name, options } = params;
152361
152407
  const modelInstance = new AxAI(_extends({
@@ -152402,12 +152448,25 @@ let DspService = class DspService {
152402
152448
  return modelInstance;
152403
152449
  }
152404
152450
  async generate(params, _pinsSettingsList, context) {
152405
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
152451
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
152406
152452
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152407
152453
  const gen = new AxGen(signature, {
152408
152454
  functions: await this.prepareFunctions(functions, context)
152409
152455
  });
152410
- const result = await gen.forward(modelInstance, input, options);
152456
+ const generator = gen.streamingForward(modelInstance, input, options);
152457
+ let buffer = {};
152458
+ let currentVersion = 0;
152459
+ for await (const item of generator){
152460
+ if (streaming) {
152461
+ await executePinsList(streaming, context, `${context.__PATH__}.streaming`);
152462
+ }
152463
+ if (item.version !== currentVersion) {
152464
+ buffer = {};
152465
+ }
152466
+ currentVersion = item.version;
152467
+ buffer = this.mergeDeltas(buffer, item.delta);
152468
+ }
152469
+ const result = buffer;
152411
152470
  var _modelInstance_ia;
152412
152471
  // add comsumption
152413
152472
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152417,12 +152476,25 @@ let DspService = class DspService {
152417
152476
  return result;
152418
152477
  }
152419
152478
  async chainOfThought(params, _pinsSettingsList, context) {
152420
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
152479
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
152421
152480
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152422
152481
  const gen = new AxChainOfThought(signature, {
152423
152482
  functions: await this.prepareFunctions(functions, context)
152424
152483
  });
152425
- const result = await gen.forward(modelInstance, input, options);
152484
+ const generator = gen.streamingForward(modelInstance, input, options);
152485
+ let buffer = {};
152486
+ let currentVersion = 0;
152487
+ for await (const item of generator){
152488
+ if (streaming) {
152489
+ await executePinsList(streaming, context, `${context.__PATH__}.streaming`);
152490
+ }
152491
+ if (item.version !== currentVersion) {
152492
+ buffer = {};
152493
+ }
152494
+ currentVersion = item.version;
152495
+ buffer = this.mergeDeltas(buffer, item.delta);
152496
+ }
152497
+ const result = buffer;
152426
152498
  var _modelInstance_ia;
152427
152499
  // add comsumption
152428
152500
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152432,7 +152504,7 @@ let DspService = class DspService {
152432
152504
  return result;
152433
152505
  }
152434
152506
  async agent(params, _pinsSettingsList, context) {
152435
- const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, name, description, signature, input } = params;
152507
+ const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, streaming, name, description, signature, input } = params;
152436
152508
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152437
152509
  const agent = new AxAgent({
152438
152510
  name,
@@ -152450,7 +152522,20 @@ let DspService = class DspService {
152450
152522
  if (!forward) {
152451
152523
  return agent;
152452
152524
  }
152453
- const result = await agent.forward(modelInstance, input, options);
152525
+ const generator = agent.streamingForward(modelInstance, input, options);
152526
+ let buffer = {};
152527
+ let currentVersion = 0;
152528
+ for await (const item of generator){
152529
+ if (streaming) {
152530
+ await executePinsList(streaming, context, `${context.__PATH__}.streaming`);
152531
+ }
152532
+ if (item.version !== currentVersion) {
152533
+ buffer = {};
152534
+ }
152535
+ currentVersion = item.version;
152536
+ buffer = this.mergeDeltas(buffer, item.delta);
152537
+ }
152538
+ const result = buffer;
152454
152539
  var _modelInstance_ia;
152455
152540
  // add comsumption
152456
152541
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@digipair/skill-dsp",
3
- "version": "0.72.9",
3
+ "version": "0.73.0",
4
4
  "dependencies": {
5
- "@ax-llm/ax": "^9.0.28"
5
+ "@ax-llm/ax": "^11.0.29"
6
6
  },
7
7
  "main": "./index.cjs.js",
8
8
  "module": "./index.esm.js"
package/schema.fr.json CHANGED
@@ -214,6 +214,18 @@
214
214
  }
215
215
  }
216
216
  },
217
+ {
218
+ "name": "streaming",
219
+ "summary": "Streaming",
220
+ "required": false,
221
+ "description": "Evènement déclenché lors du streaming",
222
+ "schema": {
223
+ "type": "array",
224
+ "items": {
225
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
226
+ }
227
+ }
228
+ },
217
229
  {
218
230
  "name": "signature",
219
231
  "summary": "Signature",
@@ -274,6 +286,18 @@
274
286
  }
275
287
  }
276
288
  },
289
+ {
290
+ "name": "streaming",
291
+ "summary": "Streaming",
292
+ "required": false,
293
+ "description": "Evènement déclenché lors du streaming",
294
+ "schema": {
295
+ "type": "array",
296
+ "items": {
297
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
298
+ }
299
+ }
300
+ },
277
301
  {
278
302
  "name": "signature",
279
303
  "summary": "Signature",
@@ -334,6 +358,18 @@
334
358
  }
335
359
  }
336
360
  },
361
+ {
362
+ "name": "streaming",
363
+ "summary": "Streaming",
364
+ "required": false,
365
+ "description": "Evènement déclenché lors du streaming",
366
+ "schema": {
367
+ "type": "array",
368
+ "items": {
369
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
370
+ }
371
+ }
372
+ },
337
373
  {
338
374
  "name": "name",
339
375
  "summary": "Nom",
package/schema.json CHANGED
@@ -214,6 +214,18 @@
214
214
  }
215
215
  }
216
216
  },
217
+ {
218
+ "name": "streaming",
219
+ "summary": "Streaming",
220
+ "required": false,
221
+ "description": "Streaming event for the generation",
222
+ "schema": {
223
+ "type": "array",
224
+ "items": {
225
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
226
+ }
227
+ }
228
+ },
217
229
  {
218
230
  "name": "signature",
219
231
  "summary": "Signature",
@@ -274,6 +286,18 @@
274
286
  }
275
287
  }
276
288
  },
289
+ {
290
+ "name": "streaming",
291
+ "summary": "Streaming",
292
+ "required": false,
293
+ "description": "Streaming event for the generation",
294
+ "schema": {
295
+ "type": "array",
296
+ "items": {
297
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
298
+ }
299
+ }
300
+ },
277
301
  {
278
302
  "name": "signature",
279
303
  "summary": "Signature",
@@ -334,6 +358,18 @@
334
358
  }
335
359
  }
336
360
  },
361
+ {
362
+ "name": "streaming",
363
+ "summary": "Streaming",
364
+ "required": false,
365
+ "description": "Streaming event for the generation",
366
+ "schema": {
367
+ "type": "array",
368
+ "items": {
369
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
370
+ }
371
+ }
372
+ },
337
373
  {
338
374
  "name": "name",
339
375
  "summary": "Name",
@@ -1,11 +1,9 @@
1
1
  import { PinsSettings } from '@digipair/engine';
2
- import { AxAI, AxAIAzureOpenAI, AxAIOllama, AxAgent, AxAIOpenAIBase } from '@ax-llm/ax';
2
+ import { AxAI, AxAIAzureOpenAI, AxAIOllama, AxAIOpenAIBase } from '@ax-llm/ax';
3
3
  export declare const model: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<AxAI>;
4
4
  export declare const modelOpenAI: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<AxAIOpenAIBase<unknown, unknown>>;
5
5
  export declare const modelAzureOpenAi: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<AxAIAzureOpenAI>;
6
6
  export declare const modelOllama: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<AxAIOllama>;
7
- export declare const generate: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@ax-llm/ax").AxGenerateResult<import("@ax-llm/ax").AxGenOut>>;
8
- export declare const chainOfThought: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@ax-llm/ax").AxGenOut & {
9
- reason: string;
10
- }>;
11
- export declare const agent: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<import("@ax-llm/ax").AxGenOut | AxAgent<import("@ax-llm/ax").AxGenIn, import("@ax-llm/ax").AxGenOut>>;
7
+ export declare const generate: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
8
+ export declare const chainOfThought: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
9
+ export declare const agent: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
File without changes