@brainfish-ai/components 0.7.0 → 0.7.1
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/chat-search.d.ts +1 -0
- package/dist/esm/chunks/{ChatSearch.BD2RqFhC.js → ChatSearch.D-TNvcdQ.js} +32 -11
- package/dist/esm/chunks/ChatSearch.D-TNvcdQ.js.map +1 -0
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/dist/esm/chunks/ChatSearch.BD2RqFhC.js.map +0 -1
package/dist/chat-search.d.ts
CHANGED
|
@@ -221,6 +221,7 @@ export declare interface ChatSearchProps {
|
|
|
221
221
|
userData?: Record<string, unknown> | null;
|
|
222
222
|
redirectRules?: RedirectRule[];
|
|
223
223
|
secretAttributes?: string;
|
|
224
|
+
allowedRegions?: string[];
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
export declare const ChatSearchProvider: default_2.FC<{
|
|
@@ -4230,7 +4230,8 @@ async function searchApi({
|
|
|
4230
4230
|
headers,
|
|
4231
4231
|
conversationId,
|
|
4232
4232
|
attributes,
|
|
4233
|
-
secretAttributes
|
|
4233
|
+
secretAttributes,
|
|
4234
|
+
allowedRegions
|
|
4234
4235
|
}) {
|
|
4235
4236
|
const payload = await makeRequest(endpoint, {
|
|
4236
4237
|
method: "POST",
|
|
@@ -4242,7 +4243,8 @@ async function searchApi({
|
|
|
4242
4243
|
...collectionId && collectionId !== "all" && { collectionId },
|
|
4243
4244
|
...conversationId && { conversationId },
|
|
4244
4245
|
...attributes && { attributes },
|
|
4245
|
-
...secretAttributes && { secretAttributes }
|
|
4246
|
+
...secretAttributes && { secretAttributes },
|
|
4247
|
+
...allowedRegions && { allowedRegions }
|
|
4246
4248
|
}
|
|
4247
4249
|
});
|
|
4248
4250
|
return {
|
|
@@ -4337,7 +4339,8 @@ async function fetchAutocomplete({
|
|
|
4337
4339
|
query,
|
|
4338
4340
|
collectionId,
|
|
4339
4341
|
headers,
|
|
4340
|
-
conversationId
|
|
4342
|
+
conversationId,
|
|
4343
|
+
allowedRegions
|
|
4341
4344
|
}) {
|
|
4342
4345
|
const data = await makeRequest(endpoint, {
|
|
4343
4346
|
method: "POST",
|
|
@@ -4346,7 +4349,8 @@ async function fetchAutocomplete({
|
|
|
4346
4349
|
body: {
|
|
4347
4350
|
query,
|
|
4348
4351
|
...collectionId && collectionId !== "all" && { collectionId },
|
|
4349
|
-
...conversationId && { conversationId }
|
|
4352
|
+
...conversationId && { conversationId },
|
|
4353
|
+
...allowedRegions && { allowedRegions }
|
|
4350
4354
|
}
|
|
4351
4355
|
});
|
|
4352
4356
|
return data;
|
|
@@ -5177,6 +5181,7 @@ function useDebounce(value, delay) {
|
|
|
5177
5181
|
function useAutocomplete({
|
|
5178
5182
|
query,
|
|
5179
5183
|
endpoint,
|
|
5184
|
+
allowedRegions,
|
|
5180
5185
|
collectionId,
|
|
5181
5186
|
headers,
|
|
5182
5187
|
conversationId,
|
|
@@ -5199,7 +5204,8 @@ function useAutocomplete({
|
|
|
5199
5204
|
query: debouncedQuery,
|
|
5200
5205
|
collectionId,
|
|
5201
5206
|
headers,
|
|
5202
|
-
conversationId
|
|
5207
|
+
conversationId,
|
|
5208
|
+
allowedRegions
|
|
5203
5209
|
});
|
|
5204
5210
|
setSuggestions(payload?.response?.results);
|
|
5205
5211
|
} catch (err) {
|
|
@@ -5209,7 +5215,7 @@ function useAutocomplete({
|
|
|
5209
5215
|
} finally {
|
|
5210
5216
|
setIsLoading(false);
|
|
5211
5217
|
}
|
|
5212
|
-
}, [debouncedQuery, endpoint, collectionId, headers, conversationId]);
|
|
5218
|
+
}, [debouncedQuery, endpoint, collectionId, headers, conversationId, allowedRegions]);
|
|
5213
5219
|
useEffect(() => {
|
|
5214
5220
|
void fetchSuggestions();
|
|
5215
5221
|
}, [fetchSuggestions]);
|
|
@@ -5246,7 +5252,8 @@ const ChatSearchComponent = forwardRef(
|
|
|
5246
5252
|
onNextBestActionClick,
|
|
5247
5253
|
userData,
|
|
5248
5254
|
redirectRules,
|
|
5249
|
-
secretAttributes
|
|
5255
|
+
secretAttributes,
|
|
5256
|
+
allowedRegions
|
|
5250
5257
|
}, ref) => {
|
|
5251
5258
|
const {
|
|
5252
5259
|
answers,
|
|
@@ -5281,6 +5288,7 @@ const ChatSearchComponent = forwardRef(
|
|
|
5281
5288
|
const { suggestions: autocompleteSuggestions } = useAutocomplete({
|
|
5282
5289
|
query,
|
|
5283
5290
|
endpoint: autocompleteEndpoint || "",
|
|
5291
|
+
allowedRegions,
|
|
5284
5292
|
collectionId: currentCollectionId,
|
|
5285
5293
|
headers,
|
|
5286
5294
|
conversationId: currentConversationId,
|
|
@@ -5460,7 +5468,13 @@ const ChatSearchComponent = forwardRef(
|
|
|
5460
5468
|
setIsSearching(false);
|
|
5461
5469
|
}
|
|
5462
5470
|
};
|
|
5463
|
-
const handleSearchApiCall = async (
|
|
5471
|
+
const handleSearchApiCall = async ({
|
|
5472
|
+
searchQuery,
|
|
5473
|
+
conversationId,
|
|
5474
|
+
attributes,
|
|
5475
|
+
secretAttributes: secretAttributes2,
|
|
5476
|
+
allowedRegions: allowedRegions2
|
|
5477
|
+
}) => {
|
|
5464
5478
|
const searchResponse = await searchApi({
|
|
5465
5479
|
endpoint: searchEndpoint,
|
|
5466
5480
|
query: searchQuery,
|
|
@@ -5468,7 +5482,8 @@ const ChatSearchComponent = forwardRef(
|
|
|
5468
5482
|
headers,
|
|
5469
5483
|
conversationId,
|
|
5470
5484
|
attributes,
|
|
5471
|
-
secretAttributes: secretAttributes2
|
|
5485
|
+
secretAttributes: secretAttributes2,
|
|
5486
|
+
allowedRegions: allowedRegions2
|
|
5472
5487
|
});
|
|
5473
5488
|
if (searchResponse.results.length === 0) {
|
|
5474
5489
|
trackEvent?.("No Articles Found", { conversationId, searchQuery });
|
|
@@ -5498,7 +5513,13 @@ const ChatSearchComponent = forwardRef(
|
|
|
5498
5513
|
followUpSearchRef.current?.focus();
|
|
5499
5514
|
try {
|
|
5500
5515
|
const attributes = { ...userData };
|
|
5501
|
-
const searchQueryId = await handleSearchApiCall(
|
|
5516
|
+
const searchQueryId = await handleSearchApiCall({
|
|
5517
|
+
searchQuery,
|
|
5518
|
+
conversationId,
|
|
5519
|
+
attributes,
|
|
5520
|
+
secretAttributes,
|
|
5521
|
+
allowedRegions
|
|
5522
|
+
});
|
|
5502
5523
|
event && trackEvent?.(event.name, {
|
|
5503
5524
|
conversationId,
|
|
5504
5525
|
searchQuery,
|
|
@@ -5852,4 +5873,4 @@ const ChatSearch = forwardRef(({ featureFlags, ...props }, ref) => /* @__PURE__
|
|
|
5852
5873
|
ChatSearch.displayName = "ChatSearch";
|
|
5853
5874
|
|
|
5854
5875
|
export { ChatSearch as C, ChatSearchProvider as a, useIsChatSearchDirty as b, useChatSearch as u };
|
|
5855
|
-
//# sourceMappingURL=ChatSearch.
|
|
5876
|
+
//# sourceMappingURL=ChatSearch.D-TNvcdQ.js.map
|