@digipair/skill-dsp 0.72.14 → 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
@@ -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,25 @@ 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, 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;
124494
124531
  var _modelInstance_ia;
124495
124532
  // add comsumption
124496
124533
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124500,12 +124537,25 @@ let DspService = class DspService {
124500
124537
  return result;
124501
124538
  }
124502
124539
  async chainOfThought(params, _pinsSettingsList, context) {
124503
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
124540
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
124504
124541
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124505
124542
  const gen = new AxChainOfThought(signature, {
124506
124543
  functions: await this.prepareFunctions(functions, context)
124507
124544
  });
124508
- 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;
124509
124559
  var _modelInstance_ia;
124510
124560
  // add comsumption
124511
124561
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -124515,7 +124565,7 @@ let DspService = class DspService {
124515
124565
  return result;
124516
124566
  }
124517
124567
  async agent(params, _pinsSettingsList, context) {
124518
- 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;
124519
124569
  const modelInstance = await engine.executePinsList(model, context, `${context.__PATH__}.model`);
124520
124570
  const agent = new AxAgent({
124521
124571
  name,
@@ -124533,7 +124583,20 @@ let DspService = class DspService {
124533
124583
  if (!forward) {
124534
124584
  return agent;
124535
124585
  }
124536
- 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;
124537
124600
  var _modelInstance_ia;
124538
124601
  // add comsumption
124539
124602
  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 i = i1, nextMatch = nextMatch1, tokens = tokens1, {
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 i = i1, nextMatch = nextMatch1, tokens = tokens1, "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 i = i1, nextMatch = nextMatch1, tokens = tokens1, "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 i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
24000
24000
  }
24001
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
24001
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
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,25 @@ 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, 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;
152433
152470
  var _modelInstance_ia;
152434
152471
  // add comsumption
152435
152472
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152439,12 +152476,25 @@ let DspService = class DspService {
152439
152476
  return result;
152440
152477
  }
152441
152478
  async chainOfThought(params, _pinsSettingsList, context) {
152442
- const { model = context.privates.MODEL_DSP, functions = [], options = {}, signature, input } = params;
152479
+ const { model = context.privates.MODEL_DSP, functions = [], options = {}, streaming, signature, input } = params;
152443
152480
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152444
152481
  const gen = new AxChainOfThought(signature, {
152445
152482
  functions: await this.prepareFunctions(functions, context)
152446
152483
  });
152447
- 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;
152448
152498
  var _modelInstance_ia;
152449
152499
  // add comsumption
152450
152500
  const ai = (_modelInstance_ia = modelInstance.ia) != null ? _modelInstance_ia : modelInstance;
@@ -152454,7 +152504,7 @@ let DspService = class DspService {
152454
152504
  return result;
152455
152505
  }
152456
152506
  async agent(params, _pinsSettingsList, context) {
152457
- 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;
152458
152508
  const modelInstance = await executePinsList(model, context, `${context.__PATH__}.model`);
152459
152509
  const agent = new AxAgent({
152460
152510
  name,
@@ -152472,7 +152522,20 @@ let DspService = class DspService {
152472
152522
  if (!forward) {
152473
152523
  return agent;
152474
152524
  }
152475
- 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;
152476
152539
  var _modelInstance_ia;
152477
152540
  // add comsumption
152478
152541
  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.0",
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>;