@salesforce/lds-adapters-sfap-einstein-ai-gateway 1.250.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/sfap-einstein-ai-gateway.js +1023 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/getGenerations.d.ts +39 -0
- package/dist/es/es2018/types/src/generated/adapters/registerFeedback.d.ts +21 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +2 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +4 -0
- package/dist/es/es2018/types/src/generated/resources/postAiGptV1Feedback.d.ts +20 -0
- package/dist/es/es2018/types/src/generated/resources/postAiGptV1Generations.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/ChatMessage.d.ts +43 -0
- package/dist/es/es2018/types/src/generated/types/ConversationalMemorySettings.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/Error.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/FeedbackErrorRepresentation.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/FeedbackRequest.d.ts +43 -0
- package/dist/es/es2018/types/src/generated/types/FeedbackResponse202Representation.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/FeedbackResponseRepresentation.d.ts +38 -0
- package/dist/es/es2018/types/src/generated/types/GenerationDetails.d.ts +32 -0
- package/dist/es/es2018/types/src/generated/types/GenerationRequest.d.ts +58 -0
- package/dist/es/es2018/types/src/generated/types/GenerationResponse.d.ts +38 -0
- package/dist/es/es2018/types/src/generated/types/GenerationResponseGenerations.d.ts +37 -0
- package/dist/es/es2018/types/src/generated/types/GenerationSettings.d.ts +46 -0
- package/dist/es/es2018/types/src/generated/types/GenerationsErrorRepresentation.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/HyperLink.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/LLMProviderDetails.d.ts +43 -0
- package/dist/es/es2018/types/src/generated/types/LLMProviderResponse.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/Links.d.ts +32 -0
- package/dist/es/es2018/types/src/generated/types/ModelResponse.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/PluginGenerationRequest.d.ts +25 -0
- package/dist/es/es2018/types/src/generated/types/PluginGenerationResponse.d.ts +25 -0
- package/dist/es/es2018/types/src/generated/types/SafetyCategoryScores.d.ts +39 -0
- package/dist/es/es2018/types/src/generated/types/SafetyScoreRepresentation.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +1062 -0
- package/src/raml/api.raml +717 -0
- package/src/raml/luvio.raml +27 -0
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
|
|
8
|
+
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys, create: ObjectCreate } = Object;
|
|
11
|
+
const { stringify: JSONStringify } = JSON;
|
|
12
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
13
|
+
/**
|
|
14
|
+
* Validates an adapter config is well-formed.
|
|
15
|
+
* @param config The config to validate.
|
|
16
|
+
* @param adapter The adapter validation configuration.
|
|
17
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
18
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
19
|
+
*/
|
|
20
|
+
function validateConfig(config, adapter, oneOf) {
|
|
21
|
+
const { displayName } = adapter;
|
|
22
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
23
|
+
if (config === undefined ||
|
|
24
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
25
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
26
|
+
}
|
|
27
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
28
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
29
|
+
}
|
|
30
|
+
if (unsupported !== undefined &&
|
|
31
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
32
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
33
|
+
}
|
|
34
|
+
const supported = required.concat(optional);
|
|
35
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
36
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function untrustedIsObject(untrusted) {
|
|
40
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
41
|
+
}
|
|
42
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
43
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
44
|
+
}
|
|
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(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(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(key) + ':' + value;
|
|
104
|
+
}
|
|
105
|
+
return '{' + out + '}';
|
|
106
|
+
}
|
|
107
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
108
|
+
return {
|
|
109
|
+
name,
|
|
110
|
+
required,
|
|
111
|
+
resourceType,
|
|
112
|
+
typeCheckShape,
|
|
113
|
+
isArrayShape,
|
|
114
|
+
coerceFn,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
118
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
119
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
120
|
+
return {
|
|
121
|
+
displayName,
|
|
122
|
+
parameters: {
|
|
123
|
+
required,
|
|
124
|
+
optional,
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const keyPrefix = 'einstein-ai-gateway';
|
|
129
|
+
|
|
130
|
+
const { isArray: ArrayIsArray } = Array;
|
|
131
|
+
function equalsArray(a, b, equalsItem) {
|
|
132
|
+
const aLength = a.length;
|
|
133
|
+
const bLength = b.length;
|
|
134
|
+
if (aLength !== bLength) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
for (let i = 0; i < aLength; i++) {
|
|
138
|
+
if (equalsItem(a[i], b[i]) === false) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
function createLink(ref) {
|
|
145
|
+
return {
|
|
146
|
+
__ref: serializeStructuredKey(ref),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const VERSION$4 = "647dd4ada228e1c62a79f1cdb4e44377";
|
|
151
|
+
function validate$4(obj, path = 'SafetyCategoryScores') {
|
|
152
|
+
const v_error = (() => {
|
|
153
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
154
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
155
|
+
}
|
|
156
|
+
if (obj.hate !== undefined) {
|
|
157
|
+
const obj_hate = obj.hate;
|
|
158
|
+
const path_hate = path + '.hate';
|
|
159
|
+
if (typeof obj_hate !== 'number') {
|
|
160
|
+
return new TypeError('Expected "number" but received "' + typeof obj_hate + '" (at "' + path_hate + '")');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (obj.identity !== undefined) {
|
|
164
|
+
const obj_identity = obj.identity;
|
|
165
|
+
const path_identity = path + '.identity';
|
|
166
|
+
if (typeof obj_identity !== 'number') {
|
|
167
|
+
return new TypeError('Expected "number" but received "' + typeof obj_identity + '" (at "' + path_identity + '")');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (obj.physical !== undefined) {
|
|
171
|
+
const obj_physical = obj.physical;
|
|
172
|
+
const path_physical = path + '.physical';
|
|
173
|
+
if (typeof obj_physical !== 'number') {
|
|
174
|
+
return new TypeError('Expected "number" but received "' + typeof obj_physical + '" (at "' + path_physical + '")');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (obj.profanity !== undefined) {
|
|
178
|
+
const obj_profanity = obj.profanity;
|
|
179
|
+
const path_profanity = path + '.profanity';
|
|
180
|
+
if (typeof obj_profanity !== 'number') {
|
|
181
|
+
return new TypeError('Expected "number" but received "' + typeof obj_profanity + '" (at "' + path_profanity + '")');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (obj.sexual !== undefined) {
|
|
185
|
+
const obj_sexual = obj.sexual;
|
|
186
|
+
const path_sexual = path + '.sexual';
|
|
187
|
+
if (typeof obj_sexual !== 'number') {
|
|
188
|
+
return new TypeError('Expected "number" but received "' + typeof obj_sexual + '" (at "' + path_sexual + '")');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (obj.toxicity !== undefined) {
|
|
192
|
+
const obj_toxicity = obj.toxicity;
|
|
193
|
+
const path_toxicity = path + '.toxicity';
|
|
194
|
+
if (typeof obj_toxicity !== 'number') {
|
|
195
|
+
return new TypeError('Expected "number" but received "' + typeof obj_toxicity + '" (at "' + path_toxicity + '")');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (obj.violence !== undefined) {
|
|
199
|
+
const obj_violence = obj.violence;
|
|
200
|
+
const path_violence = path + '.violence';
|
|
201
|
+
if (typeof obj_violence !== 'number') {
|
|
202
|
+
return new TypeError('Expected "number" but received "' + typeof obj_violence + '" (at "' + path_violence + '")');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
})();
|
|
206
|
+
return v_error === undefined ? null : v_error;
|
|
207
|
+
}
|
|
208
|
+
const select$6 = function SafetyCategoryScoresSelect() {
|
|
209
|
+
return {
|
|
210
|
+
kind: 'Fragment',
|
|
211
|
+
version: VERSION$4,
|
|
212
|
+
private: [],
|
|
213
|
+
selections: [
|
|
214
|
+
{
|
|
215
|
+
name: 'hate',
|
|
216
|
+
kind: 'Scalar',
|
|
217
|
+
required: false
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: 'identity',
|
|
221
|
+
kind: 'Scalar',
|
|
222
|
+
required: false
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'physical',
|
|
226
|
+
kind: 'Scalar',
|
|
227
|
+
required: false
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'profanity',
|
|
231
|
+
kind: 'Scalar',
|
|
232
|
+
required: false
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: 'sexual',
|
|
236
|
+
kind: 'Scalar',
|
|
237
|
+
required: false
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'toxicity',
|
|
241
|
+
kind: 'Scalar',
|
|
242
|
+
required: false
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'violence',
|
|
246
|
+
kind: 'Scalar',
|
|
247
|
+
required: false
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
function equals$4(existing, incoming) {
|
|
253
|
+
const existing_hate = existing.hate;
|
|
254
|
+
const incoming_hate = incoming.hate;
|
|
255
|
+
// if at least one of these optionals is defined
|
|
256
|
+
if (existing_hate !== undefined || incoming_hate !== undefined) {
|
|
257
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
258
|
+
// not equal
|
|
259
|
+
if (existing_hate === undefined || incoming_hate === undefined) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (!(existing_hate === incoming_hate)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const existing_identity = existing.identity;
|
|
267
|
+
const incoming_identity = incoming.identity;
|
|
268
|
+
// if at least one of these optionals is defined
|
|
269
|
+
if (existing_identity !== undefined || incoming_identity !== undefined) {
|
|
270
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
271
|
+
// not equal
|
|
272
|
+
if (existing_identity === undefined || incoming_identity === undefined) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
if (!(existing_identity === incoming_identity)) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const existing_physical = existing.physical;
|
|
280
|
+
const incoming_physical = incoming.physical;
|
|
281
|
+
// if at least one of these optionals is defined
|
|
282
|
+
if (existing_physical !== undefined || incoming_physical !== undefined) {
|
|
283
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
284
|
+
// not equal
|
|
285
|
+
if (existing_physical === undefined || incoming_physical === undefined) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
if (!(existing_physical === incoming_physical)) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const existing_profanity = existing.profanity;
|
|
293
|
+
const incoming_profanity = incoming.profanity;
|
|
294
|
+
// if at least one of these optionals is defined
|
|
295
|
+
if (existing_profanity !== undefined || incoming_profanity !== undefined) {
|
|
296
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
297
|
+
// not equal
|
|
298
|
+
if (existing_profanity === undefined || incoming_profanity === undefined) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
if (!(existing_profanity === incoming_profanity)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const existing_sexual = existing.sexual;
|
|
306
|
+
const incoming_sexual = incoming.sexual;
|
|
307
|
+
// if at least one of these optionals is defined
|
|
308
|
+
if (existing_sexual !== undefined || incoming_sexual !== undefined) {
|
|
309
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
310
|
+
// not equal
|
|
311
|
+
if (existing_sexual === undefined || incoming_sexual === undefined) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
if (!(existing_sexual === incoming_sexual)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const existing_toxicity = existing.toxicity;
|
|
319
|
+
const incoming_toxicity = incoming.toxicity;
|
|
320
|
+
// if at least one of these optionals is defined
|
|
321
|
+
if (existing_toxicity !== undefined || incoming_toxicity !== undefined) {
|
|
322
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
323
|
+
// not equal
|
|
324
|
+
if (existing_toxicity === undefined || incoming_toxicity === undefined) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
if (!(existing_toxicity === incoming_toxicity)) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const existing_violence = existing.violence;
|
|
332
|
+
const incoming_violence = incoming.violence;
|
|
333
|
+
// if at least one of these optionals is defined
|
|
334
|
+
if (existing_violence !== undefined || incoming_violence !== undefined) {
|
|
335
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
336
|
+
// not equal
|
|
337
|
+
if (existing_violence === undefined || incoming_violence === undefined) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
if (!(existing_violence === incoming_violence)) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const VERSION$3 = "16253d7587aa43b19fae0671874a0667";
|
|
348
|
+
function validate$3(obj, path = 'SafetyScoreRepresentation') {
|
|
349
|
+
const v_error = (() => {
|
|
350
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
351
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
352
|
+
}
|
|
353
|
+
if (obj.category_scores !== undefined) {
|
|
354
|
+
const obj_category_scores = obj.category_scores;
|
|
355
|
+
const path_category_scores = path + '.category_scores';
|
|
356
|
+
const referencepath_category_scoresValidationError = validate$4(obj_category_scores, path_category_scores);
|
|
357
|
+
if (referencepath_category_scoresValidationError !== null) {
|
|
358
|
+
let message = 'Object doesn\'t match SafetyCategoryScores (at "' + path_category_scores + '")\n';
|
|
359
|
+
message += referencepath_category_scoresValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
360
|
+
return new TypeError(message);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (obj.safety_score !== undefined) {
|
|
364
|
+
const obj_safety_score = obj.safety_score;
|
|
365
|
+
const path_safety_score = path + '.safety_score';
|
|
366
|
+
if (typeof obj_safety_score !== 'number') {
|
|
367
|
+
return new TypeError('Expected "number" but received "' + typeof obj_safety_score + '" (at "' + path_safety_score + '")');
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
})();
|
|
371
|
+
return v_error === undefined ? null : v_error;
|
|
372
|
+
}
|
|
373
|
+
const select$5 = function SafetyScoreRepresentationSelect() {
|
|
374
|
+
const { selections: SafetyCategoryScores__selections, opaque: SafetyCategoryScores__opaque, } = select$6();
|
|
375
|
+
return {
|
|
376
|
+
kind: 'Fragment',
|
|
377
|
+
version: VERSION$3,
|
|
378
|
+
private: [],
|
|
379
|
+
selections: [
|
|
380
|
+
{
|
|
381
|
+
name: 'category_scores',
|
|
382
|
+
kind: 'Object',
|
|
383
|
+
selections: SafetyCategoryScores__selections,
|
|
384
|
+
required: false
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: 'safety_score',
|
|
388
|
+
kind: 'Scalar',
|
|
389
|
+
required: false
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
function equals$3(existing, incoming) {
|
|
395
|
+
const existing_safety_score = existing.safety_score;
|
|
396
|
+
const incoming_safety_score = incoming.safety_score;
|
|
397
|
+
// if at least one of these optionals is defined
|
|
398
|
+
if (existing_safety_score !== undefined || incoming_safety_score !== undefined) {
|
|
399
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
400
|
+
// not equal
|
|
401
|
+
if (existing_safety_score === undefined || incoming_safety_score === undefined) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (!(existing_safety_score === incoming_safety_score)) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
const existing_category_scores = existing.category_scores;
|
|
409
|
+
const incoming_category_scores = incoming.category_scores;
|
|
410
|
+
// if at least one of these optionals is defined
|
|
411
|
+
if (existing_category_scores !== undefined || incoming_category_scores !== undefined) {
|
|
412
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
413
|
+
// not equal
|
|
414
|
+
if (existing_category_scores === undefined || incoming_category_scores === undefined) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
if (!(equals$4(existing_category_scores, incoming_category_scores))) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const VERSION$2 = "d8d7906c67f7e6b5d9e80f599c4cb47f";
|
|
425
|
+
function validate$2(obj, path = 'GenerationResponseGenerations') {
|
|
426
|
+
const v_error = (() => {
|
|
427
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
428
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
429
|
+
}
|
|
430
|
+
if (obj.generation_safety_score !== undefined) {
|
|
431
|
+
const obj_generation_safety_score = obj.generation_safety_score;
|
|
432
|
+
const path_generation_safety_score = path + '.generation_safety_score';
|
|
433
|
+
const referencepath_generation_safety_scoreValidationError = validate$3(obj_generation_safety_score, path_generation_safety_score);
|
|
434
|
+
if (referencepath_generation_safety_scoreValidationError !== null) {
|
|
435
|
+
let message = 'Object doesn\'t match SafetyScoreRepresentation (at "' + path_generation_safety_score + '")\n';
|
|
436
|
+
message += referencepath_generation_safety_scoreValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
437
|
+
return new TypeError(message);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (obj.id !== undefined) {
|
|
441
|
+
const obj_id = obj.id;
|
|
442
|
+
const path_id = path + '.id';
|
|
443
|
+
if (typeof obj_id !== 'string') {
|
|
444
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (obj.parameters !== undefined) {
|
|
448
|
+
const obj_parameters = obj.parameters;
|
|
449
|
+
const path_parameters = path + '.parameters';
|
|
450
|
+
if (typeof obj_parameters !== 'object' || ArrayIsArray(obj_parameters) || obj_parameters === null) {
|
|
451
|
+
return new TypeError('Expected "object" but received "' + typeof obj_parameters + '" (at "' + path_parameters + '")');
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const obj_text = obj.text;
|
|
455
|
+
const path_text = path + '.text';
|
|
456
|
+
if (typeof obj_text !== 'string') {
|
|
457
|
+
return new TypeError('Expected "string" but received "' + typeof obj_text + '" (at "' + path_text + '")');
|
|
458
|
+
}
|
|
459
|
+
})();
|
|
460
|
+
return v_error === undefined ? null : v_error;
|
|
461
|
+
}
|
|
462
|
+
const select$4 = function GenerationResponseGenerationsSelect() {
|
|
463
|
+
const { selections: SafetyScoreRepresentation__selections, opaque: SafetyScoreRepresentation__opaque, } = select$5();
|
|
464
|
+
return {
|
|
465
|
+
kind: 'Fragment',
|
|
466
|
+
version: VERSION$2,
|
|
467
|
+
private: [],
|
|
468
|
+
selections: [
|
|
469
|
+
{
|
|
470
|
+
name: 'generation_safety_score',
|
|
471
|
+
kind: 'Object',
|
|
472
|
+
selections: SafetyScoreRepresentation__selections,
|
|
473
|
+
required: false
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: 'id',
|
|
477
|
+
kind: 'Scalar',
|
|
478
|
+
required: false
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: 'text',
|
|
482
|
+
kind: 'Scalar'
|
|
483
|
+
}
|
|
484
|
+
]
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
function equals$2(existing, incoming) {
|
|
488
|
+
const existing_id = existing.id;
|
|
489
|
+
const incoming_id = incoming.id;
|
|
490
|
+
// if at least one of these optionals is defined
|
|
491
|
+
if (existing_id !== undefined || incoming_id !== undefined) {
|
|
492
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
493
|
+
// not equal
|
|
494
|
+
if (existing_id === undefined || incoming_id === undefined) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
if (!(existing_id === incoming_id)) {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
const existing_text = existing.text;
|
|
502
|
+
const incoming_text = incoming.text;
|
|
503
|
+
if (!(existing_text === incoming_text)) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
const existing_generation_safety_score = existing.generation_safety_score;
|
|
507
|
+
const incoming_generation_safety_score = incoming.generation_safety_score;
|
|
508
|
+
// if at least one of these optionals is defined
|
|
509
|
+
if (existing_generation_safety_score !== undefined || incoming_generation_safety_score !== undefined) {
|
|
510
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
511
|
+
// not equal
|
|
512
|
+
if (existing_generation_safety_score === undefined || incoming_generation_safety_score === undefined) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
if (!(equals$3(existing_generation_safety_score, incoming_generation_safety_score))) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const existing_parameters = existing.parameters;
|
|
520
|
+
const incoming_parameters = incoming.parameters;
|
|
521
|
+
// if at least one of these optionals is defined
|
|
522
|
+
if (existing_parameters !== undefined || incoming_parameters !== undefined) {
|
|
523
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
524
|
+
// not equal
|
|
525
|
+
if (existing_parameters === undefined || incoming_parameters === undefined) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const VERSION$1 = "31470ce89388a2c22a9c6a5a8a898945";
|
|
533
|
+
function validate$1(obj, path = 'GenerationResponse') {
|
|
534
|
+
const v_error = (() => {
|
|
535
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
536
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
537
|
+
}
|
|
538
|
+
const obj_generations = obj.generations;
|
|
539
|
+
const path_generations = path + '.generations';
|
|
540
|
+
if (!ArrayIsArray(obj_generations)) {
|
|
541
|
+
return new TypeError('Expected "array" but received "' + typeof obj_generations + '" (at "' + path_generations + '")');
|
|
542
|
+
}
|
|
543
|
+
for (let i = 0; i < obj_generations.length; i++) {
|
|
544
|
+
const obj_generations_item = obj_generations[i];
|
|
545
|
+
const path_generations_item = path_generations + '[' + i + ']';
|
|
546
|
+
const referencepath_generations_itemValidationError = validate$2(obj_generations_item, path_generations_item);
|
|
547
|
+
if (referencepath_generations_itemValidationError !== null) {
|
|
548
|
+
let message = 'Object doesn\'t match GenerationResponseGenerations (at "' + path_generations_item + '")\n';
|
|
549
|
+
message += referencepath_generations_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
550
|
+
return new TypeError(message);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const obj_id = obj.id;
|
|
554
|
+
const path_id = path + '.id';
|
|
555
|
+
if (typeof obj_id !== 'string') {
|
|
556
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
557
|
+
}
|
|
558
|
+
if (obj.parameters !== undefined) {
|
|
559
|
+
const obj_parameters = obj.parameters;
|
|
560
|
+
const path_parameters = path + '.parameters';
|
|
561
|
+
if (typeof obj_parameters !== 'object' || ArrayIsArray(obj_parameters) || obj_parameters === null) {
|
|
562
|
+
return new TypeError('Expected "object" but received "' + typeof obj_parameters + '" (at "' + path_parameters + '")');
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (obj.prompt !== undefined) {
|
|
566
|
+
const obj_prompt = obj.prompt;
|
|
567
|
+
const path_prompt = path + '.prompt';
|
|
568
|
+
let obj_prompt_union0 = null;
|
|
569
|
+
const obj_prompt_union0_error = (() => {
|
|
570
|
+
if (typeof obj_prompt !== 'string') {
|
|
571
|
+
return new TypeError('Expected "string" but received "' + typeof obj_prompt + '" (at "' + path_prompt + '")');
|
|
572
|
+
}
|
|
573
|
+
})();
|
|
574
|
+
if (obj_prompt_union0_error != null) {
|
|
575
|
+
obj_prompt_union0 = obj_prompt_union0_error.message;
|
|
576
|
+
}
|
|
577
|
+
let obj_prompt_union1 = null;
|
|
578
|
+
const obj_prompt_union1_error = (() => {
|
|
579
|
+
if (obj_prompt !== null) {
|
|
580
|
+
return new TypeError('Expected "null" but received "' + typeof obj_prompt + '" (at "' + path_prompt + '")');
|
|
581
|
+
}
|
|
582
|
+
})();
|
|
583
|
+
if (obj_prompt_union1_error != null) {
|
|
584
|
+
obj_prompt_union1 = obj_prompt_union1_error.message;
|
|
585
|
+
}
|
|
586
|
+
if (obj_prompt_union0 && obj_prompt_union1) {
|
|
587
|
+
let message = 'Object doesn\'t match union (at "' + path_prompt + '")';
|
|
588
|
+
message += '\n' + obj_prompt_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
589
|
+
message += '\n' + obj_prompt_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
590
|
+
return new TypeError(message);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
})();
|
|
594
|
+
return v_error === undefined ? null : v_error;
|
|
595
|
+
}
|
|
596
|
+
const RepresentationType$1 = 'GenerationResponse';
|
|
597
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
598
|
+
return input;
|
|
599
|
+
}
|
|
600
|
+
const select$3 = function GenerationResponseSelect() {
|
|
601
|
+
const { selections: GenerationResponseGenerations__selections, opaque: GenerationResponseGenerations__opaque, } = select$4();
|
|
602
|
+
return {
|
|
603
|
+
kind: 'Fragment',
|
|
604
|
+
version: VERSION$1,
|
|
605
|
+
private: [],
|
|
606
|
+
selections: [
|
|
607
|
+
{
|
|
608
|
+
name: 'generations',
|
|
609
|
+
kind: 'Object',
|
|
610
|
+
plural: true,
|
|
611
|
+
selections: GenerationResponseGenerations__selections
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: 'id',
|
|
615
|
+
kind: 'Scalar'
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
name: 'prompt',
|
|
619
|
+
kind: 'Scalar',
|
|
620
|
+
required: false
|
|
621
|
+
}
|
|
622
|
+
]
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
function equals$1(existing, incoming) {
|
|
626
|
+
const existing_id = existing.id;
|
|
627
|
+
const incoming_id = incoming.id;
|
|
628
|
+
if (!(existing_id === incoming_id)) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
const existing_generations = existing.generations;
|
|
632
|
+
const incoming_generations = incoming.generations;
|
|
633
|
+
const equals_generations_items = equalsArray(existing_generations, incoming_generations, (existing_generations_item, incoming_generations_item) => {
|
|
634
|
+
if (!(equals$2(existing_generations_item, incoming_generations_item))) {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
if (equals_generations_items === false) {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
const existing_parameters = existing.parameters;
|
|
642
|
+
const incoming_parameters = incoming.parameters;
|
|
643
|
+
// if at least one of these optionals is defined
|
|
644
|
+
if (existing_parameters !== undefined || incoming_parameters !== undefined) {
|
|
645
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
646
|
+
// not equal
|
|
647
|
+
if (existing_parameters === undefined || incoming_parameters === undefined) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
const existing_prompt = existing.prompt;
|
|
652
|
+
const incoming_prompt = incoming.prompt;
|
|
653
|
+
// if at least one of these optionals is defined
|
|
654
|
+
if (existing_prompt !== undefined || incoming_prompt !== undefined) {
|
|
655
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
656
|
+
// not equal
|
|
657
|
+
if (existing_prompt === undefined || incoming_prompt === undefined) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
if (!(existing_prompt === incoming_prompt)) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
const ingest$1 = function GenerationResponseIngest(input, path, luvio, store, timestamp) {
|
|
667
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
668
|
+
const validateError = validate$1(input);
|
|
669
|
+
if (validateError !== null) {
|
|
670
|
+
throw validateError;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const key = path.fullPath;
|
|
674
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 100;
|
|
675
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "einstein-ai-gateway", VERSION$1, RepresentationType$1, equals$1);
|
|
676
|
+
return createLink(key);
|
|
677
|
+
};
|
|
678
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
679
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
680
|
+
const rootKey = fullPathFactory();
|
|
681
|
+
rootKeySet.set(rootKey, {
|
|
682
|
+
namespace: keyPrefix,
|
|
683
|
+
representationName: RepresentationType$1,
|
|
684
|
+
mergeable: false
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function select$2(luvio, params) {
|
|
689
|
+
return select$3();
|
|
690
|
+
}
|
|
691
|
+
function keyBuilder$2(luvio, params) {
|
|
692
|
+
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) + ')';
|
|
693
|
+
}
|
|
694
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
695
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
|
|
696
|
+
}
|
|
697
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
698
|
+
const { body } = response;
|
|
699
|
+
const key = keyBuilder$2(luvio, resourceParams);
|
|
700
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
701
|
+
const snapshot = luvio.storeLookup({
|
|
702
|
+
recordId: key,
|
|
703
|
+
node: select$2(),
|
|
704
|
+
variables: {},
|
|
705
|
+
}, snapshotRefresh);
|
|
706
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
707
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
708
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
deepFreeze(snapshot.data);
|
|
712
|
+
return snapshot;
|
|
713
|
+
}
|
|
714
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
715
|
+
const key = keyBuilder$2(luvio, params);
|
|
716
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
717
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
718
|
+
return errorSnapshot;
|
|
719
|
+
}
|
|
720
|
+
function createResourceRequest$1(config) {
|
|
721
|
+
const headers = {};
|
|
722
|
+
headers['x-client-feature-id'] = config.headers.xClientFeatureId;
|
|
723
|
+
headers['x-LLM-Provider'] = config.headers.xLLMProvider;
|
|
724
|
+
return {
|
|
725
|
+
baseUri: 'api.salesforce.com',
|
|
726
|
+
basePath: '/ai/gpt/v1/generations',
|
|
727
|
+
method: 'post',
|
|
728
|
+
body: config.body,
|
|
729
|
+
urlParams: {},
|
|
730
|
+
queryParams: {},
|
|
731
|
+
headers,
|
|
732
|
+
priority: 'normal',
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
const adapterName$1 = 'getGenerations';
|
|
737
|
+
const getGenerations_ConfigPropertyMetadata = [
|
|
738
|
+
generateParamConfigMetadata('prompt', true, 2 /* Body */, 0 /* String */),
|
|
739
|
+
generateParamConfigMetadata('num_generations', false, 2 /* Body */, 3 /* Integer */),
|
|
740
|
+
generateParamConfigMetadata('max_tokens', false, 2 /* Body */, 3 /* Integer */),
|
|
741
|
+
generateParamConfigMetadata('enable_pii_masking', false, 2 /* Body */, 1 /* Boolean */),
|
|
742
|
+
generateParamConfigMetadata('temperature', false, 2 /* Body */, 2 /* Number */),
|
|
743
|
+
generateParamConfigMetadata('stop_sequences', false, 2 /* Body */, 0 /* String */, true),
|
|
744
|
+
generateParamConfigMetadata('frequency_penalty', false, 2 /* Body */, 2 /* Number */),
|
|
745
|
+
generateParamConfigMetadata('presence_penalty', false, 2 /* Body */, 2 /* Number */),
|
|
746
|
+
generateParamConfigMetadata('model', false, 2 /* Body */, 0 /* String */),
|
|
747
|
+
generateParamConfigMetadata('parameters', false, 2 /* Body */, 4 /* Unsupported */),
|
|
748
|
+
generateParamConfigMetadata('tags', false, 2 /* Body */, 4 /* Unsupported */),
|
|
749
|
+
generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
|
|
750
|
+
generateParamConfigMetadata('xLLMProvider', true, 3 /* Header */, 0 /* String */),
|
|
751
|
+
];
|
|
752
|
+
const getGenerations_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getGenerations_ConfigPropertyMetadata);
|
|
753
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getGenerations_ConfigPropertyMetadata);
|
|
754
|
+
function keyBuilder$1(luvio, config) {
|
|
755
|
+
const resourceParams = createResourceParams$1(config);
|
|
756
|
+
return keyBuilder$2(luvio, resourceParams);
|
|
757
|
+
}
|
|
758
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
759
|
+
const config = {};
|
|
760
|
+
typeCheckConfig$2(untrustedConfig, config, getGenerations_ConfigPropertyMetadata);
|
|
761
|
+
const untrustedConfig_parameters = untrustedConfig.parameters;
|
|
762
|
+
if (untrustedIsObject(untrustedConfig_parameters)) {
|
|
763
|
+
const untrustedConfig_parameters_object = {};
|
|
764
|
+
if (untrustedConfig_parameters_object !== undefined && Object.keys(untrustedConfig_parameters_object).length >= 0) {
|
|
765
|
+
config.parameters = untrustedConfig_parameters_object;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
const untrustedConfig_tags = untrustedConfig.tags;
|
|
769
|
+
if (untrustedIsObject(untrustedConfig_tags)) {
|
|
770
|
+
const untrustedConfig_tags_object = {};
|
|
771
|
+
if (untrustedConfig_tags_object !== undefined && Object.keys(untrustedConfig_tags_object).length >= 0) {
|
|
772
|
+
config.tags = untrustedConfig_tags_object;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return config;
|
|
776
|
+
}
|
|
777
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
778
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
782
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
783
|
+
}
|
|
784
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
785
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
return config;
|
|
789
|
+
}
|
|
790
|
+
function adapterFragment(luvio, config) {
|
|
791
|
+
createResourceParams$1(config);
|
|
792
|
+
return select$2();
|
|
793
|
+
}
|
|
794
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
795
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
796
|
+
config,
|
|
797
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
798
|
+
});
|
|
799
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
800
|
+
}
|
|
801
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
802
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
803
|
+
config,
|
|
804
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
805
|
+
});
|
|
806
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
807
|
+
}
|
|
808
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
809
|
+
const resourceParams = createResourceParams$1(config);
|
|
810
|
+
const request = createResourceRequest$1(resourceParams);
|
|
811
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
812
|
+
.then((response) => {
|
|
813
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
814
|
+
const cache = new StoreKeyMap();
|
|
815
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
816
|
+
return cache;
|
|
817
|
+
});
|
|
818
|
+
}, (response) => {
|
|
819
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
823
|
+
return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, 'get', false);
|
|
824
|
+
}
|
|
825
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
826
|
+
const { luvio, config } = context;
|
|
827
|
+
const selector = {
|
|
828
|
+
recordId: keyBuilder$1(luvio, config),
|
|
829
|
+
node: adapterFragment(luvio, config),
|
|
830
|
+
variables: {},
|
|
831
|
+
};
|
|
832
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
833
|
+
config,
|
|
834
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
835
|
+
});
|
|
836
|
+
return cacheSnapshot;
|
|
837
|
+
}
|
|
838
|
+
const getGenerationsAdapterFactory = (luvio) => function einsteinAiGateway__getGenerations(untrustedConfig, requestContext) {
|
|
839
|
+
const config = validateAdapterConfig$1(untrustedConfig, getGenerations_ConfigPropertyNames);
|
|
840
|
+
// Invalid or incomplete config
|
|
841
|
+
if (config === null) {
|
|
842
|
+
return null;
|
|
843
|
+
}
|
|
844
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
845
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
const TTL = 100;
|
|
849
|
+
const VERSION = "f29dcf556357658d72f8330fc3a9d1ac";
|
|
850
|
+
function validate(obj, path = 'FeedbackResponseRepresentation') {
|
|
851
|
+
const v_error = (() => {
|
|
852
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
853
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
854
|
+
}
|
|
855
|
+
const obj_message = obj.message;
|
|
856
|
+
const path_message = path + '.message';
|
|
857
|
+
if (typeof obj_message !== 'string') {
|
|
858
|
+
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
859
|
+
}
|
|
860
|
+
})();
|
|
861
|
+
return v_error === undefined ? null : v_error;
|
|
862
|
+
}
|
|
863
|
+
const RepresentationType = 'FeedbackResponseRepresentation';
|
|
864
|
+
function keyBuilder(luvio, config) {
|
|
865
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
866
|
+
}
|
|
867
|
+
function keyBuilderFromType(luvio, object) {
|
|
868
|
+
const keyParams = {
|
|
869
|
+
message: object.message
|
|
870
|
+
};
|
|
871
|
+
return keyBuilder(luvio, keyParams);
|
|
872
|
+
}
|
|
873
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
874
|
+
return input;
|
|
875
|
+
}
|
|
876
|
+
const select$1 = function FeedbackResponseRepresentationSelect() {
|
|
877
|
+
return {
|
|
878
|
+
kind: 'Fragment',
|
|
879
|
+
version: VERSION,
|
|
880
|
+
private: [],
|
|
881
|
+
selections: [
|
|
882
|
+
{
|
|
883
|
+
name: 'message',
|
|
884
|
+
kind: 'Scalar'
|
|
885
|
+
}
|
|
886
|
+
]
|
|
887
|
+
};
|
|
888
|
+
};
|
|
889
|
+
function equals(existing, incoming) {
|
|
890
|
+
const existing_message = existing.message;
|
|
891
|
+
const incoming_message = incoming.message;
|
|
892
|
+
if (!(existing_message === incoming_message)) {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
const ingest = function FeedbackResponseRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
898
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
899
|
+
const validateError = validate(input);
|
|
900
|
+
if (validateError !== null) {
|
|
901
|
+
throw validateError;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const key = keyBuilderFromType(luvio, input);
|
|
905
|
+
const ttlToUse = TTL;
|
|
906
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "einstein-ai-gateway", VERSION, RepresentationType, equals);
|
|
907
|
+
return createLink(key);
|
|
908
|
+
};
|
|
909
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
910
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
911
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
912
|
+
rootKeySet.set(rootKey, {
|
|
913
|
+
namespace: keyPrefix,
|
|
914
|
+
representationName: RepresentationType,
|
|
915
|
+
mergeable: false
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function select(luvio, params) {
|
|
920
|
+
return select$1();
|
|
921
|
+
}
|
|
922
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
923
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
924
|
+
}
|
|
925
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
926
|
+
const { body } = response;
|
|
927
|
+
const key = keyBuilderFromType(luvio, body);
|
|
928
|
+
luvio.storeIngest(key, ingest, body);
|
|
929
|
+
const snapshot = luvio.storeLookup({
|
|
930
|
+
recordId: key,
|
|
931
|
+
node: select(),
|
|
932
|
+
variables: {},
|
|
933
|
+
});
|
|
934
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
935
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
936
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
deepFreeze(snapshot.data);
|
|
940
|
+
return snapshot;
|
|
941
|
+
}
|
|
942
|
+
function createResourceRequest(config) {
|
|
943
|
+
const headers = {};
|
|
944
|
+
headers['x-client-feature-id'] = config.headers.xClientFeatureId;
|
|
945
|
+
return {
|
|
946
|
+
baseUri: 'api.salesforce.com',
|
|
947
|
+
basePath: '/ai/gpt/v1/feedback',
|
|
948
|
+
method: 'post',
|
|
949
|
+
body: config.body,
|
|
950
|
+
urlParams: {},
|
|
951
|
+
queryParams: {},
|
|
952
|
+
headers,
|
|
953
|
+
priority: 'normal',
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
const adapterName = 'registerFeedback';
|
|
958
|
+
const registerFeedback_ConfigPropertyMetadata = [
|
|
959
|
+
generateParamConfigMetadata('id', true, 2 /* Body */, 0 /* String */),
|
|
960
|
+
generateParamConfigMetadata('generation_id', true, 2 /* Body */, 0 /* String */),
|
|
961
|
+
generateParamConfigMetadata('feedback', false, 2 /* Body */, 0 /* String */),
|
|
962
|
+
generateParamConfigMetadata('feedback_text', false, 2 /* Body */, 0 /* String */),
|
|
963
|
+
generateParamConfigMetadata('source', false, 2 /* Body */, 0 /* String */),
|
|
964
|
+
generateParamConfigMetadata('app_feedback', false, 2 /* Body */, 4 /* Unsupported */),
|
|
965
|
+
generateParamConfigMetadata('xClientFeatureId', true, 3 /* Header */, 0 /* String */),
|
|
966
|
+
];
|
|
967
|
+
const registerFeedback_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, registerFeedback_ConfigPropertyMetadata);
|
|
968
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(registerFeedback_ConfigPropertyMetadata);
|
|
969
|
+
function typeCheckConfig(untrustedConfig) {
|
|
970
|
+
const config = {};
|
|
971
|
+
typeCheckConfig$2(untrustedConfig, config, registerFeedback_ConfigPropertyMetadata);
|
|
972
|
+
const untrustedConfig_app_feedback = untrustedConfig.app_feedback;
|
|
973
|
+
if (untrustedIsObject(untrustedConfig_app_feedback)) {
|
|
974
|
+
const untrustedConfig_app_feedback_object = {};
|
|
975
|
+
if (untrustedConfig_app_feedback_object !== undefined && Object.keys(untrustedConfig_app_feedback_object).length >= 0) {
|
|
976
|
+
config.app_feedback = untrustedConfig_app_feedback_object;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return config;
|
|
980
|
+
}
|
|
981
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
982
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
983
|
+
return null;
|
|
984
|
+
}
|
|
985
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
986
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
987
|
+
}
|
|
988
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
989
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
990
|
+
return null;
|
|
991
|
+
}
|
|
992
|
+
return config;
|
|
993
|
+
}
|
|
994
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
995
|
+
const resourceParams = createResourceParams(config);
|
|
996
|
+
const request = createResourceRequest(resourceParams);
|
|
997
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
998
|
+
.then((response) => {
|
|
999
|
+
return luvio.handleSuccessResponse(() => {
|
|
1000
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
1001
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
1002
|
+
}, () => {
|
|
1003
|
+
const cache = new StoreKeyMap();
|
|
1004
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
1005
|
+
return cache;
|
|
1006
|
+
});
|
|
1007
|
+
}, (response) => {
|
|
1008
|
+
deepFreeze(response);
|
|
1009
|
+
throw response;
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
const registerFeedbackAdapterFactory = (luvio) => {
|
|
1013
|
+
return function registerFeedback(untrustedConfig) {
|
|
1014
|
+
const config = validateAdapterConfig(untrustedConfig, registerFeedback_ConfigPropertyNames);
|
|
1015
|
+
// Invalid or incomplete config
|
|
1016
|
+
if (config === null) {
|
|
1017
|
+
throw new Error('Invalid config for "registerFeedback"');
|
|
1018
|
+
}
|
|
1019
|
+
return buildNetworkSnapshot(luvio, config);
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
export { getGenerationsAdapterFactory, registerFeedbackAdapterFactory };
|