updated search suggestions functionality

This commit is contained in:
sriram
2026-08-20 12:59:32 +05:30
parent c84f0a9529
commit f5d3d80f42
5 changed files with 281 additions and 10 deletions

View File

@@ -179,8 +179,15 @@ export const api = {
getProductDetail: (brand, imageId) =>
request(`/api/brands/${encodeURIComponent(brand)}/products/${encodeURIComponent(imageId)}`),
search: (q, { brand, category, top_k = 50 } = {}) =>
request(`/api/search${qs({ q, brand, category, top_k })}`),
// Same reasoning as SHOW_ALL_PRODUCTS_LIMIT above: searching a brand name must
// return that brand's whole catalog, not a page of it. The old default of 50
// was in any case ignored - the backend clamped every search to 15.
search: (q, { brand, category, top_k = SHOW_ALL_PRODUCTS_LIMIT, offset = 0 } = {}) =>
request(`/api/search${qs({ q, brand, category, top_k, offset })}`),
// Autocomplete for the catalog search box. Answers from in-process caches,
// so it is safe to call per keystroke (debounced in useSuggestions).
suggest: (q, { limit = 8 } = {}) => request(`/api/suggest${qs({ q, limit })}`),
chat: ({ query, brand, category, top_k, history }) =>
request('/api/chat', {