@salesforce/lds-adapters-service-einsteinllm 1.242.1 → 1.244.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.
@@ -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,219 @@ 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/v60.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
+ })();
633
+ return v_error === undefined ? null : v_error;
634
+ }
635
+
636
+ const TTL$1 = 100;
637
+ const VERSION$1 = "4033328f65865dd5d80c68a7573a4522";
638
+ function validate$3(obj, path = 'EinsteinLlmFeedbackRepresentation') {
639
+ const v_error = (() => {
640
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
641
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
642
+ }
643
+ const obj_message = obj.message;
644
+ const path_message = path + '.message';
645
+ if (typeof obj_message !== 'string') {
646
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
647
+ }
648
+ })();
649
+ return v_error === undefined ? null : v_error;
650
+ }
651
+ const RepresentationType$1 = 'EinsteinLlmFeedbackRepresentation';
652
+ function keyBuilder$1(luvio, config) {
653
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.message;
654
+ }
655
+ function keyBuilderFromType$1(luvio, object) {
656
+ const keyParams = {
657
+ message: object.message
658
+ };
659
+ return keyBuilder$1(luvio, keyParams);
660
+ }
661
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
662
+ return input;
663
+ }
664
+ const select$3 = function EinsteinLlmFeedbackRepresentationSelect() {
665
+ return {
666
+ kind: 'Fragment',
667
+ version: VERSION$1,
668
+ private: [],
669
+ selections: [
670
+ {
671
+ name: 'message',
672
+ kind: 'Scalar'
673
+ }
674
+ ]
675
+ };
676
+ };
677
+ function equals$1(existing, incoming) {
678
+ const existing_message = existing.message;
679
+ const incoming_message = incoming.message;
680
+ if (!(existing_message === incoming_message)) {
681
+ return false;
682
+ }
683
+ return true;
684
+ }
685
+ const ingest$1 = function EinsteinLlmFeedbackRepresentationIngest(input, path, luvio, store, timestamp) {
474
686
  if (process.env.NODE_ENV !== 'production') {
475
687
  const validateError = validate$3(input);
476
688
  if (validateError !== null) {
@@ -519,7 +731,7 @@ function createResourceRequest$1(config) {
519
731
  const headers = {};
520
732
  return {
521
733
  baseUri: '/services/data/v60.0',
522
- basePath: '/einstein/llm/prompt/generations',
734
+ basePath: '/einstein/llm/feedback',
523
735
  method: 'post',
524
736
  body: config.body,
525
737
  urlParams: {},
@@ -529,18 +741,18 @@ function createResourceRequest$1(config) {
529
741
  };
530
742
  }
531
743
 
532
- const adapterName$1 = 'createGenerations';
533
- const createGenerations_ConfigPropertyMetadata = [
534
- generateParamConfigMetadata('generationsInput', true, 2 /* Body */, 4 /* Unsupported */),
744
+ const adapterName$1 = 'createFeedback';
745
+ const createFeedback_ConfigPropertyMetadata = [
746
+ generateParamConfigMetadata('feedbackInput', true, 2 /* Body */, 4 /* Unsupported */),
535
747
  ];
536
- const createGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createGenerations_ConfigPropertyMetadata);
537
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(createGenerations_ConfigPropertyMetadata);
748
+ const createFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createFeedback_ConfigPropertyMetadata);
749
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(createFeedback_ConfigPropertyMetadata);
538
750
  function typeCheckConfig$1(untrustedConfig) {
539
751
  const config = {};
540
- const untrustedConfig_generationsInput = untrustedConfig.generationsInput;
541
- const referenceEinsteinLlmGenerationsInputRepresentationValidationError = validate$6(untrustedConfig_generationsInput);
542
- if (referenceEinsteinLlmGenerationsInputRepresentationValidationError === null) {
543
- config.generationsInput = untrustedConfig_generationsInput;
752
+ const untrustedConfig_feedbackInput = untrustedConfig.feedbackInput;
753
+ const referenceEinsteinLlmFeedbackInputRepresentationValidationError = validate$4(untrustedConfig_feedbackInput);
754
+ if (referenceEinsteinLlmFeedbackInputRepresentationValidationError === null) {
755
+ config.feedbackInput = untrustedConfig_feedbackInput;
544
756
  }
545
757
  return config;
546
758
  }
@@ -575,12 +787,12 @@ function buildNetworkSnapshot$1(luvio, config, options) {
575
787
  throw response;
576
788
  });
577
789
  }
578
- const createGenerationsAdapterFactory = (luvio) => {
579
- return function createGenerations(untrustedConfig) {
580
- const config = validateAdapterConfig$1(untrustedConfig, createGenerations_ConfigPropertyNames);
790
+ const createFeedbackAdapterFactory = (luvio) => {
791
+ return function createFeedback(untrustedConfig) {
792
+ const config = validateAdapterConfig$1(untrustedConfig, createFeedback_ConfigPropertyNames);
581
793
  // Invalid or incomplete config
582
794
  if (config === null) {
583
- throw new Error('Invalid config for "createGenerations"');
795
+ throw new Error('Invalid config for "createFeedback"');
584
796
  }
585
797
  return buildNetworkSnapshot$1(luvio, config);
586
798
  };
@@ -617,7 +829,7 @@ function validate$1(obj, path = 'EinsteinPromptTemplateGenerationsInputRepresent
617
829
  if (obj.additionalConfig !== undefined) {
618
830
  const obj_additionalConfig = obj.additionalConfig;
619
831
  const path_additionalConfig = path + '.additionalConfig';
620
- const referencepath_additionalConfigValidationError = validate$7(obj_additionalConfig, path_additionalConfig);
832
+ const referencepath_additionalConfigValidationError = validate$9(obj_additionalConfig, path_additionalConfig);
621
833
  if (referencepath_additionalConfigValidationError !== null) {
622
834
  let message = 'Object doesn\'t match EinsteinLlmAdditionalConfigInputRepresentation (at "' + path_additionalConfig + '")\n';
623
835
  message += referencepath_additionalConfigValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -663,7 +875,7 @@ function validate(obj, path = 'EinsteinPromptTemplateGenerationsRepresentation')
663
875
  for (let i = 0; i < obj_generations.length; i++) {
664
876
  const obj_generations_item = obj_generations[i];
665
877
  const path_generations_item = path_generations + '[' + i + ']';
666
- const referencepath_generations_itemValidationError = validate$5(obj_generations_item, path_generations_item);
878
+ const referencepath_generations_itemValidationError = validate$7(obj_generations_item, path_generations_item);
667
879
  if (referencepath_generations_itemValidationError !== null) {
668
880
  let message = 'Object doesn\'t match EinsteinLlmGenerationItemRepresentation (at "' + path_generations_item + '")\n';
669
881
  message += referencepath_generations_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -674,7 +886,7 @@ function validate(obj, path = 'EinsteinPromptTemplateGenerationsRepresentation')
674
886
  const path_parameters = path + '.parameters';
675
887
  let obj_parameters_union0 = null;
676
888
  const obj_parameters_union0_error = (() => {
677
- const referencepath_parametersValidationError = validate$4(obj_parameters, path_parameters);
889
+ const referencepath_parametersValidationError = validate$6(obj_parameters, path_parameters);
678
890
  if (referencepath_parametersValidationError !== null) {
679
891
  let message = 'Object doesn\'t match WrappedMap (at "' + path_parameters + '")\n';
680
892
  message += referencepath_parametersValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -752,8 +964,8 @@ function normalize(input, existing, path, luvio, store, timestamp) {
752
964
  return input;
753
965
  }
754
966
  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();
967
+ const { selections: EinsteinLlmGenerationItemRepresentation__selections, opaque: EinsteinLlmGenerationItemRepresentation__opaque, } = select$7();
968
+ const { selections: WrappedMap__selections, opaque: WrappedMap__opaque, } = select$6();
757
969
  return {
758
970
  kind: 'Fragment',
759
971
  version: VERSION,
@@ -800,7 +1012,7 @@ function equals(existing, incoming) {
800
1012
  const existing_generations = existing.generations;
801
1013
  const incoming_generations = incoming.generations;
802
1014
  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))) {
1015
+ if (!(equals$4(existing_generations_item, incoming_generations_item))) {
804
1016
  return false;
805
1017
  }
806
1018
  });
@@ -812,7 +1024,7 @@ function equals(existing, incoming) {
812
1024
  if (!(existing_parameters === incoming_parameters
813
1025
  || (existing_parameters != null &&
814
1026
  incoming_parameters != null &&
815
- equals$2(existing_parameters, incoming_parameters)))) {
1027
+ equals$3(existing_parameters, incoming_parameters)))) {
816
1028
  return false;
817
1029
  }
818
1030
  const existing_prompt = existing.prompt;
@@ -887,10 +1099,10 @@ const createGenerationsForPromptTemplate_ConfigPropertyMetadata = [
887
1099
  generateParamConfigMetadata('promptTemplateGenerationsInput', true, 2 /* Body */, 4 /* Unsupported */),
888
1100
  ];
889
1101
  const createGenerationsForPromptTemplate_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
890
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1102
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
891
1103
  function typeCheckConfig(untrustedConfig) {
892
1104
  const config = {};
893
- typeCheckConfig$2(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1105
+ typeCheckConfig$3(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
894
1106
  const untrustedConfig_promptTemplateGenerationsInput = untrustedConfig.promptTemplateGenerationsInput;
895
1107
  const referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError = validate$1(untrustedConfig_promptTemplateGenerationsInput);
896
1108
  if (referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError === null) {
@@ -940,4 +1152,4 @@ const createGenerationsForPromptTemplateAdapterFactory = (luvio) => {
940
1152
  };
941
1153
  };
942
1154
 
943
- export { createGenerationsAdapterFactory, createGenerationsForPromptTemplateAdapterFactory };
1155
+ 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,44 @@
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 = "d8791823dc6a931709bc42ac1d0bd098";
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
+ }
30
+ /**
31
+ * Input representation for Feedback with Einstein LLM
32
+ *
33
+ * Keys:
34
+ * (none)
35
+ */
36
+ export interface EinsteinLlmFeedbackInputRepresentation {
37
+ appFeedback?: {
38
+ [key: string]: {};
39
+ };
40
+ feedback?: string;
41
+ feedbackText: string;
42
+ generationId: string;
43
+ id: string;
44
+ }
@@ -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.242.1",
3
+ "version": "1.244.0",
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",
@@ -32,7 +32,7 @@
32
32
  "kkasimala@salesforce.com"
33
33
  ],
34
34
  "scripts": {
35
- "build": "yarn build:raml && yarn build:services && yarn build:karma",
35
+ "build": "yarn build:services && yarn build:karma",
36
36
  "build:karma": "rollup --bundleConfigAsCjs --config rollup.config.karma.js",
37
37
  "build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
38
38
  "build:services": "rollup --bundleConfigAsCjs --config rollup.config.js",
@@ -56,7 +56,11 @@
56
56
  "outputs": [
57
57
  "{projectRoot}/dist",
58
58
  "{projectRoot}/karma/dist",
59
- "{projectRoot}/sfdc",
59
+ "{projectRoot}/sfdc"
60
+ ]
61
+ },
62
+ "build:raml": {
63
+ "outputs": [
60
64
  "{projectRoot}/src/generated"
61
65
  ]
62
66
  }
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,218 @@ 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
+ })();
160
+ return v_error === undefined ? null : v_error;
161
+ }
162
+
163
+ const TTL$2 = 100;
164
+ const VERSION$4 = "4033328f65865dd5d80c68a7573a4522";
165
+ function validate$8(obj, path = 'EinsteinLlmFeedbackRepresentation') {
166
+ const v_error = (() => {
167
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
168
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
169
+ }
170
+ const obj_message = obj.message;
171
+ const path_message = path + '.message';
172
+ if (typeof obj_message !== 'string') {
173
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
174
+ }
175
+ })();
176
+ return v_error === undefined ? null : v_error;
177
+ }
178
+ const RepresentationType$2 = 'EinsteinLlmFeedbackRepresentation';
179
+ function keyBuilder$2(luvio, config) {
180
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.message;
181
+ }
182
+ function keyBuilderFromType$2(luvio, object) {
183
+ const keyParams = {
184
+ message: object.message
185
+ };
186
+ return keyBuilder$2(luvio, keyParams);
187
+ }
188
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
189
+ return input;
190
+ }
191
+ const select$7 = function EinsteinLlmFeedbackRepresentationSelect() {
192
+ return {
193
+ kind: 'Fragment',
194
+ version: VERSION$4,
195
+ private: [],
196
+ selections: [
197
+ {
198
+ name: 'message',
199
+ kind: 'Scalar'
200
+ }
201
+ ]
202
+ };
203
+ };
204
+ function equals$4(existing, incoming) {
205
+ const existing_message = existing.message;
206
+ const incoming_message = incoming.message;
207
+ if (!(existing_message === incoming_message)) {
208
+ return false;
209
+ }
210
+ return true;
211
+ }
212
+ const ingest$2 = function EinsteinLlmFeedbackRepresentationIngest(input, path, luvio, store, timestamp) {
213
+ if (process.env.NODE_ENV !== 'production') {
214
+ const validateError = validate$8(input);
215
+ if (validateError !== null) {
216
+ throw validateError;
217
+ }
218
+ }
219
+ const key = keyBuilderFromType$2(luvio, input);
220
+ const ttlToUse = TTL$2;
221
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "EinsteinLLM", VERSION$4, RepresentationType$2, equals$4);
222
+ return createLink(key);
223
+ };
224
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
225
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
226
+ const rootKey = keyBuilderFromType$2(luvio, input);
227
+ rootKeySet.set(rootKey, {
228
+ namespace: keyPrefix,
229
+ representationName: RepresentationType$2,
230
+ mergeable: false
231
+ });
232
+ }
233
+
234
+ function select$6(luvio, params) {
235
+ return select$7();
236
+ }
237
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
238
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
239
+ }
240
+ function ingestSuccess$2(luvio, resourceParams, response) {
241
+ const { body } = response;
242
+ const key = keyBuilderFromType$2(luvio, body);
243
+ luvio.storeIngest(key, ingest$2, body);
244
+ const snapshot = luvio.storeLookup({
245
+ recordId: key,
246
+ node: select$6(),
247
+ variables: {},
248
+ });
249
+ if (process.env.NODE_ENV !== 'production') {
250
+ if (snapshot.state !== 'Fulfilled') {
251
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
252
+ }
253
+ }
254
+ deepFreeze(snapshot.data);
255
+ return snapshot;
256
+ }
257
+ function createResourceRequest$2(config) {
258
+ const headers = {};
259
+ return {
260
+ baseUri: '/services/data/v60.0',
261
+ basePath: '/einstein/llm/feedback',
262
+ method: 'post',
263
+ body: config.body,
264
+ urlParams: {},
265
+ queryParams: {},
266
+ headers,
267
+ priority: 'normal',
268
+ };
269
+ }
270
+
271
+ const adapterName$2 = 'createFeedback';
272
+ const createFeedback_ConfigPropertyMetadata = [
273
+ generateParamConfigMetadata('feedbackInput', true, 2 /* Body */, 4 /* Unsupported */),
274
+ ];
275
+ const createFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, createFeedback_ConfigPropertyMetadata);
276
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(createFeedback_ConfigPropertyMetadata);
277
+ function typeCheckConfig$2(untrustedConfig) {
278
+ const config = {};
279
+ const untrustedConfig_feedbackInput = untrustedConfig.feedbackInput;
280
+ const referenceEinsteinLlmFeedbackInputRepresentationValidationError = validate$9(untrustedConfig_feedbackInput);
281
+ if (referenceEinsteinLlmFeedbackInputRepresentationValidationError === null) {
282
+ config.feedbackInput = untrustedConfig_feedbackInput;
283
+ }
284
+ return config;
285
+ }
286
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
287
+ if (!untrustedIsObject(untrustedConfig)) {
288
+ return null;
289
+ }
290
+ if (process.env.NODE_ENV !== 'production') {
291
+ validateConfig(untrustedConfig, configPropertyNames);
292
+ }
293
+ const config = typeCheckConfig$2(untrustedConfig);
294
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
295
+ return null;
296
+ }
297
+ return config;
298
+ }
299
+ function buildNetworkSnapshot$2(luvio, config, options) {
300
+ const resourceParams = createResourceParams$2(config);
301
+ const request = createResourceRequest$2(resourceParams);
302
+ return luvio.dispatchResourceRequest(request, options)
303
+ .then((response) => {
304
+ return luvio.handleSuccessResponse(() => {
305
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
306
+ return luvio.storeBroadcast().then(() => snapshot);
307
+ }, () => {
308
+ const cache = new StoreKeyMap();
309
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
310
+ return cache;
311
+ });
312
+ }, (response) => {
313
+ deepFreeze(response);
314
+ throw response;
315
+ });
316
+ }
317
+ const createFeedbackAdapterFactory = (luvio) => {
318
+ return function createFeedback(untrustedConfig) {
319
+ const config = validateAdapterConfig$2(untrustedConfig, createFeedback_ConfigPropertyNames);
320
+ // Invalid or incomplete config
321
+ if (config === null) {
322
+ throw new Error('Invalid config for "createFeedback"');
323
+ }
324
+ return buildNetworkSnapshot$2(luvio, config);
325
+ };
326
+ };
327
+
116
328
  function validate$7(obj, path = 'EinsteinLlmAdditionalConfigInputRepresentation') {
117
329
  const v_error = (() => {
118
330
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -543,7 +755,7 @@ const createGenerations_ConfigPropertyMetadata = [
543
755
  generateParamConfigMetadata('generationsInput', true, 2 /* Body */, 4 /* Unsupported */),
544
756
  ];
545
757
  const createGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createGenerations_ConfigPropertyMetadata);
546
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(createGenerations_ConfigPropertyMetadata);
758
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(createGenerations_ConfigPropertyMetadata);
547
759
  function typeCheckConfig$1(untrustedConfig) {
548
760
  const config = {};
549
761
  const untrustedConfig_generationsInput = untrustedConfig.generationsInput;
@@ -896,10 +1108,10 @@ const createGenerationsForPromptTemplate_ConfigPropertyMetadata = [
896
1108
  generateParamConfigMetadata('promptTemplateGenerationsInput', true, 2 /* Body */, 4 /* Unsupported */),
897
1109
  ];
898
1110
  const createGenerationsForPromptTemplate_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
899
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1111
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(createGenerationsForPromptTemplate_ConfigPropertyMetadata);
900
1112
  function typeCheckConfig(untrustedConfig) {
901
1113
  const config = {};
902
- typeCheckConfig$2(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
1114
+ typeCheckConfig$3(untrustedConfig, config, createGenerationsForPromptTemplate_ConfigPropertyMetadata);
903
1115
  const untrustedConfig_promptTemplateGenerationsInput = untrustedConfig.promptTemplateGenerationsInput;
904
1116
  const referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError = validate$1(untrustedConfig_promptTemplateGenerationsInput);
905
1117
  if (referenceEinsteinPromptTemplateGenerationsInputRepresentationValidationError === null) {
@@ -949,6 +1161,7 @@ const createGenerationsForPromptTemplateAdapterFactory = (luvio) => {
949
1161
  };
950
1162
  };
951
1163
 
1164
+ let createFeedback;
952
1165
  let createGenerations;
953
1166
  let createGenerationsForPromptTemplate;
954
1167
  function bindExportsTo(luvio) {
@@ -957,6 +1170,7 @@ function bindExportsTo(luvio) {
957
1170
  return (config) => adapter(config).then(snapshot => snapshot.data);
958
1171
  }
959
1172
  return {
1173
+ createFeedback: unwrapSnapshotData(createFeedbackAdapterFactory),
960
1174
  createGenerations: unwrapSnapshotData(createGenerationsAdapterFactory),
961
1175
  createGenerationsForPromptTemplate: unwrapSnapshotData(createGenerationsForPromptTemplateAdapterFactory),
962
1176
  // Imperative GET Adapters
@@ -964,10 +1178,11 @@ function bindExportsTo(luvio) {
964
1178
  }
965
1179
  withDefaultLuvio((luvio) => {
966
1180
  ({
1181
+ createFeedback,
967
1182
  createGenerations,
968
1183
  createGenerationsForPromptTemplate,
969
1184
  } = bindExportsTo(luvio));
970
1185
  });
971
1186
 
972
- export { createGenerations, createGenerationsForPromptTemplate };
973
- // version: 1.242.1-5a8ee3f4c
1187
+ export { createFeedback, createGenerations, createGenerationsForPromptTemplate };
1188
+ // version: 1.244.0-4d142822f
package/src/raml/api.raml CHANGED
@@ -91,6 +91,46 @@ 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
+ EinsteinLlmFeedbackRepresentation:
128
+ description: Output of a einstein llm feedback call
129
+ type: object
130
+ properties:
131
+ message:
132
+ description: Response text of the feedback API
133
+ type: string
94
134
  # Hand-rolled remove all EinsteinLlmEmbedding*Representation types; not in scope for current work
95
135
  EinsteinLlmGenerationItemRepresentation:
96
136
  description: Output of a einstein llm generation item response
@@ -254,6 +294,20 @@ types:
254
294
  application/json:
255
295
  type: EinsteinLlmGenerationsInputWrapperRepresentation
256
296
  (oas-body-name): generationsInput
297
+ /feedback:
298
+ post:
299
+ displayName: postEinsteinLlmFeedback
300
+ description: Send feedback for a generations.response object
301
+ responses:
302
+ '200':
303
+ description: Success
304
+ body:
305
+ application/json:
306
+ type: EinsteinLlmFeedbackRepresentation
307
+ body:
308
+ application/json:
309
+ type: EinsteinLlmFeedbackWrapperRepresentation
310
+ (oas-body-name): feedbackInput
257
311
  /prompt-templates/{promptTemplateDevName}/generations:
258
312
  post:
259
313
  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