@salesforce/lds-adapters-service-einsteinllm 1.229.0-dev3 → 1.229.0-dev5

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.
@@ -4,7 +4,7 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
@@ -104,7 +104,7 @@ function createLink(ref) {
104
104
  };
105
105
  }
106
106
 
107
- function validate$7(obj, path = 'EinsteinLlmAdditionalConfigInputRepresentation') {
107
+ function validate$9(obj, path = 'EinsteinLlmAdditionalConfigInputRepresentation') {
108
108
  const v_error = (() => {
109
109
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
110
110
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -187,7 +187,7 @@ function validate$7(obj, path = 'EinsteinLlmAdditionalConfigInputRepresentation'
187
187
  return v_error === undefined ? null : v_error;
188
188
  }
189
189
 
190
- function validate$6(obj, path = 'EinsteinLlmGenerationsInputRepresentation') {
190
+ function validate$8(obj, path = 'EinsteinLlmGenerationsInputRepresentation') {
191
191
  const v_error = (() => {
192
192
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
193
193
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -195,7 +195,7 @@ function validate$6(obj, path = 'EinsteinLlmGenerationsInputRepresentation') {
195
195
  if (obj.additionalConfig !== undefined) {
196
196
  const obj_additionalConfig = obj.additionalConfig;
197
197
  const path_additionalConfig = path + '.additionalConfig';
198
- const referencepath_additionalConfigValidationError = validate$7(obj_additionalConfig, path_additionalConfig);
198
+ const referencepath_additionalConfigValidationError = validate$9(obj_additionalConfig, path_additionalConfig);
199
199
  if (referencepath_additionalConfigValidationError !== null) {
200
200
  let message = 'Object doesn\'t match EinsteinLlmAdditionalConfigInputRepresentation (at "' + path_additionalConfig + '")\n';
201
201
  message += referencepath_additionalConfigValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -218,8 +218,8 @@ function validate$6(obj, path = 'EinsteinLlmGenerationsInputRepresentation') {
218
218
  return v_error === undefined ? null : v_error;
219
219
  }
220
220
 
221
- const VERSION$3 = "e87ca68f9dcf9550fb4dc9fd91df91ae";
222
- function validate$5(obj, path = 'EinsteinLlmGenerationItemRepresentation') {
221
+ const VERSION$4 = "e87ca68f9dcf9550fb4dc9fd91df91ae";
222
+ function validate$7(obj, path = 'EinsteinLlmGenerationItemRepresentation') {
223
223
  const v_error = (() => {
224
224
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
225
225
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -237,10 +237,10 @@ function validate$5(obj, path = 'EinsteinLlmGenerationItemRepresentation') {
237
237
  })();
238
238
  return v_error === undefined ? null : v_error;
239
239
  }
240
- const select$5 = function EinsteinLlmGenerationItemRepresentationSelect() {
240
+ const select$7 = function EinsteinLlmGenerationItemRepresentationSelect() {
241
241
  return {
242
242
  kind: 'Fragment',
243
- version: VERSION$3,
243
+ version: VERSION$4,
244
244
  private: [],
245
245
  selections: [
246
246
  {
@@ -254,7 +254,7 @@ const select$5 = function EinsteinLlmGenerationItemRepresentationSelect() {
254
254
  ]
255
255
  };
256
256
  };
257
- function equals$3(existing, incoming) {
257
+ function equals$4(existing, incoming) {
258
258
  const existing_parameters = existing.parameters;
259
259
  const incoming_parameters = incoming.parameters;
260
260
  if (!(existing_parameters === incoming_parameters)) {
@@ -268,8 +268,8 @@ function equals$3(existing, incoming) {
268
268
  return true;
269
269
  }
270
270
 
271
- const VERSION$2 = "4656c961c9d093a9e206c1db7d4de0b0";
272
- function validate$4(obj, path = 'WrappedMap') {
271
+ const VERSION$3 = "4656c961c9d093a9e206c1db7d4de0b0";
272
+ function validate$6(obj, path = 'WrappedMap') {
273
273
  const v_error = (() => {
274
274
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
275
275
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -291,15 +291,15 @@ function validate$4(obj, path = 'WrappedMap') {
291
291
  })();
292
292
  return v_error === undefined ? null : v_error;
293
293
  }
294
- const select$4 = function WrappedMapSelect() {
294
+ const select$6 = function WrappedMapSelect() {
295
295
  return {
296
296
  kind: 'Fragment',
297
- version: VERSION$2,
297
+ version: VERSION$3,
298
298
  private: [],
299
299
  selections: []
300
300
  };
301
301
  };
302
- function equals$2(existing, incoming) {
302
+ function equals$3(existing, incoming) {
303
303
  const existing_wrappedMap = existing.wrappedMap;
304
304
  const incoming_wrappedMap = incoming.wrappedMap;
305
305
  const equals_wrappedMap_props = equalsObject(existing_wrappedMap, incoming_wrappedMap, (existing_wrappedMap_prop, incoming_wrappedMap_prop) => {
@@ -310,9 +310,9 @@ function equals$2(existing, incoming) {
310
310
  return true;
311
311
  }
312
312
 
313
- const TTL$1 = 100;
314
- const VERSION$1 = "d8abd72a42e842b253da1c38954dafbc";
315
- function validate$3(obj, path = 'EinsteinLlmGenerationsRepresentation') {
313
+ const TTL$2 = 100;
314
+ const VERSION$2 = "d8abd72a42e842b253da1c38954dafbc";
315
+ function validate$5(obj, path = 'EinsteinLlmGenerationsRepresentation') {
316
316
  const v_error = (() => {
317
317
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
318
318
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -325,7 +325,7 @@ function validate$3(obj, path = 'EinsteinLlmGenerationsRepresentation') {
325
325
  for (let i = 0; i < obj_generations.length; i++) {
326
326
  const obj_generations_item = obj_generations[i];
327
327
  const path_generations_item = path_generations + '[' + i + ']';
328
- const referencepath_generations_itemValidationError = validate$5(obj_generations_item, path_generations_item);
328
+ const referencepath_generations_itemValidationError = validate$7(obj_generations_item, path_generations_item);
329
329
  if (referencepath_generations_itemValidationError !== null) {
330
330
  let message = 'Object doesn\'t match EinsteinLlmGenerationItemRepresentation (at "' + path_generations_item + '")\n';
331
331
  message += referencepath_generations_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -336,7 +336,7 @@ function validate$3(obj, path = 'EinsteinLlmGenerationsRepresentation') {
336
336
  const path_parameters = path + '.parameters';
337
337
  let obj_parameters_union0 = null;
338
338
  const obj_parameters_union0_error = (() => {
339
- const referencepath_parametersValidationError = validate$4(obj_parameters, path_parameters);
339
+ const referencepath_parametersValidationError = validate$6(obj_parameters, path_parameters);
340
340
  if (referencepath_parametersValidationError !== null) {
341
341
  let message = 'Object doesn\'t match WrappedMap (at "' + path_parameters + '")\n';
342
342
  message += referencepath_parametersValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -395,25 +395,25 @@ function validate$3(obj, path = 'EinsteinLlmGenerationsRepresentation') {
395
395
  })();
396
396
  return v_error === undefined ? null : v_error;
397
397
  }
398
- const RepresentationType$1 = 'EinsteinLlmGenerationsRepresentation';
399
- function keyBuilder$1(luvio, config) {
400
- return keyPrefix + '::' + RepresentationType$1 + ':' + config.requestId;
398
+ const RepresentationType$2 = 'EinsteinLlmGenerationsRepresentation';
399
+ function keyBuilder$2(luvio, config) {
400
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.requestId;
401
401
  }
402
- function keyBuilderFromType$1(luvio, object) {
402
+ function keyBuilderFromType$2(luvio, object) {
403
403
  const keyParams = {
404
404
  requestId: object.requestId
405
405
  };
406
- return keyBuilder$1(luvio, keyParams);
406
+ return keyBuilder$2(luvio, keyParams);
407
407
  }
408
- function normalize$1(input, existing, path, luvio, store, timestamp) {
408
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
409
409
  return input;
410
410
  }
411
- const select$3 = function EinsteinLlmGenerationsRepresentationSelect() {
412
- const { selections: EinsteinLlmGenerationItemRepresentation__selections, opaque: EinsteinLlmGenerationItemRepresentation__opaque, } = select$5();
413
- const { selections: WrappedMap__selections, opaque: WrappedMap__opaque, } = select$4();
411
+ const select$5 = function EinsteinLlmGenerationsRepresentationSelect() {
412
+ const { selections: EinsteinLlmGenerationItemRepresentation__selections, opaque: EinsteinLlmGenerationItemRepresentation__opaque, } = select$7();
413
+ const { selections: WrappedMap__selections, opaque: WrappedMap__opaque, } = select$6();
414
414
  return {
415
415
  kind: 'Fragment',
416
- version: VERSION$1,
416
+ version: VERSION$2,
417
417
  private: [],
418
418
  selections: [
419
419
  {
@@ -439,7 +439,7 @@ const select$3 = function EinsteinLlmGenerationsRepresentationSelect() {
439
439
  ]
440
440
  };
441
441
  };
442
- function equals$1(existing, incoming) {
442
+ function equals$2(existing, incoming) {
443
443
  const existing_requestId = existing.requestId;
444
444
  const incoming_requestId = incoming.requestId;
445
445
  if (!(existing_requestId === incoming_requestId)) {
@@ -448,7 +448,7 @@ function equals$1(existing, incoming) {
448
448
  const existing_generations = existing.generations;
449
449
  const incoming_generations = incoming.generations;
450
450
  const equals_generations_items = equalsArray(existing_generations, incoming_generations, (existing_generations_item, incoming_generations_item) => {
451
- if (!(equals$3(existing_generations_item, incoming_generations_item))) {
451
+ if (!(equals$4(existing_generations_item, incoming_generations_item))) {
452
452
  return false;
453
453
  }
454
454
  });
@@ -460,7 +460,7 @@ function equals$1(existing, incoming) {
460
460
  if (!(existing_parameters === incoming_parameters
461
461
  || (existing_parameters != null &&
462
462
  incoming_parameters != null &&
463
- equals$2(existing_parameters, incoming_parameters)))) {
463
+ equals$3(existing_parameters, incoming_parameters)))) {
464
464
  return false;
465
465
  }
466
466
  const existing_prompt = existing.prompt;
@@ -470,7 +470,224 @@ function equals$1(existing, incoming) {
470
470
  }
471
471
  return true;
472
472
  }
473
- const ingest$1 = function EinsteinLlmGenerationsRepresentationIngest(input, path, luvio, store, timestamp) {
473
+ const ingest$2 = function EinsteinLlmGenerationsRepresentationIngest(input, path, luvio, store, timestamp) {
474
+ if (process.env.NODE_ENV !== 'production') {
475
+ const validateError = validate$5(input);
476
+ if (validateError !== null) {
477
+ throw validateError;
478
+ }
479
+ }
480
+ const key = keyBuilderFromType$2(luvio, input);
481
+ const ttlToUse = TTL$2;
482
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "EinsteinLLM", VERSION$2, RepresentationType$2, equals$2);
483
+ return createLink(key);
484
+ };
485
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
486
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
487
+ const rootKey = keyBuilderFromType$2(luvio, input);
488
+ rootKeySet.set(rootKey, {
489
+ namespace: keyPrefix,
490
+ representationName: RepresentationType$2,
491
+ mergeable: false
492
+ });
493
+ }
494
+
495
+ function select$4(luvio, params) {
496
+ return select$5();
497
+ }
498
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
499
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
500
+ }
501
+ function ingestSuccess$2(luvio, resourceParams, response) {
502
+ const { body } = response;
503
+ const key = keyBuilderFromType$2(luvio, body);
504
+ luvio.storeIngest(key, ingest$2, body);
505
+ const snapshot = luvio.storeLookup({
506
+ recordId: key,
507
+ node: select$4(),
508
+ variables: {},
509
+ });
510
+ if (process.env.NODE_ENV !== 'production') {
511
+ if (snapshot.state !== 'Fulfilled') {
512
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
513
+ }
514
+ }
515
+ deepFreeze(snapshot.data);
516
+ return snapshot;
517
+ }
518
+ function createResourceRequest$2(config) {
519
+ const headers = {};
520
+ return {
521
+ baseUri: '/services/data/v59.0',
522
+ basePath: '/einstein/llm/prompt/generations',
523
+ method: 'post',
524
+ body: config.body,
525
+ urlParams: {},
526
+ queryParams: {},
527
+ headers,
528
+ priority: 'normal',
529
+ };
530
+ }
531
+
532
+ const adapterName$2 = 'createGenerations';
533
+ const createGenerations_ConfigPropertyMetadata = [
534
+ generateParamConfigMetadata('generationsInput', true, 2 /* Body */, 4 /* Unsupported */),
535
+ ];
536
+ const createGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, createGenerations_ConfigPropertyMetadata);
537
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(createGenerations_ConfigPropertyMetadata);
538
+ function typeCheckConfig$2(untrustedConfig) {
539
+ const config = {};
540
+ const untrustedConfig_generationsInput = untrustedConfig.generationsInput;
541
+ const referenceEinsteinLlmGenerationsInputRepresentationValidationError = validate$8(untrustedConfig_generationsInput);
542
+ if (referenceEinsteinLlmGenerationsInputRepresentationValidationError === null) {
543
+ config.generationsInput = untrustedConfig_generationsInput;
544
+ }
545
+ return config;
546
+ }
547
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
548
+ if (!untrustedIsObject(untrustedConfig)) {
549
+ return null;
550
+ }
551
+ if (process.env.NODE_ENV !== 'production') {
552
+ validateConfig(untrustedConfig, configPropertyNames);
553
+ }
554
+ const config = typeCheckConfig$2(untrustedConfig);
555
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
556
+ return null;
557
+ }
558
+ return config;
559
+ }
560
+ function buildNetworkSnapshot$2(luvio, config, options) {
561
+ const resourceParams = createResourceParams$2(config);
562
+ const request = createResourceRequest$2(resourceParams);
563
+ return luvio.dispatchResourceRequest(request, options)
564
+ .then((response) => {
565
+ return luvio.handleSuccessResponse(() => {
566
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
567
+ return luvio.storeBroadcast().then(() => snapshot);
568
+ }, () => {
569
+ const cache = new StoreKeyMap();
570
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
571
+ return cache;
572
+ });
573
+ }, (response) => {
574
+ deepFreeze(response);
575
+ throw response;
576
+ });
577
+ }
578
+ const createGenerationsAdapterFactory = (luvio) => {
579
+ return function createGenerations(untrustedConfig) {
580
+ const config = validateAdapterConfig$2(untrustedConfig, createGenerations_ConfigPropertyNames);
581
+ // Invalid or incomplete config
582
+ if (config === null) {
583
+ throw new Error('Invalid config for "createGenerations"');
584
+ }
585
+ return buildNetworkSnapshot$2(luvio, config);
586
+ };
587
+ };
588
+
589
+ function validate$4(obj, path = 'EinsteinLlmFeedbackInputRepresentation') {
590
+ const v_error = (() => {
591
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
592
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
593
+ }
594
+ if (obj.appFeedback !== undefined) {
595
+ const obj_appFeedback = obj.appFeedback;
596
+ const path_appFeedback = path + '.appFeedback';
597
+ if (typeof obj_appFeedback !== 'object' || ArrayIsArray(obj_appFeedback) || obj_appFeedback === null) {
598
+ return new TypeError('Expected "object" but received "' + typeof obj_appFeedback + '" (at "' + path_appFeedback + '")');
599
+ }
600
+ const obj_appFeedback_keys = ObjectKeys(obj_appFeedback);
601
+ for (let i = 0; i < obj_appFeedback_keys.length; i++) {
602
+ const key = obj_appFeedback_keys[i];
603
+ const obj_appFeedback_prop = obj_appFeedback[key];
604
+ const path_appFeedback_prop = path_appFeedback + '["' + key + '"]';
605
+ if (typeof obj_appFeedback_prop !== 'object' || ArrayIsArray(obj_appFeedback_prop) || obj_appFeedback_prop === null) {
606
+ return new TypeError('Expected "object" but received "' + typeof obj_appFeedback_prop + '" (at "' + path_appFeedback_prop + '")');
607
+ }
608
+ }
609
+ }
610
+ if (obj.feedback !== undefined) {
611
+ const obj_feedback = obj.feedback;
612
+ const path_feedback = path + '.feedback';
613
+ if (typeof obj_feedback !== 'string') {
614
+ return new TypeError('Expected "string" but received "' + typeof obj_feedback + '" (at "' + path_feedback + '")');
615
+ }
616
+ }
617
+ const obj_feedbackText = obj.feedbackText;
618
+ const path_feedbackText = path + '.feedbackText';
619
+ if (typeof obj_feedbackText !== 'string') {
620
+ return new TypeError('Expected "string" but received "' + typeof obj_feedbackText + '" (at "' + path_feedbackText + '")');
621
+ }
622
+ const obj_generationId = obj.generationId;
623
+ const path_generationId = path + '.generationId';
624
+ if (typeof obj_generationId !== 'string') {
625
+ return new TypeError('Expected "string" but received "' + typeof obj_generationId + '" (at "' + path_generationId + '")');
626
+ }
627
+ const obj_id = obj.id;
628
+ const path_id = path + '.id';
629
+ if (typeof obj_id !== 'string') {
630
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
631
+ }
632
+ const obj_source = obj.source;
633
+ const path_source = path + '.source';
634
+ if (typeof obj_source !== 'string') {
635
+ return new TypeError('Expected "string" but received "' + typeof obj_source + '" (at "' + path_source + '")');
636
+ }
637
+ })();
638
+ return v_error === undefined ? null : v_error;
639
+ }
640
+
641
+ const TTL$1 = 100;
642
+ const VERSION$1 = "4033328f65865dd5d80c68a7573a4522";
643
+ function validate$3(obj, path = 'EinsteinLlmFeedbackRepresentation') {
644
+ const v_error = (() => {
645
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
646
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
647
+ }
648
+ const obj_message = obj.message;
649
+ const path_message = path + '.message';
650
+ if (typeof obj_message !== 'string') {
651
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
652
+ }
653
+ })();
654
+ return v_error === undefined ? null : v_error;
655
+ }
656
+ const RepresentationType$1 = 'EinsteinLlmFeedbackRepresentation';
657
+ function keyBuilder$1(luvio, config) {
658
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.message;
659
+ }
660
+ function keyBuilderFromType$1(luvio, object) {
661
+ const keyParams = {
662
+ message: object.message
663
+ };
664
+ return keyBuilder$1(luvio, keyParams);
665
+ }
666
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
667
+ return input;
668
+ }
669
+ const select$3 = function EinsteinLlmFeedbackRepresentationSelect() {
670
+ return {
671
+ kind: 'Fragment',
672
+ version: VERSION$1,
673
+ private: [],
674
+ selections: [
675
+ {
676
+ name: 'message',
677
+ kind: 'Scalar'
678
+ }
679
+ ]
680
+ };
681
+ };
682
+ function equals$1(existing, incoming) {
683
+ const existing_message = existing.message;
684
+ const incoming_message = incoming.message;
685
+ if (!(existing_message === incoming_message)) {
686
+ return false;
687
+ }
688
+ return true;
689
+ }
690
+ const ingest$1 = function EinsteinLlmFeedbackRepresentationIngest(input, path, luvio, store, timestamp) {
474
691
  if (process.env.NODE_ENV !== 'production') {
475
692
  const validateError = validate$3(input);
476
693
  if (validateError !== null) {
@@ -519,7 +736,7 @@ function createResourceRequest$1(config) {
519
736
  const headers = {};
520
737
  return {
521
738
  baseUri: '/services/data/v59.0',
522
- basePath: '/einstein/llm/prompt/generations',
739
+ basePath: '/einstein/llm/feedback',
523
740
  method: 'post',
524
741
  body: config.body,
525
742
  urlParams: {},
@@ -529,18 +746,18 @@ function createResourceRequest$1(config) {
529
746
  };
530
747
  }
531
748
 
532
- const adapterName$1 = 'createGenerations';
533
- const createGenerations_ConfigPropertyMetadata = [
534
- generateParamConfigMetadata('generationsInput', true, 2 /* Body */, 4 /* Unsupported */),
749
+ const adapterName$1 = 'createFeedback';
750
+ const createFeedback_ConfigPropertyMetadata = [
751
+ generateParamConfigMetadata('feedbackInput', true, 2 /* Body */, 4 /* Unsupported */),
535
752
  ];
536
- const createGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createGenerations_ConfigPropertyMetadata);
537
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(createGenerations_ConfigPropertyMetadata);
753
+ const createFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createFeedback_ConfigPropertyMetadata);
754
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(createFeedback_ConfigPropertyMetadata);
538
755
  function typeCheckConfig$1(untrustedConfig) {
539
756
  const config = {};
540
- const untrustedConfig_generationsInput = untrustedConfig.generationsInput;
541
- const referenceEinsteinLlmGenerationsInputRepresentationValidationError = validate$6(untrustedConfig_generationsInput);
542
- if (referenceEinsteinLlmGenerationsInputRepresentationValidationError === null) {
543
- config.generationsInput = untrustedConfig_generationsInput;
757
+ const untrustedConfig_feedbackInput = untrustedConfig.feedbackInput;
758
+ const referenceEinsteinLlmFeedbackInputRepresentationValidationError = validate$4(untrustedConfig_feedbackInput);
759
+ if (referenceEinsteinLlmFeedbackInputRepresentationValidationError === null) {
760
+ config.feedbackInput = untrustedConfig_feedbackInput;
544
761
  }
545
762
  return config;
546
763
  }
@@ -575,12 +792,12 @@ function buildNetworkSnapshot$1(luvio, config, options) {
575
792
  throw response;
576
793
  });
577
794
  }
578
- const createGenerationsAdapterFactory = (luvio) => {
579
- return function createGenerations(untrustedConfig) {
580
- const config = validateAdapterConfig$1(untrustedConfig, createGenerations_ConfigPropertyNames);
795
+ const createFeedbackAdapterFactory = (luvio) => {
796
+ return function createFeedback(untrustedConfig) {
797
+ const config = validateAdapterConfig$1(untrustedConfig, createFeedback_ConfigPropertyNames);
581
798
  // Invalid or incomplete config
582
799
  if (config === null) {
583
- throw new Error('Invalid config for "createGenerations"');
800
+ throw new Error('Invalid config for "createFeedback"');
584
801
  }
585
802
  return buildNetworkSnapshot$1(luvio, config);
586
803
  };
@@ -617,7 +834,7 @@ function validate$1(obj, path = 'EinsteinPromptTemplateGenerationsInputRepresent
617
834
  if (obj.additionalConfig !== undefined) {
618
835
  const obj_additionalConfig = obj.additionalConfig;
619
836
  const path_additionalConfig = path + '.additionalConfig';
620
- const referencepath_additionalConfigValidationError = validate$7(obj_additionalConfig, path_additionalConfig);
837
+ const referencepath_additionalConfigValidationError = validate$9(obj_additionalConfig, path_additionalConfig);
621
838
  if (referencepath_additionalConfigValidationError !== null) {
622
839
  let message = 'Object doesn\'t match EinsteinLlmAdditionalConfigInputRepresentation (at "' + path_additionalConfig + '")\n';
623
840
  message += referencepath_additionalConfigValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -663,7 +880,7 @@ function validate(obj, path = 'EinsteinPromptTemplateGenerationsRepresentation')
663
880
  for (let i = 0; i < obj_generations.length; i++) {
664
881
  const obj_generations_item = obj_generations[i];
665
882
  const path_generations_item = path_generations + '[' + i + ']';
666
- const referencepath_generations_itemValidationError = validate$5(obj_generations_item, path_generations_item);
883
+ const referencepath_generations_itemValidationError = validate$7(obj_generations_item, path_generations_item);
667
884
  if (referencepath_generations_itemValidationError !== null) {
668
885
  let message = 'Object doesn\'t match EinsteinLlmGenerationItemRepresentation (at "' + path_generations_item + '")\n';
669
886
  message += referencepath_generations_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -674,7 +891,7 @@ function validate(obj, path = 'EinsteinPromptTemplateGenerationsRepresentation')
674
891
  const path_parameters = path + '.parameters';
675
892
  let obj_parameters_union0 = null;
676
893
  const obj_parameters_union0_error = (() => {
677
- const referencepath_parametersValidationError = validate$4(obj_parameters, path_parameters);
894
+ const referencepath_parametersValidationError = validate$6(obj_parameters, path_parameters);
678
895
  if (referencepath_parametersValidationError !== null) {
679
896
  let message = 'Object doesn\'t match WrappedMap (at "' + path_parameters + '")\n';
680
897
  message += referencepath_parametersValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -752,8 +969,8 @@ function normalize(input, existing, path, luvio, store, timestamp) {
752
969
  return input;
753
970
  }
754
971
  const select$1 = function EinsteinPromptTemplateGenerationsRepresentationSelect() {
755
- const { selections: EinsteinLlmGenerationItemRepresentation__selections, opaque: EinsteinLlmGenerationItemRepresentation__opaque, } = select$5();
756
- const { selections: WrappedMap__selections, opaque: WrappedMap__opaque, } = select$4();
972
+ const { selections: EinsteinLlmGenerationItemRepresentation__selections, opaque: EinsteinLlmGenerationItemRepresentation__opaque, } = select$7();
973
+ const { selections: WrappedMap__selections, opaque: WrappedMap__opaque, } = select$6();
757
974
  return {
758
975
  kind: 'Fragment',
759
976
  version: VERSION,
@@ -800,7 +1017,7 @@ function equals(existing, incoming) {
800
1017
  const existing_generations = existing.generations;
801
1018
  const incoming_generations = incoming.generations;
802
1019
  const equals_generations_items = equalsArray(existing_generations, incoming_generations, (existing_generations_item, incoming_generations_item) => {
803
- if (!(equals$3(existing_generations_item, incoming_generations_item))) {
1020
+ if (!(equals$4(existing_generations_item, incoming_generations_item))) {
804
1021
  return false;
805
1022
  }
806
1023
  });
@@ -812,7 +1029,7 @@ function equals(existing, incoming) {
812
1029
  if (!(existing_parameters === incoming_parameters
813
1030
  || (existing_parameters != null &&
814
1031
  incoming_parameters != null &&
815
- equals$2(existing_parameters, incoming_parameters)))) {
1032
+ equals$3(existing_parameters, incoming_parameters)))) {
816
1033
  return false;
817
1034
  }
818
1035
  const existing_prompt = existing.prompt;
@@ -887,10 +1104,10 @@ const createGenerationsForPromptTemplate_ConfigPropertyMetadata = [
887
1104
  generateParamConfigMetadata('promptTemplateGenerationsInput', true, 2 /* Body */, 4 /* Unsupported */),
888
1105
  ];
889
1106
  const createGenerationsForPromptTemplate_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
890
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1107
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
891
1108
  function typeCheckConfig(untrustedConfig) {
892
1109
  const config = {};
893
- typeCheckConfig$2(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1110
+ typeCheckConfig$3(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
894
1111
  const untrustedConfig_promptTemplateGenerationsInput = untrustedConfig.promptTemplateGenerationsInput;
895
1112
  const referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError = validate$1(untrustedConfig_promptTemplateGenerationsInput);
896
1113
  if (referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError === null) {
@@ -940,4 +1157,4 @@ const createGenerationsForPromptTemplateAdapterFactory = (luvio) => {
940
1157
  };
941
1158
  };
942
1159
 
943
- export { createGenerationsAdapterFactory, createGenerationsForPromptTemplateAdapterFactory };
1160
+ export { createFeedbackAdapterFactory, createGenerationsAdapterFactory, createGenerationsForPromptTemplateAdapterFactory };
@@ -0,0 +1,16 @@
1
+ import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
2
+ import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
3
+ import { EinsteinLlmFeedbackInputRepresentation as types_EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation } from '../types/EinsteinLlmFeedbackInputRepresentation';
4
+ import { ResourceRequestConfig as resources_postEinsteinLlmFeedback_ResourceRequestConfig } from '../resources/postEinsteinLlmFeedback';
5
+ import { EinsteinLlmFeedbackRepresentation as types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation } from '../types/EinsteinLlmFeedbackRepresentation';
6
+ export declare const adapterName = "createFeedback";
7
+ export declare const createFeedback_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
8
+ export declare const createFeedback_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
9
+ export interface CreateFeedbackConfig {
10
+ feedbackInput: types_EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation;
11
+ }
12
+ export declare const createResourceParams: (config: CreateFeedbackConfig) => resources_postEinsteinLlmFeedback_ResourceRequestConfig;
13
+ export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<CreateFeedbackConfig>): adapter$45$utils_Untrusted<CreateFeedbackConfig>;
14
+ export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): CreateFeedbackConfig | null;
15
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: CreateFeedbackConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, any>>;
16
+ export declare const createFeedbackAdapterFactory: $64$luvio_engine_AdapterFactory<CreateFeedbackConfig, types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation>;
@@ -1,2 +1,3 @@
1
1
  export { createGenerationsAdapterFactory } from '../adapters/createGenerations';
2
+ export { createFeedbackAdapterFactory } from '../adapters/createFeedback';
2
3
  export { createGenerationsForPromptTemplateAdapterFactory } from '../adapters/createGenerationsForPromptTemplate';
@@ -1,3 +1,4 @@
1
+ declare let createFeedback: any;
1
2
  declare let createGenerations: any;
2
3
  declare let createGenerationsForPromptTemplate: any;
3
- export { createGenerations, createGenerationsForPromptTemplate, };
4
+ export { createFeedback, createGenerations, createGenerationsForPromptTemplate, };
@@ -0,0 +1,13 @@
1
+ import { EinsteinLlmFeedbackInputRepresentation as types_EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation } from '../types/EinsteinLlmFeedbackInputRepresentation';
2
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
3
+ import { EinsteinLlmFeedbackRepresentation as types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation } from '../types/EinsteinLlmFeedbackRepresentation';
4
+ export interface ResourceRequestConfig {
5
+ body: {
6
+ feedbackInput: types_EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation;
7
+ };
8
+ }
9
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
10
+ export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation): void;
11
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_EinsteinLlmFeedbackRepresentation_EinsteinLlmFeedbackRepresentation, any>;
12
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
13
+ export default createResourceRequest;
@@ -0,0 +1,47 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const VERSION = "47694ce9c242c84fe546f5ef976ed158";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: EinsteinLlmFeedbackInputRepresentation, existing: EinsteinLlmFeedbackInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): EinsteinLlmFeedbackInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: EinsteinLlmFeedbackInputRepresentationNormalized, incoming: EinsteinLlmFeedbackInputRepresentationNormalized): boolean;
8
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
9
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: EinsteinLlmFeedbackInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
10
+ /**
11
+ * Input representation for Feedback with Einstein LLM
12
+ *
13
+ * Keys:
14
+ * (none)
15
+ */
16
+ export interface EinsteinLlmFeedbackInputRepresentationNormalized {
17
+ /** app feedback map */
18
+ appFeedback?: {
19
+ [key: string]: {};
20
+ };
21
+ /** feedback */
22
+ feedback?: string;
23
+ /** Feedback Text */
24
+ feedbackText: string;
25
+ /** Generation Id - Generations.response.id */
26
+ generationId: string;
27
+ /** Feedback id */
28
+ id: string;
29
+ /** Feedback source */
30
+ source: string;
31
+ }
32
+ /**
33
+ * Input representation for Feedback with Einstein LLM
34
+ *
35
+ * Keys:
36
+ * (none)
37
+ */
38
+ export interface EinsteinLlmFeedbackInputRepresentation {
39
+ appFeedback?: {
40
+ [key: string]: {};
41
+ };
42
+ feedback?: string;
43
+ feedbackText: string;
44
+ generationId: string;
45
+ id: string;
46
+ source: string;
47
+ }
@@ -0,0 +1,38 @@
1
+ import { KeyMetadata as $64$luvio_engine_KeyMetadata, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Luvio as $64$luvio_engine_Luvio, IngestPath as $64$luvio_engine_IngestPath, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const TTL = 100;
3
+ export declare const VERSION = "4033328f65865dd5d80c68a7573a4522";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
7
+ message: string;
8
+ }
9
+ export type EinsteinLlmFeedbackRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
10
+ export type PartialEinsteinLlmFeedbackRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
12
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): EinsteinLlmFeedbackRepresentationNormalizedKeyMetadata;
13
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: EinsteinLlmFeedbackRepresentation): string;
14
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: EinsteinLlmFeedbackRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
15
+ export declare function normalize(input: EinsteinLlmFeedbackRepresentation, existing: EinsteinLlmFeedbackRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): EinsteinLlmFeedbackRepresentationNormalized;
16
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
17
+ export declare function equals(existing: EinsteinLlmFeedbackRepresentationNormalized, incoming: EinsteinLlmFeedbackRepresentationNormalized): boolean;
18
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
19
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: EinsteinLlmFeedbackRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
20
+ /**
21
+ * Output of a einstein llm feedback call
22
+ *
23
+ * Keys:
24
+ * message (string): message
25
+ */
26
+ export interface EinsteinLlmFeedbackRepresentationNormalized {
27
+ /** Response text of the feedback API */
28
+ message: string;
29
+ }
30
+ /**
31
+ * Output of a einstein llm feedback call
32
+ *
33
+ * Keys:
34
+ * message (string): message
35
+ */
36
+ export interface EinsteinLlmFeedbackRepresentation {
37
+ message: string;
38
+ }
@@ -0,0 +1,28 @@
1
+ import { EinsteinLlmFeedbackInputRepresentation as EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation } from './EinsteinLlmFeedbackInputRepresentation';
2
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
3
+ export declare const VERSION = "358db59f887ee50c67f9d2d3edb01fa0";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export declare function normalize(input: EinsteinLlmFeedbackWrapperRepresentation, existing: EinsteinLlmFeedbackWrapperRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): EinsteinLlmFeedbackWrapperRepresentationNormalized;
7
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
8
+ export declare function equals(existing: EinsteinLlmFeedbackWrapperRepresentationNormalized, incoming: EinsteinLlmFeedbackWrapperRepresentationNormalized): boolean;
9
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
10
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: EinsteinLlmFeedbackWrapperRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
11
+ /**
12
+ * Input wrapper for feedback representation
13
+ *
14
+ * Keys:
15
+ * (none)
16
+ */
17
+ export interface EinsteinLlmFeedbackWrapperRepresentationNormalized {
18
+ feedbackInput: EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation;
19
+ }
20
+ /**
21
+ * Input wrapper for feedback representation
22
+ *
23
+ * Keys:
24
+ * (none)
25
+ */
26
+ export interface EinsteinLlmFeedbackWrapperRepresentation {
27
+ feedbackInput: EinsteinLlmFeedbackInputRepresentation_EinsteinLlmFeedbackInputRepresentation;
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-service-einsteinllm",
3
- "version": "1.229.0-dev3",
3
+ "version": "1.229.0-dev5",
4
4
  "description": "Connect family for Einstein LLM generations",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "dist/es/es2018/service-einsteinllm.js",
@@ -44,11 +44,11 @@
44
44
  "test:compat": "karma start --single-run --compat"
45
45
  },
46
46
  "dependencies": {
47
- "@salesforce/lds-bindings": "1.229.0-dev3"
47
+ "@salesforce/lds-bindings": "1.229.0-dev5"
48
48
  },
49
49
  "devDependencies": {
50
- "@salesforce/lds-compiler-plugins": "1.229.0-dev3",
51
- "@salesforce/lds-karma": "1.229.0-dev3"
50
+ "@salesforce/lds-compiler-plugins": "1.229.0-dev5",
51
+ "@salesforce/lds-karma": "1.229.0-dev5"
52
52
  },
53
53
  "nx": {
54
54
  "targets": {
package/sfdc/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  */
14
14
  /* proxy-compat-disable */
15
15
  import { withDefaultLuvio } from 'force/ldsEngine';
16
- import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from 'force/luvioEngine';
16
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } from 'force/luvioEngine';
17
17
 
18
18
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
19
19
  const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
@@ -113,6 +113,223 @@ function createLink(ref) {
113
113
  };
114
114
  }
115
115
 
116
+ function validate$9(obj, path = 'EinsteinLlmFeedbackInputRepresentation') {
117
+ const v_error = (() => {
118
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
119
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
120
+ }
121
+ if (obj.appFeedback !== undefined) {
122
+ const obj_appFeedback = obj.appFeedback;
123
+ const path_appFeedback = path + '.appFeedback';
124
+ if (typeof obj_appFeedback !== 'object' || ArrayIsArray(obj_appFeedback) || obj_appFeedback === null) {
125
+ return new TypeError('Expected "object" but received "' + typeof obj_appFeedback + '" (at "' + path_appFeedback + '")');
126
+ }
127
+ const obj_appFeedback_keys = ObjectKeys(obj_appFeedback);
128
+ for (let i = 0; i < obj_appFeedback_keys.length; i++) {
129
+ const key = obj_appFeedback_keys[i];
130
+ const obj_appFeedback_prop = obj_appFeedback[key];
131
+ const path_appFeedback_prop = path_appFeedback + '["' + key + '"]';
132
+ if (typeof obj_appFeedback_prop !== 'object' || ArrayIsArray(obj_appFeedback_prop) || obj_appFeedback_prop === null) {
133
+ return new TypeError('Expected "object" but received "' + typeof obj_appFeedback_prop + '" (at "' + path_appFeedback_prop + '")');
134
+ }
135
+ }
136
+ }
137
+ if (obj.feedback !== undefined) {
138
+ const obj_feedback = obj.feedback;
139
+ const path_feedback = path + '.feedback';
140
+ if (typeof obj_feedback !== 'string') {
141
+ return new TypeError('Expected "string" but received "' + typeof obj_feedback + '" (at "' + path_feedback + '")');
142
+ }
143
+ }
144
+ const obj_feedbackText = obj.feedbackText;
145
+ const path_feedbackText = path + '.feedbackText';
146
+ if (typeof obj_feedbackText !== 'string') {
147
+ return new TypeError('Expected "string" but received "' + typeof obj_feedbackText + '" (at "' + path_feedbackText + '")');
148
+ }
149
+ const obj_generationId = obj.generationId;
150
+ const path_generationId = path + '.generationId';
151
+ if (typeof obj_generationId !== 'string') {
152
+ return new TypeError('Expected "string" but received "' + typeof obj_generationId + '" (at "' + path_generationId + '")');
153
+ }
154
+ const obj_id = obj.id;
155
+ const path_id = path + '.id';
156
+ if (typeof obj_id !== 'string') {
157
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
158
+ }
159
+ const obj_source = obj.source;
160
+ const path_source = path + '.source';
161
+ if (typeof obj_source !== 'string') {
162
+ return new TypeError('Expected "string" but received "' + typeof obj_source + '" (at "' + path_source + '")');
163
+ }
164
+ })();
165
+ return v_error === undefined ? null : v_error;
166
+ }
167
+
168
+ const TTL$2 = 100;
169
+ const VERSION$4 = "4033328f65865dd5d80c68a7573a4522";
170
+ function validate$8(obj, path = 'EinsteinLlmFeedbackRepresentation') {
171
+ const v_error = (() => {
172
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
173
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
174
+ }
175
+ const obj_message = obj.message;
176
+ const path_message = path + '.message';
177
+ if (typeof obj_message !== 'string') {
178
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
179
+ }
180
+ })();
181
+ return v_error === undefined ? null : v_error;
182
+ }
183
+ const RepresentationType$2 = 'EinsteinLlmFeedbackRepresentation';
184
+ function keyBuilder$2(luvio, config) {
185
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.message;
186
+ }
187
+ function keyBuilderFromType$2(luvio, object) {
188
+ const keyParams = {
189
+ message: object.message
190
+ };
191
+ return keyBuilder$2(luvio, keyParams);
192
+ }
193
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
194
+ return input;
195
+ }
196
+ const select$7 = function EinsteinLlmFeedbackRepresentationSelect() {
197
+ return {
198
+ kind: 'Fragment',
199
+ version: VERSION$4,
200
+ private: [],
201
+ selections: [
202
+ {
203
+ name: 'message',
204
+ kind: 'Scalar'
205
+ }
206
+ ]
207
+ };
208
+ };
209
+ function equals$4(existing, incoming) {
210
+ const existing_message = existing.message;
211
+ const incoming_message = incoming.message;
212
+ if (!(existing_message === incoming_message)) {
213
+ return false;
214
+ }
215
+ return true;
216
+ }
217
+ const ingest$2 = function EinsteinLlmFeedbackRepresentationIngest(input, path, luvio, store, timestamp) {
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ const validateError = validate$8(input);
220
+ if (validateError !== null) {
221
+ throw validateError;
222
+ }
223
+ }
224
+ const key = keyBuilderFromType$2(luvio, input);
225
+ const ttlToUse = TTL$2;
226
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "EinsteinLLM", VERSION$4, RepresentationType$2, equals$4);
227
+ return createLink(key);
228
+ };
229
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
230
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
231
+ const rootKey = keyBuilderFromType$2(luvio, input);
232
+ rootKeySet.set(rootKey, {
233
+ namespace: keyPrefix,
234
+ representationName: RepresentationType$2,
235
+ mergeable: false
236
+ });
237
+ }
238
+
239
+ function select$6(luvio, params) {
240
+ return select$7();
241
+ }
242
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
243
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
244
+ }
245
+ function ingestSuccess$2(luvio, resourceParams, response) {
246
+ const { body } = response;
247
+ const key = keyBuilderFromType$2(luvio, body);
248
+ luvio.storeIngest(key, ingest$2, body);
249
+ const snapshot = luvio.storeLookup({
250
+ recordId: key,
251
+ node: select$6(),
252
+ variables: {},
253
+ });
254
+ if (process.env.NODE_ENV !== 'production') {
255
+ if (snapshot.state !== 'Fulfilled') {
256
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
257
+ }
258
+ }
259
+ deepFreeze(snapshot.data);
260
+ return snapshot;
261
+ }
262
+ function createResourceRequest$2(config) {
263
+ const headers = {};
264
+ return {
265
+ baseUri: '/services/data/v59.0',
266
+ basePath: '/einstein/llm/feedback',
267
+ method: 'post',
268
+ body: config.body,
269
+ urlParams: {},
270
+ queryParams: {},
271
+ headers,
272
+ priority: 'normal',
273
+ };
274
+ }
275
+
276
+ const adapterName$2 = 'createFeedback';
277
+ const createFeedback_ConfigPropertyMetadata = [
278
+ generateParamConfigMetadata('feedbackInput', true, 2 /* Body */, 4 /* Unsupported */),
279
+ ];
280
+ const createFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, createFeedback_ConfigPropertyMetadata);
281
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(createFeedback_ConfigPropertyMetadata);
282
+ function typeCheckConfig$2(untrustedConfig) {
283
+ const config = {};
284
+ const untrustedConfig_feedbackInput = untrustedConfig.feedbackInput;
285
+ const referenceEinsteinLlmFeedbackInputRepresentationValidationError = validate$9(untrustedConfig_feedbackInput);
286
+ if (referenceEinsteinLlmFeedbackInputRepresentationValidationError === null) {
287
+ config.feedbackInput = untrustedConfig_feedbackInput;
288
+ }
289
+ return config;
290
+ }
291
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
292
+ if (!untrustedIsObject(untrustedConfig)) {
293
+ return null;
294
+ }
295
+ if (process.env.NODE_ENV !== 'production') {
296
+ validateConfig(untrustedConfig, configPropertyNames);
297
+ }
298
+ const config = typeCheckConfig$2(untrustedConfig);
299
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
300
+ return null;
301
+ }
302
+ return config;
303
+ }
304
+ function buildNetworkSnapshot$2(luvio, config, options) {
305
+ const resourceParams = createResourceParams$2(config);
306
+ const request = createResourceRequest$2(resourceParams);
307
+ return luvio.dispatchResourceRequest(request, options)
308
+ .then((response) => {
309
+ return luvio.handleSuccessResponse(() => {
310
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
311
+ return luvio.storeBroadcast().then(() => snapshot);
312
+ }, () => {
313
+ const cache = new StoreKeyMap();
314
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
315
+ return cache;
316
+ });
317
+ }, (response) => {
318
+ deepFreeze(response);
319
+ throw response;
320
+ });
321
+ }
322
+ const createFeedbackAdapterFactory = (luvio) => {
323
+ return function createFeedback(untrustedConfig) {
324
+ const config = validateAdapterConfig$2(untrustedConfig, createFeedback_ConfigPropertyNames);
325
+ // Invalid or incomplete config
326
+ if (config === null) {
327
+ throw new Error('Invalid config for "createFeedback"');
328
+ }
329
+ return buildNetworkSnapshot$2(luvio, config);
330
+ };
331
+ };
332
+
116
333
  function validate$7(obj, path = 'EinsteinLlmAdditionalConfigInputRepresentation') {
117
334
  const v_error = (() => {
118
335
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -543,7 +760,7 @@ const createGenerations_ConfigPropertyMetadata = [
543
760
  generateParamConfigMetadata('generationsInput', true, 2 /* Body */, 4 /* Unsupported */),
544
761
  ];
545
762
  const createGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createGenerations_ConfigPropertyMetadata);
546
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(createGenerations_ConfigPropertyMetadata);
763
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(createGenerations_ConfigPropertyMetadata);
547
764
  function typeCheckConfig$1(untrustedConfig) {
548
765
  const config = {};
549
766
  const untrustedConfig_generationsInput = untrustedConfig.generationsInput;
@@ -896,10 +1113,10 @@ const createGenerationsForPromptTemplate_ConfigPropertyMetadata = [
896
1113
  generateParamConfigMetadata('promptTemplateGenerationsInput', true, 2 /* Body */, 4 /* Unsupported */),
897
1114
  ];
898
1115
  const createGenerationsForPromptTemplate_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
899
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1116
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
900
1117
  function typeCheckConfig(untrustedConfig) {
901
1118
  const config = {};
902
- typeCheckConfig$2(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1119
+ typeCheckConfig$3(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
903
1120
  const untrustedConfig_promptTemplateGenerationsInput = untrustedConfig.promptTemplateGenerationsInput;
904
1121
  const referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError = validate$1(untrustedConfig_promptTemplateGenerationsInput);
905
1122
  if (referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError === null) {
@@ -949,6 +1166,7 @@ const createGenerationsForPromptTemplateAdapterFactory = (luvio) => {
949
1166
  };
950
1167
  };
951
1168
 
1169
+ let createFeedback;
952
1170
  let createGenerations;
953
1171
  let createGenerationsForPromptTemplate;
954
1172
  function bindExportsTo(luvio) {
@@ -957,6 +1175,7 @@ function bindExportsTo(luvio) {
957
1175
  return (config) => adapter(config).then(snapshot => snapshot.data);
958
1176
  }
959
1177
  return {
1178
+ createFeedback: unwrapSnapshotData(createFeedbackAdapterFactory),
960
1179
  createGenerations: unwrapSnapshotData(createGenerationsAdapterFactory),
961
1180
  createGenerationsForPromptTemplate: unwrapSnapshotData(createGenerationsForPromptTemplateAdapterFactory),
962
1181
  // Imperative GET Adapters
@@ -964,10 +1183,11 @@ function bindExportsTo(luvio) {
964
1183
  }
965
1184
  withDefaultLuvio((luvio) => {
966
1185
  ({
1186
+ createFeedback,
967
1187
  createGenerations,
968
1188
  createGenerationsForPromptTemplate,
969
1189
  } = bindExportsTo(luvio));
970
1190
  });
971
1191
 
972
- export { createGenerations, createGenerationsForPromptTemplate };
973
- // version: 1.229.0-dev3-71194d134
1192
+ export { createFeedback, createGenerations, createGenerationsForPromptTemplate };
1193
+ // version: 1.229.0-dev5-577daa79a
package/src/raml/api.raml CHANGED
@@ -91,6 +91,49 @@ types:
91
91
  format: double
92
92
  type: number
93
93
  required: false # TODO Hand-rolled W-9314597
94
+ # TODO Hand-rolled W-8334626
95
+ # Need to manually wrap the input representation with what the aura controller is expecting
96
+ EinsteinLlmFeedbackWrapperRepresentation:
97
+ description: Input wrapper for feedback representation
98
+ type: object
99
+ properties:
100
+ feedbackInput:
101
+ description: Set the parameters for feedback
102
+ type: EinsteinLlmFeedbackInputRepresentation
103
+ EinsteinLlmFeedbackInputRepresentation:
104
+ description: Input representation for Feedback with Einstein LLM
105
+ type: object
106
+ properties:
107
+ appFeedback:
108
+ description: app feedback map
109
+ type: object
110
+ required: false # TODO Hand-rolled W-9314597
111
+ properties:
112
+ //:
113
+ type: object
114
+ feedback:
115
+ description: feedback
116
+ type: string
117
+ required: false # TODO Hand-rolled W-9314597
118
+ feedbackText:
119
+ description: Feedback Text
120
+ type: string
121
+ generationId:
122
+ description: Generation Id - Generations.response.id
123
+ type: string
124
+ id:
125
+ description: Feedback id
126
+ type: string
127
+ source:
128
+ description: Feedback source
129
+ type: string
130
+ EinsteinLlmFeedbackRepresentation:
131
+ description: Output of a einstein llm feedback call
132
+ type: object
133
+ properties:
134
+ message:
135
+ description: Response text of the feedback API
136
+ type: string
94
137
  # Hand-rolled remove all EinsteinLlmEmbedding*Representation types; not in scope for current work
95
138
  EinsteinLlmGenerationItemRepresentation:
96
139
  description: Output of a einstein llm generation item response
@@ -254,6 +297,20 @@ types:
254
297
  application/json:
255
298
  type: EinsteinLlmGenerationsInputWrapperRepresentation
256
299
  (oas-body-name): generationsInput
300
+ /feedback:
301
+ post:
302
+ displayName: postEinsteinLlmFeedback
303
+ description: Send feedback for a generations.response object
304
+ responses:
305
+ '200':
306
+ description: Success
307
+ body:
308
+ application/json:
309
+ type: EinsteinLlmFeedbackRepresentation
310
+ body:
311
+ application/json:
312
+ type: EinsteinLlmFeedbackWrapperRepresentation
313
+ (oas-body-name): feedbackInput
257
314
  /prompt-templates/{promptTemplateDevName}/generations:
258
315
  post:
259
316
  displayName: postEinsteinPromptTemplateGenerations
@@ -15,6 +15,10 @@ types:
15
15
  (luvio.ttl): 100
16
16
  (luvio.key):
17
17
  requestId: requestId
18
+ EinsteinLlmFeedbackRepresentation:
19
+ (luvio.ttl): 100
20
+ (luvio.key):
21
+ message: message
18
22
 
19
23
  /einstein/llm/prompt/generations:
20
24
  post:
@@ -25,3 +29,8 @@ types:
25
29
  post:
26
30
  (luvio.adapter):
27
31
  name: createGenerationsForPromptTemplate
32
+
33
+ /einstein/llm/feedback:
34
+ post:
35
+ (luvio.adapter):
36
+ name: createFeedback