@salesforce/lds-adapters-sfap-einstein-ai-gateway 1.265.0 → 1.266.0-dev10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # SFAP Einstein AI Gateway
2
+
3
+ ## api.raml
4
+
5
+ Einstein AI gateway Wires are based on Salesforce API Platfrom(SFAP) and not Connect API.
6
+ Steps to get RAML for api.raml file
7
+
8
+ 1. Go to Mulesoft Anypoint Exchange
9
+ 2. Search for "EinsteinGPT Foundations LLM Gateway APIs" and click on the item.
10
+ 3. Click on Download button on the page and download "As RAML"
11
+ 4. Mulesoft Generated RAML is not compatible with luvio. Handrolled lots of changes. Please cherry pick the changes, don't copy/paste.
12
+
13
+ ### Update on Dec 14, 2023
14
+
15
+ - As part of addressing the SFAP header issue(W-14663142), we are overriding the createResourceRequest to support the default value for `xSfdcAppContext` header.
16
+ - Once this is addressed with correct fix, please rollback.
17
+ - Steps followed to override is listed here.
18
+ https://bookish-sniffle-l8vm2yq.pages.github.io/#/how-to/override-generated-code
@@ -4,11 +4,10 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
11
- const { stringify: JSONStringify$1 } = JSON;
12
11
  const { isArray: ArrayIsArray$1 } = Array;
13
12
  /**
14
13
  * Validates an adapter config is well-formed.
@@ -42,68 +41,6 @@ function untrustedIsObject(untrusted) {
42
41
  function areRequiredParametersPresent(config, configPropertyNames) {
43
42
  return configPropertyNames.parameters.required.every(req => req in config);
44
43
  }
45
- const snapshotRefreshOptions = {
46
- overrides: {
47
- headers: {
48
- 'Cache-Control': 'no-cache',
49
- },
50
- }
51
- };
52
- /**
53
- * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
54
- * This is needed because insertion order for JSON.stringify(object) affects output:
55
- * JSON.stringify({a: 1, b: 2})
56
- * "{"a":1,"b":2}"
57
- * JSON.stringify({b: 2, a: 1})
58
- * "{"b":2,"a":1}"
59
- * @param data Data to be JSON-stringified.
60
- * @returns JSON.stringified value with consistent ordering of keys.
61
- */
62
- function stableJSONStringify(node) {
63
- // This is for Date values.
64
- if (node && node.toJSON && typeof node.toJSON === 'function') {
65
- // eslint-disable-next-line no-param-reassign
66
- node = node.toJSON();
67
- }
68
- if (node === undefined) {
69
- return;
70
- }
71
- if (typeof node === 'number') {
72
- return isFinite(node) ? '' + node : 'null';
73
- }
74
- if (typeof node !== 'object') {
75
- return JSONStringify$1(node);
76
- }
77
- let i;
78
- let out;
79
- if (ArrayIsArray$1(node)) {
80
- out = '[';
81
- for (i = 0; i < node.length; i++) {
82
- if (i) {
83
- out += ',';
84
- }
85
- out += stableJSONStringify(node[i]) || 'null';
86
- }
87
- return out + ']';
88
- }
89
- if (node === null) {
90
- return 'null';
91
- }
92
- const keys = ObjectKeys$1(node).sort();
93
- out = '';
94
- for (i = 0; i < keys.length; i++) {
95
- const key = keys[i];
96
- const value = stableJSONStringify(node[key]);
97
- if (!value) {
98
- continue;
99
- }
100
- if (out) {
101
- out += ',';
102
- }
103
- out += JSONStringify$1(key) + ':' + value;
104
- }
105
- return '{' + out + '}';
106
- }
107
44
  function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
108
45
  return {
109
46
  name,
@@ -622,7 +559,8 @@ function equals$2(existing, incoming) {
622
559
  return true;
623
560
  }
624
561
 
625
- const VERSION$1 = "4f085d3ce8f948d5a3d38e9e24ce4f63";
562
+ const TTL$1 = 100;
563
+ const VERSION$1 = "ad6b1f255df73e241341ce190bfafe29";
626
564
  function validate$1(obj, path = 'GenerationResponse') {
627
565
  const v_error = (() => {
628
566
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -696,6 +634,15 @@ function validate$1(obj, path = 'GenerationResponse') {
696
634
  return v_error === undefined ? null : v_error;
697
635
  }
698
636
  const RepresentationType$1 = 'GenerationResponse';
637
+ function keyBuilder$1(luvio, config) {
638
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.id;
639
+ }
640
+ function keyBuilderFromType$1(luvio, object) {
641
+ const keyParams = {
642
+ id: object.id
643
+ };
644
+ return keyBuilder$1(luvio, keyParams);
645
+ }
699
646
  function normalize$1(input, existing, path, luvio, store, timestamp) {
700
647
  return input;
701
648
  }
@@ -785,14 +732,14 @@ const ingest$1 = function GenerationResponseIngest(input, path, luvio, store, ti
785
732
  throw validateError;
786
733
  }
787
734
  }
788
- const key = path.fullPath;
789
- const ttlToUse = path.ttl !== undefined ? path.ttl : 100;
735
+ const key = keyBuilderFromType$1(luvio, input);
736
+ const ttlToUse = TTL$1;
790
737
  ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "einstein-ai-gateway", VERSION$1, RepresentationType$1, equals$1);
791
738
  return createLink(key);
792
739
  };
793
740
  function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
794
741
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
795
- const rootKey = fullPathFactory();
742
+ const rootKey = keyBuilderFromType$1(luvio, input);
796
743
  rootKeySet.set(rootKey, {
797
744
  namespace: keyPrefix,
798
745
  representationName: RepresentationType$1,
@@ -803,21 +750,18 @@ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
803
750
  function select$2(luvio, params) {
804
751
  return select$3();
805
752
  }
806
- function keyBuilder$2(luvio, params) {
807
- return keyPrefix + '::GenerationResponse:(' + 'xClientFeatureId:' + params.headers.xClientFeatureId + ',' + 'xLLMProvider:' + params.headers.xLLMProvider + ',' + 'prompt:' + params.body.prompt + '::' + (params.body.num_generations === undefined ? 'num_generations' : 'num_generations:' + params.body.num_generations) + '::' + (params.body.max_tokens === undefined ? 'max_tokens' : 'max_tokens:' + params.body.max_tokens) + '::' + (params.body.enable_pii_masking === undefined ? 'enable_pii_masking' : 'enable_pii_masking:' + params.body.enable_pii_masking) + '::' + (params.body.temperature === undefined ? 'temperature' : 'temperature:' + params.body.temperature) + '::' + (params.body.stop_sequences === undefined ? 'stop_sequences' : 'stop_sequences:' + params.body.stop_sequences) + '::' + (params.body.frequency_penalty === undefined ? 'frequency_penalty' : 'frequency_penalty:' + params.body.frequency_penalty) + '::' + (params.body.presence_penalty === undefined ? 'presence_penalty' : 'presence_penalty:' + params.body.presence_penalty) + '::' + (params.body.model === undefined ? 'model' : 'model:' + params.body.model) + '::' + stableJSONStringify(params.body.parameters) + '::' + stableJSONStringify(params.body.tags) + ')';
808
- }
809
753
  function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
810
- getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
754
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
811
755
  }
812
- function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
756
+ function ingestSuccess$1(luvio, resourceParams, response) {
813
757
  const { body } = response;
814
- const key = keyBuilder$2(luvio, resourceParams);
758
+ const key = keyBuilderFromType$1(luvio, body);
815
759
  luvio.storeIngest(key, ingest$1, body);
816
760
  const snapshot = luvio.storeLookup({
817
761
  recordId: key,
818
762
  node: select$2(),
819
763
  variables: {},
820
- }, snapshotRefresh);
764
+ });
821
765
  if (process.env.NODE_ENV !== 'production') {
822
766
  if (snapshot.state !== 'Fulfilled') {
823
767
  throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
@@ -826,16 +770,18 @@ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
826
770
  deepFreeze(snapshot.data);
827
771
  return snapshot;
828
772
  }
829
- function ingestError(luvio, params, error, snapshotRefresh) {
830
- const key = keyBuilder$2(luvio, params);
831
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
832
- luvio.storeIngestError(key, errorSnapshot);
833
- return errorSnapshot;
834
- }
773
+
835
774
  function createResourceRequest$1(config) {
836
775
  const headers = {};
837
776
  headers['x-client-feature-id'] = config.headers.xClientFeatureId;
838
- headers['x-LLM-Provider'] = config.headers.xLLMProvider;
777
+ const header_xSfdcAppContext = config.headers.xSfdcAppContext || 'EinsteinGPT'; /* Hand rolled default value*/
778
+ if (header_xSfdcAppContext !== undefined) {
779
+ headers['x-sfdc-app-context'] = header_xSfdcAppContext;
780
+ }
781
+ const header_xLLMProvider = config.headers.xLLMProvider;
782
+ if (header_xLLMProvider !== undefined) {
783
+ headers['x-LLM-Provider'] = header_xLLMProvider;
784
+ }
839
785
  return {
840
786
  baseUri: 'api.salesforce.com',
841
787
  basePath: '/ai/gpt/v1/generations',
@@ -862,14 +808,11 @@ const getGenerations_ConfigPropertyMetadata = [
862
808
  generateParamConfigMetadata('parameters', false, 2 /* Body */, 4 /* Unsupported */),
863
809
  generateParamConfigMetadata('tags', false, 2 /* Body */, 4 /* Unsupported */),
864
810
  generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
865
- generateParamConfigMetadata('xLLMProvider', true, 3 /* Header */, 0 /* String */),
811
+ generateParamConfigMetadata('xSfdcAppContext', false, 3 /* Header */, 0 /* String */),
812
+ generateParamConfigMetadata('xLLMProvider', false, 3 /* Header */, 0 /* String */),
866
813
  ];
867
814
  const getGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getGenerations_ConfigPropertyMetadata);
868
815
  const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getGenerations_ConfigPropertyMetadata);
869
- function keyBuilder$1(luvio, config) {
870
- const resourceParams = createResourceParams$1(config);
871
- return keyBuilder$2(luvio, resourceParams);
872
- }
873
816
  function typeCheckConfig$1(untrustedConfig) {
874
817
  const config = {};
875
818
  typeCheckConfig$2(untrustedConfig, config, getGenerations_ConfigPropertyMetadata);
@@ -918,62 +861,33 @@ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
918
861
  }
919
862
  return config;
920
863
  }
921
- function adapterFragment(luvio, config) {
922
- createResourceParams$1(config);
923
- return select$2();
924
- }
925
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
926
- const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
927
- config,
928
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
929
- });
930
- return luvio.storeBroadcast().then(() => snapshot);
931
- }
932
- function onFetchResponseError(luvio, config, resourceParams, response) {
933
- const snapshot = ingestError(luvio, resourceParams, response, {
934
- config,
935
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
936
- });
937
- return luvio.storeBroadcast().then(() => snapshot);
938
- }
939
864
  function buildNetworkSnapshot$1(luvio, config, options) {
940
865
  const resourceParams = createResourceParams$1(config);
941
866
  const request = createResourceRequest$1(resourceParams);
942
867
  return luvio.dispatchResourceRequest(request, options)
943
868
  .then((response) => {
944
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
869
+ return luvio.handleSuccessResponse(() => {
870
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
871
+ return luvio.storeBroadcast().then(() => snapshot);
872
+ }, () => {
945
873
  const cache = new StoreKeyMap();
946
874
  getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
947
875
  return cache;
948
876
  });
949
877
  }, (response) => {
950
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
878
+ deepFreeze(response);
879
+ throw response;
951
880
  });
952
881
  }
953
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
954
- return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, 'get', false);
955
- }
956
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
957
- const { luvio, config } = context;
958
- const selector = {
959
- recordId: keyBuilder$1(luvio, config),
960
- node: adapterFragment(luvio, config),
961
- variables: {},
882
+ const getGenerationsAdapterFactory = (luvio) => {
883
+ return function getGenerations(untrustedConfig) {
884
+ const config = validateAdapterConfig$1(untrustedConfig, getGenerations_ConfigPropertyNames);
885
+ // Invalid or incomplete config
886
+ if (config === null) {
887
+ throw new Error('Invalid config for "getGenerations"');
888
+ }
889
+ return buildNetworkSnapshot$1(luvio, config);
962
890
  };
963
- const cacheSnapshot = storeLookup(selector, {
964
- config,
965
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
966
- });
967
- return cacheSnapshot;
968
- }
969
- const getGenerationsAdapterFactory = (luvio) => function einsteinAiGateway__getGenerations(untrustedConfig, requestContext) {
970
- const config = validateAdapterConfig$1(untrustedConfig, getGenerations_ConfigPropertyNames);
971
- // Invalid or incomplete config
972
- if (config === null) {
973
- return null;
974
- }
975
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
976
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
977
891
  };
978
892
 
979
893
  const TTL = 100;
@@ -1070,9 +984,12 @@ function ingestSuccess(luvio, resourceParams, response) {
1070
984
  deepFreeze(snapshot.data);
1071
985
  return snapshot;
1072
986
  }
987
+
1073
988
  function createResourceRequest(config) {
1074
989
  const headers = {};
1075
990
  headers['x-client-feature-id'] = config.headers.xClientFeatureId;
991
+ headers['x-sfdc-app-context'] =
992
+ config.headers.xSfdcAppContext || 'EinsteinGPT'; /* Hand rolled default value*/
1076
993
  return {
1077
994
  baseUri: 'api.salesforce.com',
1078
995
  basePath: '/ai/gpt/v1/feedback',
@@ -1088,12 +1005,16 @@ function createResourceRequest(config) {
1088
1005
  const adapterName = 'registerFeedback';
1089
1006
  const registerFeedback_ConfigPropertyMetadata = [
1090
1007
  generateParamConfigMetadata('id', true, 2 /* Body */, 0 /* String */),
1091
- generateParamConfigMetadata('generation_id', true, 2 /* Body */, 0 /* String */),
1008
+ generateParamConfigMetadata('generation_id', false, 2 /* Body */, 0 /* String */),
1009
+ generateParamConfigMetadata('turn_id', false, 2 /* Body */, 0 /* String */),
1010
+ generateParamConfigMetadata('app_generation_id', false, 2 /* Body */, 0 /* String */),
1011
+ generateParamConfigMetadata('app_generation', false, 2 /* Body */, 0 /* String */),
1092
1012
  generateParamConfigMetadata('feedback', false, 2 /* Body */, 4 /* Unsupported */),
1093
1013
  generateParamConfigMetadata('feedback_text', false, 2 /* Body */, 0 /* String */),
1094
1014
  generateParamConfigMetadata('source', false, 2 /* Body */, 0 /* String */),
1095
1015
  generateParamConfigMetadata('app_feedback', false, 2 /* Body */, 4 /* Unsupported */),
1096
1016
  generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
1017
+ generateParamConfigMetadata('xSfdcAppContext', false, 3 /* Header */, 0 /* String */),
1097
1018
  ];
1098
1019
  const registerFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, registerFeedback_ConfigPropertyMetadata);
1099
1020
  const createResourceParams = /*#__PURE__*/ createResourceParams$2(registerFeedback_ConfigPropertyMetadata);
@@ -1,4 +1,4 @@
1
- import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Fragment as $64$luvio_engine_Fragment, Snapshot as $64$luvio_engine_Snapshot, FetchResponse as $64$luvio_engine_FetchResponse, ErrorResponse as $64$luvio_engine_ErrorResponse, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, CoercedAdapterRequestContext as $64$luvio_engine_CoercedAdapterRequestContext, StoreLookup as $64$luvio_engine_StoreLookup, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
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
2
  import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
3
3
  import { ResourceRequestConfig as resources_postAiGptV1Generations_ResourceRequestConfig } from '../resources/postAiGptV1Generations';
4
4
  import { GenerationResponse as types_GenerationResponse_GenerationResponse } from '../types/GenerationResponse';
@@ -7,7 +7,8 @@ export declare const getGenerations_ConfigPropertyMetadata: $64$luvio_engine_Ada
7
7
  export declare const getGenerations_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
8
  export interface GetGenerationsConfig {
9
9
  xClientFeatureId: string;
10
- xLLMProvider: string;
10
+ xSfdcAppContext?: string;
11
+ xLLMProvider?: string;
11
12
  prompt: string;
12
13
  num_generations?: number;
13
14
  max_tokens?: number;
@@ -25,19 +26,7 @@ export interface GetGenerationsConfig {
25
26
  };
26
27
  }
27
28
  export declare const createResourceParams: (config: GetGenerationsConfig) => resources_postAiGptV1Generations_ResourceRequestConfig;
28
- export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig): string;
29
- export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig): $64$luvio_engine_NormalizedKeyMetadata;
30
29
  export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<GetGenerationsConfig>): adapter$45$utils_Untrusted<GetGenerationsConfig>;
31
30
  export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): GetGenerationsConfig | null;
32
- export declare function adapterFragment(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig): $64$luvio_engine_Fragment;
33
- export declare function buildCachedSnapshot(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig): $64$luvio_engine_Snapshot<types_GenerationResponse_GenerationResponse, any>;
34
- export declare function onFetchResponseSuccess(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig, resourceParams: resources_postAiGptV1Generations_ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_GenerationResponse_GenerationResponse>): Promise<import("@luvio/engine").FulfilledSnapshot<types_GenerationResponse_GenerationResponse, {}> | import("@luvio/engine").StaleSnapshot<types_GenerationResponse_GenerationResponse, {}> | import("@luvio/engine").PendingSnapshot<types_GenerationResponse_GenerationResponse, any>>;
35
- export declare function onFetchResponseError(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig, resourceParams: resources_postAiGptV1Generations_ResourceRequestConfig, response: $64$luvio_engine_ErrorResponse): Promise<import("@luvio/engine").ErrorSnapshot>;
36
- export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<$64$luvio_engine_Snapshot<types_GenerationResponse_GenerationResponse, any>>;
37
- export type BuildSnapshotContext = {
38
- luvio: $64$luvio_engine_Luvio;
39
- config: GetGenerationsConfig;
40
- };
41
- export declare function buildNetworkSnapshotCachePolicy(context: BuildSnapshotContext, coercedAdapterRequestContext: $64$luvio_engine_CoercedAdapterRequestContext): Promise<$64$luvio_engine_Snapshot<types_GenerationResponse_GenerationResponse, any>>;
42
- export declare function buildCachedSnapshotCachePolicy(context: BuildSnapshotContext, storeLookup: $64$luvio_engine_StoreLookup<types_GenerationResponse_GenerationResponse>): $64$luvio_engine_Snapshot<types_GenerationResponse_GenerationResponse, any>;
31
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: GetGenerationsConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_GenerationResponse_GenerationResponse, {}> | import("@luvio/engine").StaleSnapshot<types_GenerationResponse_GenerationResponse, {}> | import("@luvio/engine").PendingSnapshot<types_GenerationResponse_GenerationResponse, any>>;
43
32
  export declare const getGenerationsAdapterFactory: $64$luvio_engine_AdapterFactory<GetGenerationsConfig, types_GenerationResponse_GenerationResponse>;
@@ -7,8 +7,12 @@ export declare const registerFeedback_ConfigPropertyMetadata: $64$luvio_engine_A
7
7
  export declare const registerFeedback_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
8
  export interface RegisterFeedbackConfig {
9
9
  xClientFeatureId: string;
10
+ xSfdcAppContext?: string;
10
11
  id: string;
11
- generation_id: string;
12
+ generation_id?: string;
13
+ turn_id?: string;
14
+ app_generation_id?: string;
15
+ app_generation?: string;
12
16
  feedback?: string | null;
13
17
  feedback_text?: string;
14
18
  source?: string;
@@ -1,4 +1,3 @@
1
1
  declare let getGenerations: any;
2
2
  declare let registerFeedback: any;
3
- declare let getGenerations_imperative: any;
4
- export { getGenerations, registerFeedback, getGenerations_imperative };
3
+ export { getGenerations, registerFeedback };
@@ -3,7 +3,10 @@ import { FeedbackResponseRepresentation as types_FeedbackResponseRepresentation_
3
3
  export interface ResourceRequestConfig {
4
4
  body: {
5
5
  id: string;
6
- generation_id: string;
6
+ generation_id?: string;
7
+ turn_id?: string;
8
+ app_generation_id?: string;
9
+ app_generation?: string;
7
10
  feedback?: string | null;
8
11
  feedback_text?: string;
9
12
  source?: string;
@@ -13,6 +16,7 @@ export interface ResourceRequestConfig {
13
16
  };
14
17
  headers: {
15
18
  xClientFeatureId: string;
19
+ xSfdcAppContext?: string;
16
20
  };
17
21
  }
18
22
  export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
@@ -1,4 +1,4 @@
1
- import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, FetchResponse as $64$luvio_engine_FetchResponse, SnapshotRefresh as $64$luvio_engine_SnapshotRefresh, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ErrorResponse as $64$luvio_engine_ErrorResponse, ErrorSnapshot as $64$luvio_engine_ErrorSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
1
+ 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';
2
2
  import { GenerationResponse as types_GenerationResponse_GenerationResponse } from '../types/GenerationResponse';
3
3
  export interface ResourceRequestConfig {
4
4
  body: {
@@ -20,14 +20,12 @@ export interface ResourceRequestConfig {
20
20
  };
21
21
  headers: {
22
22
  xClientFeatureId: string;
23
- xLLMProvider: string;
23
+ xSfdcAppContext?: string;
24
+ xLLMProvider?: string;
24
25
  };
25
26
  }
26
27
  export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
27
- export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): string;
28
- export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_NormalizedKeyMetadata;
29
28
  export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_GenerationResponse_GenerationResponse): void;
30
- export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_GenerationResponse_GenerationResponse>, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_GenerationResponse_GenerationResponse>): $64$luvio_engine_FulfilledSnapshot<types_GenerationResponse_GenerationResponse, {}> | $64$luvio_engine_StaleSnapshot<types_GenerationResponse_GenerationResponse, {}> | $64$luvio_engine_PendingSnapshot<types_GenerationResponse_GenerationResponse, any>;
31
- export declare function ingestError(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig, error: $64$luvio_engine_ErrorResponse, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_GenerationResponse_GenerationResponse>): $64$luvio_engine_ErrorSnapshot;
29
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_GenerationResponse_GenerationResponse>): $64$luvio_engine_FulfilledSnapshot<types_GenerationResponse_GenerationResponse, {}> | $64$luvio_engine_StaleSnapshot<types_GenerationResponse_GenerationResponse, {}> | $64$luvio_engine_PendingSnapshot<types_GenerationResponse_GenerationResponse, any>;
32
30
  export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
33
31
  export default createResourceRequest;
@@ -1,5 +1,5 @@
1
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 = "677aa3c947477cdf2196296053ea3a8d";
2
+ export declare const VERSION = "1ab8d6091197e3772731210a2d3678a9";
3
3
  export declare function validate(obj: any, path?: string): TypeError | null;
4
4
  export declare const RepresentationType: string;
5
5
  export declare function normalize(input: FeedbackRequest, existing: FeedbackRequestNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): FeedbackRequestNormalized;
@@ -18,16 +18,22 @@ export interface FeedbackRequestNormalized {
18
18
  app_feedback?: {
19
19
  [key: string]: unknown;
20
20
  };
21
+ /** The app-specific generation text to support cases where the client further splits a generation into multiple generations. */
22
+ app_generation?: string;
23
+ /** The app-specific generation ID to support cases where client further split a generation into multiple generations. */
24
+ app_generation_id?: string;
21
25
  /** The feedback sentiment. Can be `null`. */
22
26
  feedback?: string | null;
23
27
  /** The textual representation of the feedback as provided by the user. */
24
28
  feedback_text?: string;
25
29
  /** The ID of the gateway's generation response. For example, `GenerationResponseGenerations.id`. */
26
- generation_id: string;
30
+ generation_id?: string;
27
31
  /** A unique ID for the feedback object. */
28
32
  id: string;
29
33
  /** The source of the feedback. For example, `human` or `app`. */
30
34
  source?: string;
35
+ /** The unique ID of a batch of generations to support to capture a single feedback for multiple generations. */
36
+ turn_id?: string;
31
37
  }
32
38
  /**
33
39
  *
@@ -39,9 +45,12 @@ export interface FeedbackRequest {
39
45
  app_feedback?: {
40
46
  [key: string]: unknown;
41
47
  };
48
+ app_generation?: string;
49
+ app_generation_id?: string;
42
50
  feedback?: string | null;
43
51
  feedback_text?: string;
44
- generation_id: string;
52
+ generation_id?: string;
45
53
  id: string;
46
54
  source?: string;
55
+ turn_id?: string;
47
56
  }
@@ -1,8 +1,18 @@
1
1
  import { GenerationResponseGenerations as GenerationResponseGenerations_GenerationResponseGenerations } from './GenerationResponseGenerations';
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 = "4f085d3ce8f948d5a3d38e9e24ce4f63";
2
+ 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';
3
+ export declare const TTL = 100;
4
+ export declare const VERSION = "ad6b1f255df73e241341ce190bfafe29";
4
5
  export declare function validate(obj: any, path?: string): TypeError | null;
5
6
  export declare const RepresentationType: string;
7
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
8
+ id: string;
9
+ }
10
+ export type GenerationResponseNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export type PartialGenerationResponseNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
12
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
13
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): GenerationResponseNormalizedKeyMetadata;
14
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: GenerationResponse): string;
15
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: GenerationResponse): $64$luvio_engine_NormalizedKeyMetadata;
6
16
  export declare function normalize(input: GenerationResponse, existing: GenerationResponseNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): GenerationResponseNormalized;
7
17
  export declare const select: () => $64$luvio_engine_FragmentSelection;
8
18
  export declare function equals(existing: GenerationResponseNormalized, incoming: GenerationResponseNormalized): boolean;
@@ -12,7 +22,7 @@ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableSto
12
22
  *
13
23
  *
14
24
  * Keys:
15
- * (none)
25
+ * id (string): id
16
26
  */
17
27
  export interface GenerationResponseNormalized {
18
28
  /** List of generated text items. */
@@ -30,7 +40,7 @@ export interface GenerationResponseNormalized {
30
40
  *
31
41
  *
32
42
  * Keys:
33
- * (none)
43
+ * id (string): id
34
44
  */
35
45
  export interface GenerationResponse {
36
46
  generations: Array<GenerationResponseGenerations_GenerationResponseGenerations>;
@@ -0,0 +1,21 @@
1
+ import type { ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
2
+ export interface ResourceRequestConfig {
3
+ body: {
4
+ id: string;
5
+ generation_id?: string;
6
+ turn_id?: string;
7
+ app_generation_id?: string;
8
+ app_generation?: string;
9
+ feedback?: string | null;
10
+ feedback_text?: string;
11
+ source?: string;
12
+ app_feedback?: {
13
+ [key: string]: unknown;
14
+ };
15
+ };
16
+ headers: {
17
+ xClientFeatureId: string;
18
+ xSfdcAppContext?: string;
19
+ };
20
+ }
21
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
@@ -0,0 +1,26 @@
1
+ import type { ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
2
+ export interface ResourceRequestConfig {
3
+ body: {
4
+ prompt: string;
5
+ num_generations?: number;
6
+ max_tokens?: number;
7
+ enable_pii_masking?: boolean;
8
+ temperature?: number;
9
+ stop_sequences?: Array<string>;
10
+ frequency_penalty?: number;
11
+ presence_penalty?: number;
12
+ model?: string;
13
+ parameters?: {
14
+ [key: string]: unknown;
15
+ };
16
+ tags?: {
17
+ [key: string]: unknown;
18
+ };
19
+ };
20
+ headers: {
21
+ xClientFeatureId: string;
22
+ xSfdcAppContext?: string;
23
+ xLLMProvider?: string;
24
+ };
25
+ }
26
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-sfap-einstein-ai-gateway",
3
- "version": "1.265.0",
3
+ "version": "1.266.0-dev10",
4
4
  "description": "LLM Gateway API's",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "dist/es/es2018/sfap-einstein-ai-gateway.js",
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "scripts": {
34
34
  "build": "yarn build:services",
35
- "build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
35
+ "build:raml": "luvio generate src/raml/luvio.raml src/generated -p './scripts/lds-adapters-sfap-einstein-ai-gateway-plugin.js'",
36
36
  "build:services": "rollup --bundleConfigAsCjs --config rollup.config.js",
37
37
  "clean": "rm -rf dist sfdc src/generated",
38
38
  "release:core": "../../scripts/release/core.js --adapter=lds-adapters-sfap-einstein-ai-gateway",
@@ -40,10 +40,10 @@
40
40
  "test:unit": "jest"
41
41
  },
42
42
  "dependencies": {
43
- "@salesforce/lds-bindings": "^1.265.0"
43
+ "@salesforce/lds-bindings": "^1.266.0-dev10"
44
44
  },
45
45
  "devDependencies": {
46
- "@salesforce/lds-compiler-plugins": "^1.265.0"
46
+ "@salesforce/lds-compiler-plugins": "^1.266.0-dev10"
47
47
  },
48
48
  "nx": {
49
49
  "targets": {
@@ -54,6 +54,16 @@
54
54
  ]
55
55
  },
56
56
  "build:raml": {
57
+ "inputs": [
58
+ {
59
+ "externalDependencies": [
60
+ "@luvio/compiler",
61
+ "@luvio/cli"
62
+ ]
63
+ },
64
+ "{projectRoot}/**/*.raml",
65
+ "{projectRoot}/scripts/**"
66
+ ],
57
67
  "outputs": [
58
68
  "{projectRoot}/src/generated"
59
69
  ]
package/sfdc/index.js CHANGED
@@ -12,13 +12,11 @@
12
12
  * *******************************************************************************************
13
13
  */
14
14
  /* proxy-compat-disable */
15
- import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
15
  import { withDefaultLuvio } from 'force/ldsEngine';
17
- import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from 'force/luvioEngine';
16
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from 'force/luvioEngine';
18
17
 
19
18
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
19
  const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
21
- const { stringify: JSONStringify$1 } = JSON;
22
20
  const { isArray: ArrayIsArray$1 } = Array;
23
21
  /**
24
22
  * Validates an adapter config is well-formed.
@@ -52,68 +50,6 @@ function untrustedIsObject(untrusted) {
52
50
  function areRequiredParametersPresent(config, configPropertyNames) {
53
51
  return configPropertyNames.parameters.required.every(req => req in config);
54
52
  }
55
- const snapshotRefreshOptions = {
56
- overrides: {
57
- headers: {
58
- 'Cache-Control': 'no-cache',
59
- },
60
- }
61
- };
62
- /**
63
- * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
64
- * This is needed because insertion order for JSON.stringify(object) affects output:
65
- * JSON.stringify({a: 1, b: 2})
66
- * "{"a":1,"b":2}"
67
- * JSON.stringify({b: 2, a: 1})
68
- * "{"b":2,"a":1}"
69
- * @param data Data to be JSON-stringified.
70
- * @returns JSON.stringified value with consistent ordering of keys.
71
- */
72
- function stableJSONStringify(node) {
73
- // This is for Date values.
74
- if (node && node.toJSON && typeof node.toJSON === 'function') {
75
- // eslint-disable-next-line no-param-reassign
76
- node = node.toJSON();
77
- }
78
- if (node === undefined) {
79
- return;
80
- }
81
- if (typeof node === 'number') {
82
- return isFinite(node) ? '' + node : 'null';
83
- }
84
- if (typeof node !== 'object') {
85
- return JSONStringify$1(node);
86
- }
87
- let i;
88
- let out;
89
- if (ArrayIsArray$1(node)) {
90
- out = '[';
91
- for (i = 0; i < node.length; i++) {
92
- if (i) {
93
- out += ',';
94
- }
95
- out += stableJSONStringify(node[i]) || 'null';
96
- }
97
- return out + ']';
98
- }
99
- if (node === null) {
100
- return 'null';
101
- }
102
- const keys = ObjectKeys$1(node).sort();
103
- out = '';
104
- for (i = 0; i < keys.length; i++) {
105
- const key = keys[i];
106
- const value = stableJSONStringify(node[key]);
107
- if (!value) {
108
- continue;
109
- }
110
- if (out) {
111
- out += ',';
112
- }
113
- out += JSONStringify$1(key) + ':' + value;
114
- }
115
- return '{' + out + '}';
116
- }
117
53
  function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
118
54
  return {
119
55
  name,
@@ -632,7 +568,8 @@ function equals$2(existing, incoming) {
632
568
  return true;
633
569
  }
634
570
 
635
- const VERSION$1 = "4f085d3ce8f948d5a3d38e9e24ce4f63";
571
+ const TTL$1 = 100;
572
+ const VERSION$1 = "ad6b1f255df73e241341ce190bfafe29";
636
573
  function validate$1(obj, path = 'GenerationResponse') {
637
574
  const v_error = (() => {
638
575
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -706,6 +643,15 @@ function validate$1(obj, path = 'GenerationResponse') {
706
643
  return v_error === undefined ? null : v_error;
707
644
  }
708
645
  const RepresentationType$1 = 'GenerationResponse';
646
+ function keyBuilder$1(luvio, config) {
647
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.id;
648
+ }
649
+ function keyBuilderFromType$1(luvio, object) {
650
+ const keyParams = {
651
+ id: object.id
652
+ };
653
+ return keyBuilder$1(luvio, keyParams);
654
+ }
709
655
  function normalize$1(input, existing, path, luvio, store, timestamp) {
710
656
  return input;
711
657
  }
@@ -795,14 +741,14 @@ const ingest$1 = function GenerationResponseIngest(input, path, luvio, store, ti
795
741
  throw validateError;
796
742
  }
797
743
  }
798
- const key = path.fullPath;
799
- const ttlToUse = path.ttl !== undefined ? path.ttl : 100;
744
+ const key = keyBuilderFromType$1(luvio, input);
745
+ const ttlToUse = TTL$1;
800
746
  ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "einstein-ai-gateway", VERSION$1, RepresentationType$1, equals$1);
801
747
  return createLink(key);
802
748
  };
803
749
  function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
804
750
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
805
- const rootKey = fullPathFactory();
751
+ const rootKey = keyBuilderFromType$1(luvio, input);
806
752
  rootKeySet.set(rootKey, {
807
753
  namespace: keyPrefix,
808
754
  representationName: RepresentationType$1,
@@ -813,21 +759,18 @@ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
813
759
  function select$2(luvio, params) {
814
760
  return select$3();
815
761
  }
816
- function keyBuilder$2(luvio, params) {
817
- return keyPrefix + '::GenerationResponse:(' + 'xClientFeatureId:' + params.headers.xClientFeatureId + ',' + 'xLLMProvider:' + params.headers.xLLMProvider + ',' + 'prompt:' + params.body.prompt + '::' + (params.body.num_generations === undefined ? 'num_generations' : 'num_generations:' + params.body.num_generations) + '::' + (params.body.max_tokens === undefined ? 'max_tokens' : 'max_tokens:' + params.body.max_tokens) + '::' + (params.body.enable_pii_masking === undefined ? 'enable_pii_masking' : 'enable_pii_masking:' + params.body.enable_pii_masking) + '::' + (params.body.temperature === undefined ? 'temperature' : 'temperature:' + params.body.temperature) + '::' + (params.body.stop_sequences === undefined ? 'stop_sequences' : 'stop_sequences:' + params.body.stop_sequences) + '::' + (params.body.frequency_penalty === undefined ? 'frequency_penalty' : 'frequency_penalty:' + params.body.frequency_penalty) + '::' + (params.body.presence_penalty === undefined ? 'presence_penalty' : 'presence_penalty:' + params.body.presence_penalty) + '::' + (params.body.model === undefined ? 'model' : 'model:' + params.body.model) + '::' + stableJSONStringify(params.body.parameters) + '::' + stableJSONStringify(params.body.tags) + ')';
818
- }
819
762
  function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
820
- getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
763
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
821
764
  }
822
- function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
765
+ function ingestSuccess$1(luvio, resourceParams, response) {
823
766
  const { body } = response;
824
- const key = keyBuilder$2(luvio, resourceParams);
767
+ const key = keyBuilderFromType$1(luvio, body);
825
768
  luvio.storeIngest(key, ingest$1, body);
826
769
  const snapshot = luvio.storeLookup({
827
770
  recordId: key,
828
771
  node: select$2(),
829
772
  variables: {},
830
- }, snapshotRefresh);
773
+ });
831
774
  if (process.env.NODE_ENV !== 'production') {
832
775
  if (snapshot.state !== 'Fulfilled') {
833
776
  throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
@@ -836,16 +779,18 @@ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
836
779
  deepFreeze(snapshot.data);
837
780
  return snapshot;
838
781
  }
839
- function ingestError(luvio, params, error, snapshotRefresh) {
840
- const key = keyBuilder$2(luvio, params);
841
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
842
- luvio.storeIngestError(key, errorSnapshot);
843
- return errorSnapshot;
844
- }
782
+
845
783
  function createResourceRequest$1(config) {
846
784
  const headers = {};
847
785
  headers['x-client-feature-id'] = config.headers.xClientFeatureId;
848
- headers['x-LLM-Provider'] = config.headers.xLLMProvider;
786
+ const header_xSfdcAppContext = config.headers.xSfdcAppContext || 'EinsteinGPT'; /* Hand rolled default value*/
787
+ if (header_xSfdcAppContext !== undefined) {
788
+ headers['x-sfdc-app-context'] = header_xSfdcAppContext;
789
+ }
790
+ const header_xLLMProvider = config.headers.xLLMProvider;
791
+ if (header_xLLMProvider !== undefined) {
792
+ headers['x-LLM-Provider'] = header_xLLMProvider;
793
+ }
849
794
  return {
850
795
  baseUri: 'api.salesforce.com',
851
796
  basePath: '/ai/gpt/v1/generations',
@@ -872,14 +817,11 @@ const getGenerations_ConfigPropertyMetadata = [
872
817
  generateParamConfigMetadata('parameters', false, 2 /* Body */, 4 /* Unsupported */),
873
818
  generateParamConfigMetadata('tags', false, 2 /* Body */, 4 /* Unsupported */),
874
819
  generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
875
- generateParamConfigMetadata('xLLMProvider', true, 3 /* Header */, 0 /* String */),
820
+ generateParamConfigMetadata('xSfdcAppContext', false, 3 /* Header */, 0 /* String */),
821
+ generateParamConfigMetadata('xLLMProvider', false, 3 /* Header */, 0 /* String */),
876
822
  ];
877
823
  const getGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getGenerations_ConfigPropertyMetadata);
878
824
  const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getGenerations_ConfigPropertyMetadata);
879
- function keyBuilder$1(luvio, config) {
880
- const resourceParams = createResourceParams$1(config);
881
- return keyBuilder$2(luvio, resourceParams);
882
- }
883
825
  function typeCheckConfig$1(untrustedConfig) {
884
826
  const config = {};
885
827
  typeCheckConfig$2(untrustedConfig, config, getGenerations_ConfigPropertyMetadata);
@@ -928,62 +870,33 @@ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
928
870
  }
929
871
  return config;
930
872
  }
931
- function adapterFragment(luvio, config) {
932
- createResourceParams$1(config);
933
- return select$2();
934
- }
935
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
936
- const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
937
- config,
938
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
939
- });
940
- return luvio.storeBroadcast().then(() => snapshot);
941
- }
942
- function onFetchResponseError(luvio, config, resourceParams, response) {
943
- const snapshot = ingestError(luvio, resourceParams, response, {
944
- config,
945
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
946
- });
947
- return luvio.storeBroadcast().then(() => snapshot);
948
- }
949
873
  function buildNetworkSnapshot$1(luvio, config, options) {
950
874
  const resourceParams = createResourceParams$1(config);
951
875
  const request = createResourceRequest$1(resourceParams);
952
876
  return luvio.dispatchResourceRequest(request, options)
953
877
  .then((response) => {
954
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
878
+ return luvio.handleSuccessResponse(() => {
879
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
880
+ return luvio.storeBroadcast().then(() => snapshot);
881
+ }, () => {
955
882
  const cache = new StoreKeyMap();
956
883
  getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
957
884
  return cache;
958
885
  });
959
886
  }, (response) => {
960
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
887
+ deepFreeze(response);
888
+ throw response;
961
889
  });
962
890
  }
963
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
964
- return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, 'get', false);
965
- }
966
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
967
- const { luvio, config } = context;
968
- const selector = {
969
- recordId: keyBuilder$1(luvio, config),
970
- node: adapterFragment(luvio, config),
971
- variables: {},
891
+ const getGenerationsAdapterFactory = (luvio) => {
892
+ return function getGenerations(untrustedConfig) {
893
+ const config = validateAdapterConfig$1(untrustedConfig, getGenerations_ConfigPropertyNames);
894
+ // Invalid or incomplete config
895
+ if (config === null) {
896
+ throw new Error('Invalid config for "getGenerations"');
897
+ }
898
+ return buildNetworkSnapshot$1(luvio, config);
972
899
  };
973
- const cacheSnapshot = storeLookup(selector, {
974
- config,
975
- resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
976
- });
977
- return cacheSnapshot;
978
- }
979
- const getGenerationsAdapterFactory = (luvio) => function einsteinAiGateway__getGenerations(untrustedConfig, requestContext) {
980
- const config = validateAdapterConfig$1(untrustedConfig, getGenerations_ConfigPropertyNames);
981
- // Invalid or incomplete config
982
- if (config === null) {
983
- return null;
984
- }
985
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
986
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
987
900
  };
988
901
 
989
902
  const TTL = 100;
@@ -1080,9 +993,12 @@ function ingestSuccess(luvio, resourceParams, response) {
1080
993
  deepFreeze(snapshot.data);
1081
994
  return snapshot;
1082
995
  }
996
+
1083
997
  function createResourceRequest(config) {
1084
998
  const headers = {};
1085
999
  headers['x-client-feature-id'] = config.headers.xClientFeatureId;
1000
+ headers['x-sfdc-app-context'] =
1001
+ config.headers.xSfdcAppContext || 'EinsteinGPT'; /* Hand rolled default value*/
1086
1002
  return {
1087
1003
  baseUri: 'api.salesforce.com',
1088
1004
  basePath: '/ai/gpt/v1/feedback',
@@ -1098,12 +1014,16 @@ function createResourceRequest(config) {
1098
1014
  const adapterName = 'registerFeedback';
1099
1015
  const registerFeedback_ConfigPropertyMetadata = [
1100
1016
  generateParamConfigMetadata('id', true, 2 /* Body */, 0 /* String */),
1101
- generateParamConfigMetadata('generation_id', true, 2 /* Body */, 0 /* String */),
1017
+ generateParamConfigMetadata('generation_id', false, 2 /* Body */, 0 /* String */),
1018
+ generateParamConfigMetadata('turn_id', false, 2 /* Body */, 0 /* String */),
1019
+ generateParamConfigMetadata('app_generation_id', false, 2 /* Body */, 0 /* String */),
1020
+ generateParamConfigMetadata('app_generation', false, 2 /* Body */, 0 /* String */),
1102
1021
  generateParamConfigMetadata('feedback', false, 2 /* Body */, 4 /* Unsupported */),
1103
1022
  generateParamConfigMetadata('feedback_text', false, 2 /* Body */, 0 /* String */),
1104
1023
  generateParamConfigMetadata('source', false, 2 /* Body */, 0 /* String */),
1105
1024
  generateParamConfigMetadata('app_feedback', false, 2 /* Body */, 4 /* Unsupported */),
1106
1025
  generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
1026
+ generateParamConfigMetadata('xSfdcAppContext', false, 3 /* Header */, 0 /* String */),
1107
1027
  ];
1108
1028
  const registerFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, registerFeedback_ConfigPropertyMetadata);
1109
1029
  const createResourceParams = /*#__PURE__*/ createResourceParams$2(registerFeedback_ConfigPropertyMetadata);
@@ -1178,29 +1098,23 @@ const registerFeedbackAdapterFactory = (luvio) => {
1178
1098
 
1179
1099
  let getGenerations;
1180
1100
  let registerFeedback;
1181
- // Imperative GET Adapters
1182
- let getGenerations_imperative;
1183
- // Adapter Metadata
1184
- const getGenerationsMetadata = { apiFamily: 'einsteinai-gateway', name: 'getGenerations' };
1185
1101
  // Notify Update Available
1186
1102
  function bindExportsTo(luvio) {
1187
1103
  // LDS Adapters
1188
- const getGenerations_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getGenerations', getGenerationsAdapterFactory), getGenerationsMetadata);
1189
1104
  function unwrapSnapshotData(factory) {
1190
1105
  const adapter = factory(luvio);
1191
1106
  return (config) => adapter(config).then((snapshot) => snapshot.data);
1192
1107
  }
1193
1108
  return {
1194
- getGenerations: createWireAdapterConstructor(luvio, getGenerations_ldsAdapter, getGenerationsMetadata),
1109
+ getGenerations: unwrapSnapshotData(getGenerationsAdapterFactory),
1195
1110
  registerFeedback: unwrapSnapshotData(registerFeedbackAdapterFactory),
1196
1111
  // Imperative GET Adapters
1197
- getGenerations_imperative: createImperativeAdapter(luvio, getGenerations_ldsAdapter, getGenerationsMetadata),
1198
1112
  // Notify Update Availables
1199
1113
  };
1200
1114
  }
1201
1115
  withDefaultLuvio((luvio) => {
1202
- ({ getGenerations, registerFeedback, getGenerations_imperative } = bindExportsTo(luvio));
1116
+ ({ getGenerations, registerFeedback } = bindExportsTo(luvio));
1203
1117
  });
1204
1118
 
1205
- export { getGenerations, getGenerations_imperative, registerFeedback };
1206
- // version: 1.265.0-25488bd30
1119
+ export { getGenerations, registerFeedback };
1120
+ // version: 1.266.0-dev10-3275d4bf8
package/src/raml/api.raml CHANGED
@@ -468,9 +468,18 @@ types:
468
468
  id:
469
469
  description: A unique ID for the feedback object.
470
470
  type: string
471
- generation_id:
471
+ generation_id?:
472
472
  description: The ID of the gateway's generation response. For example, `GenerationResponseGenerations.id`.
473
473
  type: string
474
+ turn_id?:
475
+ description: The unique ID of a batch of generations to support to capture a single feedback for multiple generations.
476
+ type: string
477
+ app_generation_id?:
478
+ description: The app-specific generation ID to support cases where client further split a generation into multiple generations.
479
+ type: string
480
+ app_generation?:
481
+ description: The app-specific generation text to support cases where the client further splits a generation into multiple generations.
482
+ type: string
474
483
  feedback?:
475
484
  description: The feedback sentiment. Can be `null`.
476
485
  enum:
@@ -616,9 +625,14 @@ version: v1
616
625
  'x-client-feature-id':
617
626
  type: string
618
627
  description: Client Feature Id.
628
+ 'x-sfdc-app-context':
629
+ type: string
630
+ default: EinsteinGPT
631
+ required: false
632
+ description: SFDC app context.
619
633
  'x-LLM-Provider':
620
634
  description: Provider to use.
621
- required: true
635
+ required: false
622
636
  enum:
623
637
  - OpenAI
624
638
  - Cohere
@@ -689,6 +703,11 @@ version: v1
689
703
  'x-client-feature-id':
690
704
  type: string
691
705
  description: Client Feature Id.
706
+ 'x-sfdc-app-context':
707
+ type: string
708
+ default: EinsteinGPT
709
+ required: false
710
+ description: SFDC app context.
692
711
  body:
693
712
  application/json: FeedbackRequest
694
713
  responses:
@@ -10,6 +10,10 @@ uses:
10
10
  (luvio.ttl): 100
11
11
 
12
12
  types:
13
+ GenerationResponse:
14
+ (luvio.ttl): 100
15
+ (luvio.key):
16
+ id: id
13
17
  FeedbackResponseRepresentation:
14
18
  (luvio.ttl): 100
15
19
  (luvio.key):
@@ -17,7 +21,6 @@ types:
17
21
 
18
22
  /ai/gpt/v1/generations:
19
23
  post:
20
- (luvio.method): get
21
24
  (luvio.adapter):
22
25
  name: getGenerations
23
26