@getlupa/client 1.6.1 → 1.6.3
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/dist/lupaSearch.iife.js +15 -38
- package/dist/lupaSearch.js +15 -38
- package/dist/lupaSearch.mjs +15 -38
- package/dist/lupaSearch.umd.js +15 -38
- package/package.json +2 -2
package/dist/lupaSearch.iife.js
CHANGED
|
@@ -6389,12 +6389,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
6389
6389
|
});
|
|
6390
6390
|
return output;
|
|
6391
6391
|
};
|
|
6392
|
-
const
|
|
6392
|
+
const inputsAreEqual = (input, possibleValues) => {
|
|
6393
6393
|
if (!input) {
|
|
6394
6394
|
return false;
|
|
6395
6395
|
}
|
|
6396
6396
|
const normalizedInput = getNormalizedString(input);
|
|
6397
|
-
return possibleValues.some((v) => getNormalizedString(v)
|
|
6397
|
+
return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
|
|
6398
6398
|
};
|
|
6399
6399
|
const initAnalyticsTracking = (analyticsOptions) => {
|
|
6400
6400
|
try {
|
|
@@ -7401,7 +7401,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7401
7401
|
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
7402
7402
|
return false;
|
|
7403
7403
|
}
|
|
7404
|
-
const redirectTo = redirections.value.rules.find((r) =>
|
|
7404
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
|
|
7405
7405
|
if (!redirectTo) {
|
|
7406
7406
|
return false;
|
|
7407
7407
|
}
|
|
@@ -20974,7 +20974,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20974
20974
|
return { success: false, errors: [e] };
|
|
20975
20975
|
}
|
|
20976
20976
|
});
|
|
20977
|
-
const suggestPhraseAlternatives = (
|
|
20977
|
+
const suggestPhraseAlternatives = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
20978
20978
|
var _a, _b, _c;
|
|
20979
20979
|
const { environment, customBaseUrl } = options;
|
|
20980
20980
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
@@ -20982,7 +20982,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20982
20982
|
const res = yield fetch(
|
|
20983
20983
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
20984
20984
|
__spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
20985
|
-
body: JSON.stringify(
|
|
20985
|
+
body: JSON.stringify(request),
|
|
20986
20986
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
20987
20987
|
})
|
|
20988
20988
|
);
|
|
@@ -20998,38 +20998,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20998
20998
|
return { success: false, errors: [e] };
|
|
20999
20999
|
}
|
|
21000
21000
|
});
|
|
21001
|
-
const
|
|
21002
|
-
var _a, _b, _c;
|
|
21003
|
-
const { environment, customBaseUrl } = options;
|
|
21004
|
-
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21005
|
-
try {
|
|
21006
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21007
|
-
body: JSON.stringify({ phrases }),
|
|
21008
|
-
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21009
|
-
}));
|
|
21010
|
-
if (res.status < 400) {
|
|
21011
|
-
const data = yield res.json();
|
|
21012
|
-
return __spreadProps2(__spreadValues2({}, data), { success: true });
|
|
21013
|
-
}
|
|
21014
|
-
const errors = yield res.json();
|
|
21015
|
-
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
21016
|
-
return { success: false, errors };
|
|
21017
|
-
} catch (e) {
|
|
21018
|
-
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
|
|
21019
|
-
return { success: false, errors: [e] };
|
|
21020
|
-
}
|
|
21021
|
-
});
|
|
21022
|
-
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
21023
|
-
initialQuery,
|
|
21024
|
-
productStrings,
|
|
21025
|
-
messageHistory
|
|
21026
|
-
}, chatSettings) {
|
|
21001
|
+
const suggestBestProductMatches = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
21027
21002
|
var _a, _b, _c;
|
|
21028
21003
|
const { environment, customBaseUrl } = options;
|
|
21029
21004
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21030
21005
|
try {
|
|
21031
21006
|
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21032
|
-
body: JSON.stringify(
|
|
21007
|
+
body: JSON.stringify(request),
|
|
21033
21008
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21034
21009
|
}));
|
|
21035
21010
|
if (res.status < 400) {
|
|
@@ -21065,11 +21040,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21065
21040
|
}
|
|
21066
21041
|
return history;
|
|
21067
21042
|
};
|
|
21068
|
-
const getTextResponseChunkStream = (options,
|
|
21043
|
+
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
21069
21044
|
var _a;
|
|
21070
21045
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21071
21046
|
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21072
|
-
body: JSON.stringify(
|
|
21047
|
+
body: JSON.stringify(request),
|
|
21073
21048
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21074
21049
|
})).then((response) => {
|
|
21075
21050
|
const reader = response.body.getReader();
|
|
@@ -21089,7 +21064,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21089
21064
|
const ChatService = {
|
|
21090
21065
|
suggestSearchChatPhrases,
|
|
21091
21066
|
suggestPhraseAlternatives,
|
|
21092
|
-
suggestSimplifiedPhrases,
|
|
21093
21067
|
suggestBestProductMatches,
|
|
21094
21068
|
prepareChatHistory,
|
|
21095
21069
|
getTextResponseChunkStream
|
|
@@ -21211,7 +21185,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21211
21185
|
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
21212
21186
|
props.options.sdkOptions,
|
|
21213
21187
|
{
|
|
21214
|
-
phrases: [props.phrase]
|
|
21188
|
+
phrases: [props.phrase],
|
|
21189
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21215
21190
|
},
|
|
21216
21191
|
props.options.chatSettings
|
|
21217
21192
|
);
|
|
@@ -21284,7 +21259,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21284
21259
|
{
|
|
21285
21260
|
initialQuery: props.entry.userInput,
|
|
21286
21261
|
productStrings: productResultStrings,
|
|
21287
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21262
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21263
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21288
21264
|
},
|
|
21289
21265
|
props.options.chatSettings
|
|
21290
21266
|
);
|
|
@@ -21358,7 +21334,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21358
21334
|
props.options.sdkOptions,
|
|
21359
21335
|
{
|
|
21360
21336
|
initialQuery: props.content,
|
|
21361
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21337
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21338
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21362
21339
|
},
|
|
21363
21340
|
processChunk,
|
|
21364
21341
|
props.options.chatSettings
|
package/dist/lupaSearch.js
CHANGED
|
@@ -6389,12 +6389,12 @@ const escapeHtml = (value) => {
|
|
|
6389
6389
|
});
|
|
6390
6390
|
return output;
|
|
6391
6391
|
};
|
|
6392
|
-
const
|
|
6392
|
+
const inputsAreEqual = (input, possibleValues) => {
|
|
6393
6393
|
if (!input) {
|
|
6394
6394
|
return false;
|
|
6395
6395
|
}
|
|
6396
6396
|
const normalizedInput = getNormalizedString(input);
|
|
6397
|
-
return possibleValues.some((v) => getNormalizedString(v)
|
|
6397
|
+
return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
|
|
6398
6398
|
};
|
|
6399
6399
|
const initAnalyticsTracking = (analyticsOptions) => {
|
|
6400
6400
|
try {
|
|
@@ -7401,7 +7401,7 @@ const useRedirectionStore = defineStore("redirections", () => {
|
|
|
7401
7401
|
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
7402
7402
|
return false;
|
|
7403
7403
|
}
|
|
7404
|
-
const redirectTo = redirections.value.rules.find((r) =>
|
|
7404
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
|
|
7405
7405
|
if (!redirectTo) {
|
|
7406
7406
|
return false;
|
|
7407
7407
|
}
|
|
@@ -20974,7 +20974,7 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(voi
|
|
|
20974
20974
|
return { success: false, errors: [e] };
|
|
20975
20975
|
}
|
|
20976
20976
|
});
|
|
20977
|
-
const suggestPhraseAlternatives = (
|
|
20977
|
+
const suggestPhraseAlternatives = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
20978
20978
|
var _a, _b, _c;
|
|
20979
20979
|
const { environment, customBaseUrl } = options;
|
|
20980
20980
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
@@ -20982,7 +20982,7 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20982
20982
|
const res = yield fetch(
|
|
20983
20983
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
20984
20984
|
__spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
20985
|
-
body: JSON.stringify(
|
|
20985
|
+
body: JSON.stringify(request),
|
|
20986
20986
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
20987
20987
|
})
|
|
20988
20988
|
);
|
|
@@ -20998,38 +20998,13 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20998
20998
|
return { success: false, errors: [e] };
|
|
20999
20999
|
}
|
|
21000
21000
|
});
|
|
21001
|
-
const
|
|
21002
|
-
var _a, _b, _c;
|
|
21003
|
-
const { environment, customBaseUrl } = options;
|
|
21004
|
-
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21005
|
-
try {
|
|
21006
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21007
|
-
body: JSON.stringify({ phrases }),
|
|
21008
|
-
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21009
|
-
}));
|
|
21010
|
-
if (res.status < 400) {
|
|
21011
|
-
const data = yield res.json();
|
|
21012
|
-
return __spreadProps2(__spreadValues2({}, data), { success: true });
|
|
21013
|
-
}
|
|
21014
|
-
const errors = yield res.json();
|
|
21015
|
-
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
21016
|
-
return { success: false, errors };
|
|
21017
|
-
} catch (e) {
|
|
21018
|
-
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
|
|
21019
|
-
return { success: false, errors: [e] };
|
|
21020
|
-
}
|
|
21021
|
-
});
|
|
21022
|
-
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
21023
|
-
initialQuery,
|
|
21024
|
-
productStrings,
|
|
21025
|
-
messageHistory
|
|
21026
|
-
}, chatSettings) {
|
|
21001
|
+
const suggestBestProductMatches = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
21027
21002
|
var _a, _b, _c;
|
|
21028
21003
|
const { environment, customBaseUrl } = options;
|
|
21029
21004
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21030
21005
|
try {
|
|
21031
21006
|
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21032
|
-
body: JSON.stringify(
|
|
21007
|
+
body: JSON.stringify(request),
|
|
21033
21008
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21034
21009
|
}));
|
|
21035
21010
|
if (res.status < 400) {
|
|
@@ -21065,11 +21040,11 @@ const prepareChatHistory = (chatLog) => {
|
|
|
21065
21040
|
}
|
|
21066
21041
|
return history;
|
|
21067
21042
|
};
|
|
21068
|
-
const getTextResponseChunkStream = (options,
|
|
21043
|
+
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
21069
21044
|
var _a;
|
|
21070
21045
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21071
21046
|
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21072
|
-
body: JSON.stringify(
|
|
21047
|
+
body: JSON.stringify(request),
|
|
21073
21048
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21074
21049
|
})).then((response) => {
|
|
21075
21050
|
const reader = response.body.getReader();
|
|
@@ -21089,7 +21064,6 @@ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, o
|
|
|
21089
21064
|
const ChatService = {
|
|
21090
21065
|
suggestSearchChatPhrases,
|
|
21091
21066
|
suggestPhraseAlternatives,
|
|
21092
|
-
suggestSimplifiedPhrases,
|
|
21093
21067
|
suggestBestProductMatches,
|
|
21094
21068
|
prepareChatHistory,
|
|
21095
21069
|
getTextResponseChunkStream
|
|
@@ -21211,7 +21185,8 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
|
|
|
21211
21185
|
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
21212
21186
|
props.options.sdkOptions,
|
|
21213
21187
|
{
|
|
21214
|
-
phrases: [props.phrase]
|
|
21188
|
+
phrases: [props.phrase],
|
|
21189
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21215
21190
|
},
|
|
21216
21191
|
props.options.chatSettings
|
|
21217
21192
|
);
|
|
@@ -21284,7 +21259,8 @@ const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
|
|
|
21284
21259
|
{
|
|
21285
21260
|
initialQuery: props.entry.userInput,
|
|
21286
21261
|
productStrings: productResultStrings,
|
|
21287
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21262
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21263
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21288
21264
|
},
|
|
21289
21265
|
props.options.chatSettings
|
|
21290
21266
|
);
|
|
@@ -21358,7 +21334,8 @@ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
|
|
|
21358
21334
|
props.options.sdkOptions,
|
|
21359
21335
|
{
|
|
21360
21336
|
initialQuery: props.content,
|
|
21361
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21337
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21338
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21362
21339
|
},
|
|
21363
21340
|
processChunk,
|
|
21364
21341
|
props.options.chatSettings
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -6387,12 +6387,12 @@ const escapeHtml = (value) => {
|
|
|
6387
6387
|
});
|
|
6388
6388
|
return output;
|
|
6389
6389
|
};
|
|
6390
|
-
const
|
|
6390
|
+
const inputsAreEqual = (input, possibleValues) => {
|
|
6391
6391
|
if (!input) {
|
|
6392
6392
|
return false;
|
|
6393
6393
|
}
|
|
6394
6394
|
const normalizedInput = getNormalizedString(input);
|
|
6395
|
-
return possibleValues.some((v) => getNormalizedString(v)
|
|
6395
|
+
return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
|
|
6396
6396
|
};
|
|
6397
6397
|
const initAnalyticsTracking = (analyticsOptions) => {
|
|
6398
6398
|
try {
|
|
@@ -7399,7 +7399,7 @@ const useRedirectionStore = defineStore("redirections", () => {
|
|
|
7399
7399
|
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
7400
7400
|
return false;
|
|
7401
7401
|
}
|
|
7402
|
-
const redirectTo = redirections.value.rules.find((r) =>
|
|
7402
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
|
|
7403
7403
|
if (!redirectTo) {
|
|
7404
7404
|
return false;
|
|
7405
7405
|
}
|
|
@@ -20972,7 +20972,7 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(voi
|
|
|
20972
20972
|
return { success: false, errors: [e] };
|
|
20973
20973
|
}
|
|
20974
20974
|
});
|
|
20975
|
-
const suggestPhraseAlternatives = (
|
|
20975
|
+
const suggestPhraseAlternatives = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
20976
20976
|
var _a, _b, _c;
|
|
20977
20977
|
const { environment, customBaseUrl } = options;
|
|
20978
20978
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
@@ -20980,7 +20980,7 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20980
20980
|
const res = yield fetch(
|
|
20981
20981
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
20982
20982
|
__spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
20983
|
-
body: JSON.stringify(
|
|
20983
|
+
body: JSON.stringify(request),
|
|
20984
20984
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
20985
20985
|
})
|
|
20986
20986
|
);
|
|
@@ -20996,38 +20996,13 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20996
20996
|
return { success: false, errors: [e] };
|
|
20997
20997
|
}
|
|
20998
20998
|
});
|
|
20999
|
-
const
|
|
21000
|
-
var _a, _b, _c;
|
|
21001
|
-
const { environment, customBaseUrl } = options;
|
|
21002
|
-
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21003
|
-
try {
|
|
21004
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21005
|
-
body: JSON.stringify({ phrases }),
|
|
21006
|
-
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21007
|
-
}));
|
|
21008
|
-
if (res.status < 400) {
|
|
21009
|
-
const data = yield res.json();
|
|
21010
|
-
return __spreadProps2(__spreadValues2({}, data), { success: true });
|
|
21011
|
-
}
|
|
21012
|
-
const errors = yield res.json();
|
|
21013
|
-
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
21014
|
-
return { success: false, errors };
|
|
21015
|
-
} catch (e) {
|
|
21016
|
-
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
|
|
21017
|
-
return { success: false, errors: [e] };
|
|
21018
|
-
}
|
|
21019
|
-
});
|
|
21020
|
-
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
21021
|
-
initialQuery,
|
|
21022
|
-
productStrings,
|
|
21023
|
-
messageHistory
|
|
21024
|
-
}, chatSettings) {
|
|
20999
|
+
const suggestBestProductMatches = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
21025
21000
|
var _a, _b, _c;
|
|
21026
21001
|
const { environment, customBaseUrl } = options;
|
|
21027
21002
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21028
21003
|
try {
|
|
21029
21004
|
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21030
|
-
body: JSON.stringify(
|
|
21005
|
+
body: JSON.stringify(request),
|
|
21031
21006
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21032
21007
|
}));
|
|
21033
21008
|
if (res.status < 400) {
|
|
@@ -21063,11 +21038,11 @@ const prepareChatHistory = (chatLog) => {
|
|
|
21063
21038
|
}
|
|
21064
21039
|
return history;
|
|
21065
21040
|
};
|
|
21066
|
-
const getTextResponseChunkStream = (options,
|
|
21041
|
+
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
21067
21042
|
var _a;
|
|
21068
21043
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21069
21044
|
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21070
|
-
body: JSON.stringify(
|
|
21045
|
+
body: JSON.stringify(request),
|
|
21071
21046
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21072
21047
|
})).then((response) => {
|
|
21073
21048
|
const reader = response.body.getReader();
|
|
@@ -21087,7 +21062,6 @@ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, o
|
|
|
21087
21062
|
const ChatService = {
|
|
21088
21063
|
suggestSearchChatPhrases,
|
|
21089
21064
|
suggestPhraseAlternatives,
|
|
21090
|
-
suggestSimplifiedPhrases,
|
|
21091
21065
|
suggestBestProductMatches,
|
|
21092
21066
|
prepareChatHistory,
|
|
21093
21067
|
getTextResponseChunkStream
|
|
@@ -21209,7 +21183,8 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
|
|
|
21209
21183
|
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
21210
21184
|
props.options.sdkOptions,
|
|
21211
21185
|
{
|
|
21212
|
-
phrases: [props.phrase]
|
|
21186
|
+
phrases: [props.phrase],
|
|
21187
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21213
21188
|
},
|
|
21214
21189
|
props.options.chatSettings
|
|
21215
21190
|
);
|
|
@@ -21282,7 +21257,8 @@ const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
|
|
|
21282
21257
|
{
|
|
21283
21258
|
initialQuery: props.entry.userInput,
|
|
21284
21259
|
productStrings: productResultStrings,
|
|
21285
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21260
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21261
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21286
21262
|
},
|
|
21287
21263
|
props.options.chatSettings
|
|
21288
21264
|
);
|
|
@@ -21356,7 +21332,8 @@ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
|
|
|
21356
21332
|
props.options.sdkOptions,
|
|
21357
21333
|
{
|
|
21358
21334
|
initialQuery: props.content,
|
|
21359
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21335
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21336
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21360
21337
|
},
|
|
21361
21338
|
processChunk,
|
|
21362
21339
|
props.options.chatSettings
|
package/dist/lupaSearch.umd.js
CHANGED
|
@@ -6391,12 +6391,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
6391
6391
|
});
|
|
6392
6392
|
return output;
|
|
6393
6393
|
};
|
|
6394
|
-
const
|
|
6394
|
+
const inputsAreEqual = (input, possibleValues) => {
|
|
6395
6395
|
if (!input) {
|
|
6396
6396
|
return false;
|
|
6397
6397
|
}
|
|
6398
6398
|
const normalizedInput = getNormalizedString(input);
|
|
6399
|
-
return possibleValues.some((v) => getNormalizedString(v)
|
|
6399
|
+
return possibleValues.some((v) => getNormalizedString(v) === normalizedInput);
|
|
6400
6400
|
};
|
|
6401
6401
|
const initAnalyticsTracking = (analyticsOptions) => {
|
|
6402
6402
|
try {
|
|
@@ -7403,7 +7403,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7403
7403
|
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
7404
7404
|
return false;
|
|
7405
7405
|
}
|
|
7406
|
-
const redirectTo = redirections.value.rules.find((r) =>
|
|
7406
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input, r.sources));
|
|
7407
7407
|
if (!redirectTo) {
|
|
7408
7408
|
return false;
|
|
7409
7409
|
}
|
|
@@ -20976,7 +20976,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20976
20976
|
return { success: false, errors: [e] };
|
|
20977
20977
|
}
|
|
20978
20978
|
});
|
|
20979
|
-
const suggestPhraseAlternatives = (
|
|
20979
|
+
const suggestPhraseAlternatives = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
20980
20980
|
var _a, _b, _c;
|
|
20981
20981
|
const { environment, customBaseUrl } = options;
|
|
20982
20982
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
@@ -20984,7 +20984,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20984
20984
|
const res = yield fetch(
|
|
20985
20985
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
20986
20986
|
__spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
20987
|
-
body: JSON.stringify(
|
|
20987
|
+
body: JSON.stringify(request),
|
|
20988
20988
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
20989
20989
|
})
|
|
20990
20990
|
);
|
|
@@ -21000,38 +21000,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21000
21000
|
return { success: false, errors: [e] };
|
|
21001
21001
|
}
|
|
21002
21002
|
});
|
|
21003
|
-
const
|
|
21004
|
-
var _a, _b, _c;
|
|
21005
|
-
const { environment, customBaseUrl } = options;
|
|
21006
|
-
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21007
|
-
try {
|
|
21008
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21009
|
-
body: JSON.stringify({ phrases }),
|
|
21010
|
-
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21011
|
-
}));
|
|
21012
|
-
if (res.status < 400) {
|
|
21013
|
-
const data = yield res.json();
|
|
21014
|
-
return __spreadProps2(__spreadValues2({}, data), { success: true });
|
|
21015
|
-
}
|
|
21016
|
-
const errors = yield res.json();
|
|
21017
|
-
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
21018
|
-
return { success: false, errors };
|
|
21019
|
-
} catch (e) {
|
|
21020
|
-
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
|
|
21021
|
-
return { success: false, errors: [e] };
|
|
21022
|
-
}
|
|
21023
|
-
});
|
|
21024
|
-
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
21025
|
-
initialQuery,
|
|
21026
|
-
productStrings,
|
|
21027
|
-
messageHistory
|
|
21028
|
-
}, chatSettings) {
|
|
21003
|
+
const suggestBestProductMatches = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
21029
21004
|
var _a, _b, _c;
|
|
21030
21005
|
const { environment, customBaseUrl } = options;
|
|
21031
21006
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21032
21007
|
try {
|
|
21033
21008
|
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21034
|
-
body: JSON.stringify(
|
|
21009
|
+
body: JSON.stringify(request),
|
|
21035
21010
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21036
21011
|
}));
|
|
21037
21012
|
if (res.status < 400) {
|
|
@@ -21067,11 +21042,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21067
21042
|
}
|
|
21068
21043
|
return history;
|
|
21069
21044
|
};
|
|
21070
|
-
const getTextResponseChunkStream = (options,
|
|
21045
|
+
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
21071
21046
|
var _a;
|
|
21072
21047
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21073
21048
|
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21074
|
-
body: JSON.stringify(
|
|
21049
|
+
body: JSON.stringify(request),
|
|
21075
21050
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21076
21051
|
})).then((response) => {
|
|
21077
21052
|
const reader = response.body.getReader();
|
|
@@ -21091,7 +21066,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21091
21066
|
const ChatService = {
|
|
21092
21067
|
suggestSearchChatPhrases,
|
|
21093
21068
|
suggestPhraseAlternatives,
|
|
21094
|
-
suggestSimplifiedPhrases,
|
|
21095
21069
|
suggestBestProductMatches,
|
|
21096
21070
|
prepareChatHistory,
|
|
21097
21071
|
getTextResponseChunkStream
|
|
@@ -21213,7 +21187,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21213
21187
|
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
21214
21188
|
props.options.sdkOptions,
|
|
21215
21189
|
{
|
|
21216
|
-
phrases: [props.phrase]
|
|
21190
|
+
phrases: [props.phrase],
|
|
21191
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21217
21192
|
},
|
|
21218
21193
|
props.options.chatSettings
|
|
21219
21194
|
);
|
|
@@ -21286,7 +21261,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21286
21261
|
{
|
|
21287
21262
|
initialQuery: props.entry.userInput,
|
|
21288
21263
|
productStrings: productResultStrings,
|
|
21289
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21264
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21265
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21290
21266
|
},
|
|
21291
21267
|
props.options.chatSettings
|
|
21292
21268
|
);
|
|
@@ -21360,7 +21336,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21360
21336
|
props.options.sdkOptions,
|
|
21361
21337
|
{
|
|
21362
21338
|
initialQuery: props.content,
|
|
21363
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21339
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21340
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21364
21341
|
},
|
|
21365
21342
|
processChunk,
|
|
21366
21343
|
props.options.chatSettings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getlupa/client",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"main": "dist/lupaSearch.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@getlupa/client-sdk": "^1.3.4",
|
|
23
|
-
"@getlupa/vue": "0.7.
|
|
23
|
+
"@getlupa/vue": "0.7.3",
|
|
24
24
|
"@rushstack/eslint-patch": "^1.3.2",
|
|
25
25
|
"@tsconfig/node18": "^2.0.1",
|
|
26
26
|
"@types/jsdom": "^21.1.1",
|