@digipair/skill-dsp 0.72.14 → 0.73.1

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
@@ -124439,6 +124439,30 @@ let DspService = class DspService {
124439
124439
  }), `${context.__PATH__}.functions[${i}]`)
124440
124440
  })));
124441
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
+ }
124442
124466
  async model(params, _pinsSettingsList, _context) {
124443
124467
  const { name, options } = params;
124444
124468
  const modelInstance = new AxAI(_extends({
@@ -124485,12 +124509,27 @@ let DspService = class DspService {
124485
124509
  return modelInstance;
124486
124510
  }
124487
124511
  async generate(params, _pinsSettingsList, context) {
124488
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
124512
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
124489
124513
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124490
124514
  const gen = new AxGen(signature, {
124491
124515
  functions: await this.prepareFunctions(functions, context)
124492
124516
  });
124493
- 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, _extends({}, context, {
124523
+ event: item
124524
+ }), `${context.__PATH__}.streaming`);
124525
+ }
124526
+ if (item.version !== currentVersion) {
124527
+ buffer = {};
124528
+ }
124529
+ currentVersion = item.version;
124530
+ buffer = this.mergeDeltas(buffer, item.delta);
124531
+ }
124532
+ const result = buffer;
124494
124533
  var _modelInstance_ia;
124495
124534
  // add comsumption
124496
124535
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124500,12 +124539,27 @@ let DspService = class DspService {
124500
124539
  return result;
124501
124540
  }
124502
124541
  async chainOfThought(params, _pinsSettingsList, context) {
124503
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
124542
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
124504
124543
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124505
124544
  const gen = new AxChainOfThought(signature, {
124506
124545
  functions: await this.prepareFunctions(functions, context)
124507
124546
  });
124508
- const result = await gen.forward(modelInstance, input, options);
124547
+ const generator = gen.streamingForward(modelInstance, input, options);
124548
+ let buffer = {};
124549
+ let currentVersion = 0;
124550
+ for await (const item of generator){
124551
+ if (streaming) {
124552
+ await engine.executePinsList(streaming, _extends({}, context, {
124553
+ event: item
124554
+ }), `${context.__PATH__}.streaming`);
124555
+ }
124556
+ if (item.version !== currentVersion) {
124557
+ buffer = {};
124558
+ }
124559
+ currentVersion = item.version;
124560
+ buffer = this.mergeDeltas(buffer, item.delta);
124561
+ }
124562
+ const result = buffer;
124509
124563
  var _modelInstance_ia;
124510
124564
  // add comsumption
124511
124565
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124515,7 +124569,7 @@ let DspService = class DspService {
124515
124569
  return result;
124516
124570
  }
124517
124571
  async agent(params, _pinsSettingsList, context) {
124518
- const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, name, description, signature, input } = params;
124572
+ const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, streaming, name, description, signature, input } = params;
124519
124573
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124520
124574
  const agent = new AxAgent({
124521
124575
  name,
@@ -124533,7 +124587,22 @@ let DspService = class DspService {
124533
124587
  if (!forward) {
124534
124588
  return agent;
124535
124589
  }
124536
- const result = await agent.forward(modelInstance, input, options);
124590
+ const generator = agent.streamingForward(modelInstance, input, options);
124591
+ let buffer = {};
124592
+ let currentVersion = 0;
124593
+ for await (const item of generator){
124594
+ if (streaming) {
124595
+ await engine.executePinsList(streaming, _extends({}, context, {
124596
+ event: item
124597
+ }), `${context.__PATH__}.streaming`);
124598
+ }
124599
+ if (item.version !== currentVersion) {
124600
+ buffer = {};
124601
+ }
124602
+ currentVersion = item.version;
124603
+ buffer = this.mergeDeltas(buffer, item.delta);
124604
+ }
124605
+ const result = buffer;
124537
124606
  var _modelInstance_ia;
124538
124607
  // add comsumption
124539
124608
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
package/index.esm.js CHANGED
@@ -23951,14 +23951,14 @@ function indent(str, spaces) {
23951
23951
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23952
23952
  // match is required
23953
23953
  if (!match) {
23954
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
23954
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23955
23955
  v: nextMatch1
23956
23956
  };
23957
23957
  }
23958
23958
  var token = match.token, offset = match.offset;
23959
23959
  i1 += offset;
23960
23960
  if (token === " ") {
23961
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23961
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23962
23962
  }
23963
23963
  tokens1 = _to_consumable_array$5(tokens1).concat([
23964
23964
  token
@@ -23977,7 +23977,7 @@ function indent(str, spaces) {
23977
23977
  if (contextKeys.some(function(el) {
23978
23978
  return el.startsWith(name);
23979
23979
  })) {
23980
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23980
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23981
23981
  }
23982
23982
  if (dateTimeIdentifiers.some(function(el) {
23983
23983
  return el === name;
@@ -23996,9 +23996,9 @@ function indent(str, spaces) {
23996
23996
  if (dateTimeIdentifiers.some(function(el) {
23997
23997
  return el.startsWith(name);
23998
23998
  })) {
23999
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23999
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
24000
24000
  }
24001
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
24001
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
24002
24002
  v: nextMatch1
24003
24003
  };
24004
24004
  };
@@ -152378,6 +152378,30 @@ let DspService = class DspService {
152378
152378
  }), `${context.__PATH__}.functions[${i}]`)
152379
152379
  })));
152380
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
+ }
152381
152405
  async model(params, _pinsSettingsList, _context) {
152382
152406
  const { name, options } = params;
152383
152407
  const modelInstance = new AxAI(_extends({
@@ -152424,12 +152448,27 @@ let DspService = class DspService {
152424
152448
  return modelInstance;
152425
152449
  }
152426
152450
  async generate(params, _pinsSettingsList, context) {
152427
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
152451
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
152428
152452
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152429
152453
  const gen = new AxGen(signature, {
152430
152454
  functions: await this.prepareFunctions(functions, context)
152431
152455
  });
152432
- 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, _extends({}, context, {
152462
+ event: item
152463
+ }), `${context.__PATH__}.streaming`);
152464
+ }
152465
+ if (item.version !== currentVersion) {
152466
+ buffer = {};
152467
+ }
152468
+ currentVersion = item.version;
152469
+ buffer = this.mergeDeltas(buffer, item.delta);
152470
+ }
152471
+ const result = buffer;
152433
152472
  var _modelInstance_ia;
152434
152473
  // add comsumption
152435
152474
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152439,12 +152478,27 @@ let DspService = class DspService {
152439
152478
  return result;
152440
152479
  }
152441
152480
  async chainOfThought(params, _pinsSettingsList, context) {
152442
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
152481
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
152443
152482
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152444
152483
  const gen = new AxChainOfThought(signature, {
152445
152484
  functions: await this.prepareFunctions(functions, context)
152446
152485
  });
152447
- const result = await gen.forward(modelInstance, input, options);
152486
+ const generator = gen.streamingForward(modelInstance, input, options);
152487
+ let buffer = {};
152488
+ let currentVersion = 0;
152489
+ for await (const item of generator){
152490
+ if (streaming) {
152491
+ await executePinsList(streaming, _extends({}, context, {
152492
+ event: item
152493
+ }), `${context.__PATH__}.streaming`);
152494
+ }
152495
+ if (item.version !== currentVersion) {
152496
+ buffer = {};
152497
+ }
152498
+ currentVersion = item.version;
152499
+ buffer = this.mergeDeltas(buffer, item.delta);
152500
+ }
152501
+ const result = buffer;
152448
152502
  var _modelInstance_ia;
152449
152503
  // add comsumption
152450
152504
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152454,7 +152508,7 @@ let DspService = class DspService {
152454
152508
  return result;
152455
152509
  }
152456
152510
  async agent(params, _pinsSettingsList, context) {
152457
- const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, name, description, signature, input } = params;
152511
+ const { model = context.privates.MODEL_DSP, functions = [], agents = [], forward = true, options = {}, streaming, name, description, signature, input } = params;
152458
152512
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152459
152513
  const agent = new AxAgent({
152460
152514
  name,
@@ -152472,7 +152526,22 @@ let DspService = class DspService {
152472
152526
  if (!forward) {
152473
152527
  return agent;
152474
152528
  }
152475
- const result = await agent.forward(modelInstance, input, options);
152529
+ const generator = agent.streamingForward(modelInstance, input, options);
152530
+ let buffer = {};
152531
+ let currentVersion = 0;
152532
+ for await (const item of generator){
152533
+ if (streaming) {
152534
+ await executePinsList(streaming, _extends({}, context, {
152535
+ event: item
152536
+ }), `${context.__PATH__}.streaming`);
152537
+ }
152538
+ if (item.version !== currentVersion) {
152539
+ buffer = {};
152540
+ }
152541
+ currentVersion = item.version;
152542
+ buffer = this.mergeDeltas(buffer, item.delta);
152543
+ }
152544
+ const result = buffer;
152476
152545
  var _modelInstance_ia;
152477
152546
  // add comsumption
152478
152547
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-dsp",
3
- "version": "0.72.14",
3
+ "version": "0.73.1",
4
4
  "dependencies": {
5
5
  "@ax-llm/ax": "^11.0.29"
6
6
  },
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>;