@indxsearch/intrface 3.15.1 → 4.0.0-beta.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/CHANGELOG.md +82 -0
- package/README.md +4 -4
- package/dist/components/AskPanel.d.ts +8 -1
- package/dist/components/QuickAnswer.d.ts +4 -2
- package/dist/components/SearchInput.d.ts +5 -3
- package/dist/components/SearchResults.d.ts +20 -3
- package/dist/context/SearchContext.d.ts +40 -16
- package/dist/hooks/useAsk.d.ts +41 -5
- package/dist/hooks/useSearchOrAsk.d.ts +25 -11
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.ts +3 -5
- package/dist/index.es.js +1526 -1286
- package/dist/intrface.css +1 -1
- package/dist/utils/searchOrAsk.d.ts +20 -42
- package/package.json +3 -3
- package/dist/utils/askPhrases.d.ts +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 867e6a3: `removeDuplicates` is gone from `SearchProvider` and the search settings, and searches no longer send it: the server never acted on it. To show one row per title or per work, use the server's `collapseBy`.
|
|
8
|
+
|
|
9
|
+
## 4.0.0-beta.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 1d26629: Search or ask searches what the visitor types. The Ask phrases are gone: the list is no longer rewritten while a question is typed, and the invitation comes from the judge, which reads a question from its first word in any language. `stripAskPhrases` and the `AskPhrases` type are no longer exported.
|
|
14
|
+
- 14cca8a: A page sends only what it sets, so a dataset's query parameters decide the rest (6.0). The provider's
|
|
15
|
+
`mode` is left out unless the page sets it (the dataset's mode, else EditDistance), and
|
|
16
|
+
`setSearchSettings({ match: undefined })` (or `candidates`, `ranking`) hands a whole part back to the
|
|
17
|
+
dataset. The settings panel shows the dataset's values where the page sets none, from
|
|
18
|
+
`query-parameters`' `effective`. While the offer to ask is strong, the page's searches take
|
|
19
|
+
`STRICT_MATCH` (`tolerance: Exact`, `typingPrefixFrom: 0`, `joinedWords: false`; was
|
|
20
|
+
`STRICT_COVERAGE`), and `visibleResults` takes the count of records counted where it took the
|
|
21
|
+
truncation index.
|
|
22
|
+
- a394c82: The 6.0 wire: a query in three parts. `QueryProxy` takes `mode` (`SearchMode`: `EditDistance`,
|
|
23
|
+
the default, or `Bm25f`; whether the records are reranked by Coverage is `ranking.rerank`, on by
|
|
24
|
+
default) and three parts, `match` (`MatchSetup`: tolerance, rungs, the word being
|
|
25
|
+
typed), `candidates` (`CandidateSetup`: `candidatesPerRow`, `maxCandidates`, `fallback`, `rest`) and
|
|
26
|
+
`ranking` (`RankingProxy`: the blend, field weights and boosts, `boosts` and `buries`).
|
|
27
|
+
`enableCoverage`, `coverageDepth`, `coverageSetup` and the `CoverageSetup` and `CloudQuery` types are
|
|
28
|
+
gone. Enums are strings, by name, as the server now sends and reads them (`BoostStrength.Med`, was
|
|
29
|
+
`Medium`). `Result` loses `truncationIndex` and `truncationScore` and has `toleranceCounts`,
|
|
30
|
+
`countedTolerance`, `count`, `ranked`, `isFallback`, `reason` and `systemState` (`toleranceCounts.rest`
|
|
31
|
+
with `candidates.rest`). The provider's `countedTotal` is the result's `count`. `FieldProxy` follows the
|
|
32
|
+
server's: `wordMatching` in place of `searchable`, and `tolerance` (`Exact`, `OneEdit`,
|
|
33
|
+
`TwoEdits`) in place of `coverageStrictness`, whose `None` is a `rerankWeight` of 0; the
|
|
34
|
+
`CoverageStrictness` enum is gone. Coverage is called reranking: `enableMatchReport`,
|
|
35
|
+
`matchReport` (`MatchReport`) and a field's `rerankWeight` in place of `enableCoverageReport`,
|
|
36
|
+
`coverageReport` and `coverageWeight`.
|
|
37
|
+
|
|
38
|
+
The settings panel shows the mode and a rerank switch. The intrface provider takes `mode`, `match`, `candidates` and `ranking` in place of
|
|
39
|
+
`enableCoverage`, `coverageDepth` (now `candidates.maxCandidates`) and `initialCoverageSetup`;
|
|
40
|
+
`SearchSettings` holds the same, and `setSearchSettings` merges a part member by member. The state's
|
|
41
|
+
`truncationIndex` is `countedTotal`, the records the search counted, with `isFallback` beside it.
|
|
42
|
+
Needs a 6.0 server.
|
|
43
|
+
|
|
44
|
+
- 3b0b1fd: Search or ask follows each of its five modes as the 6.0 server defines them.
|
|
45
|
+
|
|
46
|
+
- The list under an offer is never cut. With the server's "strong matches only" gone, the cut emptied the list under most questions. `cutResults`, `cutRule`, `visibleResults`, `DEFAULT_CUT`, `CutRule` and `SCORE_SCALE` are removed.
|
|
47
|
+
- `SearchResults` dims the list, with a line above it, when the judge reads what is asked about as not in the results (`found` below `thresholds.found`). The hook's state has `found` and `notFound`; `notFoundLabel` words the line.
|
|
48
|
+
- While asking is held, nothing is offered in any mode: no Ask button in open, no hint in inviting, no answer starting in proactive, and Enter searches. That is when the model provider refuses answers (reason `paused`) or the dataset's calls for today are spent. The state says so as `held`.
|
|
49
|
+
- `AskPanel` tells a refusal apart: a proactive start the server refuses shows nothing, a spent budget says asking is back tomorrow, and asking that is not on here gets a sentence for the visitor rather than the server's text for the owner.
|
|
50
|
+
- An intent answering 404 (the dataset does not show Search or ask) turns the hook off, as a 409 does.
|
|
51
|
+
- `SearchOrAskMode` and `pageMode` are exported. The hook's `mode` doc now says what it does: a page's `proactive` is `inviting` where the dataset is not proactive.
|
|
52
|
+
- `setSearchRewrite`, the Ask phrases' hook into the provider, is gone; the provider's `searchTextOf` stays.
|
|
53
|
+
- `QuickAnswer` shows the plain Ask of open, inviting and proactive (a new `ask` quick state, `labels.ask`), so a page that puts the offer in a row of its own keeps the Ask that those modes always have. `SearchInput`'s chip reads the same state.
|
|
54
|
+
|
|
55
|
+
- 75714b7: On a catalogue, the assistant's picks are the result list while the conversation is open, with nothing for the page to wire. The answer chooses the records that answer the visitor by reading them, best first, each with why. `AskPanel` puts them on the `SearchProvider` (`picks`, `showPicks`); `SearchResults` lists them in place of the search, numbered as the answer cites them, with the reason under each row, and a way back ("Show the search instead", or "Show all 45 found" when the picks came with a search); `SearchInput` drops its Nearest and No results chips, which are about the search. Typing, Clear, a new conversation or the panel going gives the list back. A proactive answer leaves the list alone. `AskPanel`'s `onPicks` reports them and `listPicks={false}` keeps them in the panel; `SearchResults` takes `picks` and `onShowSearch` to override. A pick opened is reported against the answer, and a follow-up sends the picks as what the last turn showed (`AskTurn.shown.picks`). New types `AskPick`, `AskPicks`.
|
|
56
|
+
|
|
57
|
+
### Minor Changes
|
|
58
|
+
|
|
59
|
+
- 0b3925e: `filters/combine` takes a list. `CombinedFilterProxy` is `{ filters: FilterProxy[], useAndOperation }`
|
|
60
|
+
in place of `{ a, b, useAndOperation }`, and the server makes one filter of the whole list. The
|
|
61
|
+
intrface sends one combine per field and one for the whole selection, where it sent one per pair:
|
|
62
|
+
three values on one field were two requests and are one. Needs a server with the list form.
|
|
63
|
+
- 496a2dc: The search state keeps the rest of what a 6.0 search says about itself: `toleranceCounts` (the
|
|
64
|
+
counted records by typo level, for "140 results, 45 with a typo"), `countedTolerance`, `ranked`,
|
|
65
|
+
`reranked` and `fill`, beside `countedTotal` and `isFallback`.
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- 342e1a4: A search asks the server to send the records with its answer, so each search is one call instead of a search followed by a lookup. A server that does not send them yet is asked for them as before.
|
|
70
|
+
- 2c89d15: Search or ask offers to answer once the question is whole. While a question is still being typed ("which school is"), the visitor sees the invitation, and the offer to answer follows when the rest is there.
|
|
71
|
+
- Updated dependencies [c4f1ecb]
|
|
72
|
+
- Updated dependencies [0b3925e]
|
|
73
|
+
- Updated dependencies [a880596]
|
|
74
|
+
- Updated dependencies [c3d895c]
|
|
75
|
+
- Updated dependencies [9085f78]
|
|
76
|
+
- Updated dependencies [a394c82]
|
|
77
|
+
- Updated dependencies [1ba5cc7]
|
|
78
|
+
- Updated dependencies [c4ff027]
|
|
79
|
+
- Updated dependencies [9bd6669]
|
|
80
|
+
- Updated dependencies [4829cc7]
|
|
81
|
+
- Updated dependencies [496a2dc]
|
|
82
|
+
- @indxsearch/systm@2.25.0-beta.0
|
|
83
|
+
- @indxsearch/indx-types@4.0.0-beta.0
|
|
84
|
+
|
|
3
85
|
## 3.15.1
|
|
4
86
|
|
|
5
87
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -370,12 +370,12 @@ Two optional `SearchProvider` props shape what the statistics see:
|
|
|
370
370
|
| `dataset` | `string` | ✅ | - | Dataset name |
|
|
371
371
|
| `allowEmptySearch` | `boolean` | ❌ | `false` | Show results without query |
|
|
372
372
|
| `enableFacets` | `boolean` | ❌ | `true` | Enable faceted search |
|
|
373
|
-
| `enableCoverage` | `boolean` | ❌ | `true` | Enable coverage-based fuzzy matching |
|
|
374
373
|
| `maxResults` | `number` | ❌ | `10` | Max results per search |
|
|
375
374
|
| `facetDebounceDelayMillis` | `number` | ❌ | `500` | Debounce delay for facet updates (ms) |
|
|
376
|
-
| `
|
|
377
|
-
| `
|
|
378
|
-
| `
|
|
375
|
+
| `mode` | `SearchMode` | ❌ | `Coverage` | `Coverage`, `EditDistance` or `Bm25f` (ranking alone, no word lookup) |
|
|
376
|
+
| `match` | `MatchSetup` | ❌ | `{}` | What counts as a hit: `tolerance`, `rungs`, the word being typed. A member left out is the server's default |
|
|
377
|
+
| `candidates` | `CandidateSetup` | ❌ | `{}` | Who comes in: `candidatesPerRow`, `maxCandidates`, `fallback` |
|
|
378
|
+
| `ranking` | `RankingProxy` | ❌ | `{}` | The order: the blend, field weights and boosts, `boosts`, `buries` |
|
|
379
379
|
| `enableDebugLogs` | `boolean` | ❌ | `false` | Enable detailed console logging |
|
|
380
380
|
| `source` | `string` | ❌ | - | Names this search surface in the statistics (`"header"`, `"app"`); counted as usual. See [Search statistics](#search-statistics) |
|
|
381
381
|
| `count` | `boolean` | ❌ | `true` | `false` keeps this page's searches and clicks out of the statistics (stored, not counted) |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { AskSource, AskStatus, AskFilters } from '../hooks/useAsk';
|
|
2
|
+
import { AskSource, AskStatus, AskFilters, AskPicks } from '../hooks/useAsk';
|
|
3
3
|
export interface AskPanelProps {
|
|
4
4
|
/** The question to answer. A new value asks it and starts a new conversation; null or empty
|
|
5
5
|
* shows nothing. To ask the same text again, give the panel a new `key`. */
|
|
@@ -26,6 +26,13 @@ export interface AskPanelProps {
|
|
|
26
26
|
/** On a catalogue, called with the filters a description was searched with, as soon as they are
|
|
27
27
|
* known: give them to `useFilterSuggestion().apply` so the page's list shows the same set. */
|
|
28
28
|
onFilters?: (filters: AskFilters) => void;
|
|
29
|
+
/** On a catalogue, called with the records the assistant picked, as soon as they are known. The
|
|
30
|
+
* panel also makes them the page's list itself (`SearchResults` shows them, `SearchInput` drops
|
|
31
|
+
* its search chips), unless the answer was `proactive` or `listPicks` is false. */
|
|
32
|
+
onPicks?: (picks: AskPicks) => void;
|
|
33
|
+
/** Make the assistant's picks the page's list. Default true; never for a proactive answer, which
|
|
34
|
+
* leaves the page as the visitor has it. */
|
|
35
|
+
listPicks?: boolean;
|
|
29
36
|
/** How a filter reads on its chip. Default: a text value as itself, a yes/no by its field's
|
|
30
37
|
* name, a range by its bounds. */
|
|
31
38
|
filterLabel?: (filter: AskFilters['filters'][number]) => string;
|
|
@@ -6,7 +6,7 @@ export interface QuickAnswerProps {
|
|
|
6
6
|
/** Called with the text to ask, as SearchInput's `onAsk`. */
|
|
7
7
|
onAsk: (text: string) => void;
|
|
8
8
|
/** The words, for a page in another language. */
|
|
9
|
-
labels?: Partial<Record<'invite' | 'hint' | 'ready' | 'thinking', string>>;
|
|
9
|
+
labels?: Partial<Record<'invite' | 'hint' | 'ready' | 'thinking' | 'ask', string>>;
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -15,6 +15,8 @@ export interface QuickAnswerProps {
|
|
|
15
15
|
* hook's `quick` state. In inviting and proactive the invitation sweeps as soon as a question starts
|
|
16
16
|
* ("For a quick answer, type a bit more"), meant to teach a visitor that the field answers too; in
|
|
17
17
|
* proactive the sure offer is no button but "Thinking", sweeping, until the answer starts on its
|
|
18
|
-
* own.
|
|
18
|
+
* own. In open, inviting and proactive, where asking is always there, a text the judge has nothing
|
|
19
|
+
* to say about still gets a quiet Ask. Nothing shows when there is nothing to offer, and a click on
|
|
20
|
+
* any of it asks.
|
|
19
21
|
*/
|
|
20
22
|
export declare const QuickAnswer: React.FC<QuickAnswerProps>;
|
|
@@ -13,9 +13,11 @@ export interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputEle
|
|
|
13
13
|
/** Search or ask: when given, and the dataset has it switched on, an offer to ask appears in
|
|
14
14
|
* the chip row while the visitor types something an answer would serve. A strong offer also
|
|
15
15
|
* makes Enter ask. Called with the text to ask; show the answer with `AskPanel`. The dataset's
|
|
16
|
-
* mode decides how forward the offer is: in `open` and `proactive` an Ask button is
|
|
17
|
-
* whenever something is typed and Enter asks;
|
|
18
|
-
*
|
|
16
|
+
* mode decides how forward the offer is: in `open`, `inviting` and `proactive` an Ask button is
|
|
17
|
+
* there whenever something is typed and Enter asks; `inviting` and `proactive` also invite early
|
|
18
|
+
* ("For a quick answer, type a bit more"); in `proactive` the field asks on its own once the
|
|
19
|
+
* judge is sure, with `{ proactive: true }`, which the page passes to `AskPanel`. While asking is
|
|
20
|
+
* held (the provider refusing answers, the day's calls spent) nothing is offered in any mode. */
|
|
19
21
|
onAsk?: (text: string, how?: {
|
|
20
22
|
proactive: boolean;
|
|
21
23
|
}) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SearchResult as SearchResultData } from '../context/SearchContext';
|
|
3
3
|
import { SearchOrAskState } from '../hooks/useSearchOrAsk';
|
|
4
|
+
import { AskPicks } from '../hooks/useAsk';
|
|
4
5
|
export interface SearchResultsProps {
|
|
5
6
|
fields?: string[];
|
|
6
7
|
resultsPerPage?: number;
|
|
@@ -18,11 +19,27 @@ export interface SearchResultsProps {
|
|
|
18
19
|
*/
|
|
19
20
|
children: (item: Record<string, any>, meta: SearchResultMeta) => React.ReactNode;
|
|
20
21
|
/**
|
|
21
|
-
* The offer, when the page runs `useSearchOrAsk`:
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* The offer, when the page runs `useSearchOrAsk`: under the full offer to a question whose
|
|
23
|
+
* answer the judge reads as not in the results (`notFound`), the list is dimmed with a line
|
|
24
|
+
* above it, so the offer is what the visitor reads first. The list itself is never cut.
|
|
24
25
|
*/
|
|
25
26
|
searchOrAsk?: SearchOrAskState;
|
|
27
|
+
/** The line above a dimmed list, for a page in another language. */
|
|
28
|
+
notFoundLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The records the assistant picked. Left out, the provider's: `AskPanel` puts them there, and
|
|
31
|
+
* while they stand the list is those, in the assistant's order and numbered as its answer cites
|
|
32
|
+
* them, each with why it was picked, in place of the search. They stand for the field's text as it
|
|
33
|
+
* was when they came: once the visitor types or clears the field, the list is the search again.
|
|
34
|
+
* Given, these instead; null never lists picks.
|
|
35
|
+
*/
|
|
36
|
+
picks?: AskPicks | null;
|
|
37
|
+
/** The way back to the search over the picks: "Show all 45 found" when the picks came with a
|
|
38
|
+
* search, "Show the search instead" otherwise. Left out, it does that itself: applies the
|
|
39
|
+
* picks' search when there is one, and gives the list back. */
|
|
40
|
+
onShowSearch?: () => void;
|
|
41
|
+
/** The heading over the picks. Default "Picked by the assistant". */
|
|
42
|
+
picksLabel?: string;
|
|
26
43
|
/**
|
|
27
44
|
* Shows each result's score beside it. Given, it wins over the `showScore` search setting (the
|
|
28
45
|
* toggle in SearchSettingsPanel); left out, that setting decides, and it is on by default.
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AskPicks } from '../hooks/useAsk';
|
|
3
|
+
import { SearchMode, MatchSetup, CandidateSetup, RankingProxy, ToleranceCounts, PageFill, Tolerance } from '@indxsearch/indx-types';
|
|
3
4
|
import { SearchErrorInfo } from './searchError';
|
|
4
5
|
import { ValueMatch, NumericRange } from './buildFilterProxy';
|
|
5
6
|
export type { ValueMatch, NumericRange };
|
|
7
|
+
/**
|
|
8
|
+
* What every search from this provider is asked with: the query's mode and its three parts, as
|
|
9
|
+
* the server takes them (6.0). The mode, or a member of a part, left out is the dataset's on the
|
|
10
|
+
* server (its query parameters), else the engine default, so a page sets only what it means to
|
|
11
|
+
* decide itself: every value it sends wins over the dataset's.
|
|
12
|
+
*/
|
|
6
13
|
export interface SearchSettings {
|
|
7
14
|
maxNumberOfRecordsToReturn: number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
/** Left out: the dataset's mode, else EditDistance. */
|
|
16
|
+
mode?: SearchMode;
|
|
17
|
+
/** What counts as a hit: tolerance, rungs, the word being typed. */
|
|
18
|
+
match: MatchSetup;
|
|
19
|
+
/** Who comes in: the bound on the candidates, the fallback. */
|
|
20
|
+
candidates: CandidateSetup;
|
|
21
|
+
/** The order: the blend, field weights and boosts, boosts and buries. */
|
|
22
|
+
ranking: RankingProxy;
|
|
23
|
+
/** Ask the server to order a search no record holds every word of by the rarest words the records
|
|
24
|
+
* hold (`?refocus=true`). useSearchOrAsk sets it while the judge reads a question or a description. */
|
|
25
|
+
refocus?: boolean;
|
|
12
26
|
minimumScore: number;
|
|
13
27
|
showScore: boolean;
|
|
14
28
|
placeholderText: string;
|
|
@@ -52,7 +66,13 @@ export interface SearchState {
|
|
|
52
66
|
sortBy?: string;
|
|
53
67
|
sortAscending?: boolean;
|
|
54
68
|
searchSettings: SearchSettings;
|
|
55
|
-
|
|
69
|
+
countedTotal?: number;
|
|
70
|
+
isFallback?: boolean;
|
|
71
|
+
toleranceCounts?: ToleranceCounts | null;
|
|
72
|
+
countedTolerance?: Tolerance | null;
|
|
73
|
+
ranked?: number;
|
|
74
|
+
reranked?: boolean;
|
|
75
|
+
fill?: PageFill | null;
|
|
56
76
|
totalDocumentCount?: number;
|
|
57
77
|
queryId?: string;
|
|
58
78
|
}
|
|
@@ -93,13 +113,17 @@ export interface SearchContextType {
|
|
|
93
113
|
sessionId?: string;
|
|
94
114
|
source?: string;
|
|
95
115
|
count?: boolean;
|
|
96
|
-
/** What the search runs on: `state.query`, or what `searchTextOf`
|
|
116
|
+
/** What the search runs on: `state.query`, or what the provider's `searchTextOf` made of it. */
|
|
97
117
|
searchText?: string;
|
|
118
|
+
/** The assistant's picks, while they are the list: `AskPanel` puts them here when they come, and
|
|
119
|
+
* they stand for the text in the field then, so typing or Clear gives the list back to the
|
|
120
|
+
* search. SearchResults lists them, and SearchInput drops its Nearest and No results chips,
|
|
121
|
+
* which are about the search. */
|
|
122
|
+
picks?: AskPicks | null;
|
|
123
|
+
/** Makes picks the list, or null to give it back to the search. */
|
|
124
|
+
showPicks?: (picks: AskPicks | null) => void;
|
|
98
125
|
/** Searches the typed text as it is, this once: the way back from a rewrite ("Search for your exact words"). */
|
|
99
126
|
searchAsTyped?: () => void;
|
|
100
|
-
/** Registers what the search runs on for what is typed, for a hook inside the provider
|
|
101
|
-
* (useSearchOrAsk's Ask phrases); null takes it off. The provider's own `searchTextOf` wins. */
|
|
102
|
-
setSearchRewrite?: (rewrite: ((typed: string) => string) | null) => void;
|
|
103
127
|
}
|
|
104
128
|
/** The field's placeholder unless the page sets one. SearchInput says "Search or ask" instead
|
|
105
129
|
* while asking is on, so it must know this one from a page's own. */
|
|
@@ -114,10 +138,10 @@ export declare const SearchProvider: React.FC<{
|
|
|
114
138
|
maxResults?: number;
|
|
115
139
|
facetDebounceDelayMillis?: number;
|
|
116
140
|
enableFacets?: boolean;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
141
|
+
mode?: SearchMode;
|
|
142
|
+
match?: MatchSetup;
|
|
143
|
+
candidates?: CandidateSetup;
|
|
144
|
+
ranking?: RankingProxy;
|
|
121
145
|
enableDebugLogs?: boolean;
|
|
122
146
|
preAuthenticatedToken?: string;
|
|
123
147
|
source?: string;
|
|
@@ -125,8 +149,8 @@ export declare const SearchProvider: React.FC<{
|
|
|
125
149
|
locale?: string;
|
|
126
150
|
count?: boolean;
|
|
127
151
|
/** The text to search for what is typed, when it is not the typed text itself: the field keeps
|
|
128
|
-
* showing what the visitor typed, and the search runs on this
|
|
129
|
-
*
|
|
152
|
+
* showing what the visitor typed, and the search runs on this ("help me find the movie about the
|
|
153
|
+
* green ogre" searching "green ogre"). Called on every
|
|
130
154
|
* render with the typed text; return it unchanged to search it as typed. */
|
|
131
155
|
searchTextOf?: (typed: string) => string;
|
|
132
156
|
}>;
|
package/dist/hooks/useAsk.d.ts
CHANGED
|
@@ -8,13 +8,35 @@ export interface AskSource {
|
|
|
8
8
|
export interface AskTurn {
|
|
9
9
|
question: string;
|
|
10
10
|
answer: string;
|
|
11
|
-
/** On a catalogue, the list that turn put on the page
|
|
11
|
+
/** On a catalogue, the list that turn put on the page, a search or the assistant's picks: a
|
|
12
|
+
* follow-up is about it. */
|
|
12
13
|
shown?: {
|
|
13
|
-
filters
|
|
14
|
-
text
|
|
14
|
+
filters?: AskFilters['filters'];
|
|
15
|
+
text?: string;
|
|
15
16
|
sort?: AskFilters['sort'];
|
|
17
|
+
picks?: {
|
|
18
|
+
documentKey: number;
|
|
19
|
+
title: string;
|
|
20
|
+
}[];
|
|
16
21
|
};
|
|
17
22
|
}
|
|
23
|
+
/** A record the assistant picked for the page's list, numbered as the answer cites it ([n]), with
|
|
24
|
+
* why it was picked. */
|
|
25
|
+
export interface AskPick {
|
|
26
|
+
n: number;
|
|
27
|
+
documentKey: number;
|
|
28
|
+
title: string;
|
|
29
|
+
why: string;
|
|
30
|
+
}
|
|
31
|
+
/** On a catalogue, the records the assistant picked by reading them: the page's list while the
|
|
32
|
+
* conversation is open. `search` is the search behind them when the visitor asked for all of
|
|
33
|
+
* something (every private school in a town), so the page can offer all it found. `askId` names
|
|
34
|
+
* the answer, for reporting a pick that is opened. */
|
|
35
|
+
export interface AskPicks {
|
|
36
|
+
picks: AskPick[];
|
|
37
|
+
search?: AskFilters | null;
|
|
38
|
+
askId?: string;
|
|
39
|
+
}
|
|
18
40
|
export type AskStatus = 'idle' | 'searching' | 'writing' | 'answered' | 'error' | 'limited';
|
|
19
41
|
export interface AskState {
|
|
20
42
|
question: string;
|
|
@@ -23,17 +45,24 @@ export interface AskState {
|
|
|
23
45
|
answer: string;
|
|
24
46
|
sources: AskSource[];
|
|
25
47
|
/** Why it failed, when status is 'error': the server's code (nothingFound, upstreamBusy, failed,
|
|
26
|
-
* or an HTTP problem code
|
|
48
|
+
* or an HTTP problem code: searchOrAskDisabled, searchOrAskUnavailable, http404 where the dataset
|
|
49
|
+
* does not show it) and a sentence for the visitor. A refusal's own text is the owner's, so the
|
|
50
|
+
* sentence for one is intrface's. */
|
|
27
51
|
error?: {
|
|
28
52
|
code: string;
|
|
29
53
|
message: string;
|
|
30
54
|
};
|
|
31
55
|
/** When status is 'limited': seconds until asking again may succeed. */
|
|
32
56
|
retryAfterSeconds?: number;
|
|
57
|
+
/** When status is 'limited': `address`, too many questions from this visitor for now; `budget`,
|
|
58
|
+
* the dataset's questions for today are spent, until midnight UTC. */
|
|
59
|
+
limit?: 'address' | 'budget';
|
|
33
60
|
/** The server's id for this ask (Indx-Ask-Id). A source opened is reported against it. */
|
|
34
61
|
askId?: string;
|
|
35
62
|
/** On a catalogue, a description's filters, as the server searched with them, and what it found. */
|
|
36
63
|
filters?: AskFilters;
|
|
64
|
+
/** On a catalogue, the records the assistant picked for the list (its several searches). */
|
|
65
|
+
picks?: AskPicks;
|
|
37
66
|
/** What the agent has done so far ("Searching: Folkehøyskole, by Elevtall"), while it works. */
|
|
38
67
|
steps: string[];
|
|
39
68
|
}
|
|
@@ -75,17 +104,24 @@ export declare function useAsk(): {
|
|
|
75
104
|
answer: string;
|
|
76
105
|
sources: AskSource[];
|
|
77
106
|
/** Why it failed, when status is 'error': the server's code (nothingFound, upstreamBusy, failed,
|
|
78
|
-
* or an HTTP problem code
|
|
107
|
+
* or an HTTP problem code: searchOrAskDisabled, searchOrAskUnavailable, http404 where the dataset
|
|
108
|
+
* does not show it) and a sentence for the visitor. A refusal's own text is the owner's, so the
|
|
109
|
+
* sentence for one is intrface's. */
|
|
79
110
|
error?: {
|
|
80
111
|
code: string;
|
|
81
112
|
message: string;
|
|
82
113
|
};
|
|
83
114
|
/** When status is 'limited': seconds until asking again may succeed. */
|
|
84
115
|
retryAfterSeconds?: number;
|
|
116
|
+
/** When status is 'limited': `address`, too many questions from this visitor for now; `budget`,
|
|
117
|
+
* the dataset's questions for today are spent, until midnight UTC. */
|
|
118
|
+
limit?: "address" | "budget";
|
|
85
119
|
/** The server's id for this ask (Indx-Ask-Id). A source opened is reported against it. */
|
|
86
120
|
askId?: string;
|
|
87
121
|
/** On a catalogue, a description's filters, as the server searched with them, and what it found. */
|
|
88
122
|
filters?: AskFilters;
|
|
123
|
+
/** On a catalogue, the records the assistant picked for the list (its several searches). */
|
|
124
|
+
picks?: AskPicks;
|
|
89
125
|
/** What the agent has done so far ("Searching: Folkehøyskole, by Elevtall"), while it works. */
|
|
90
126
|
steps: string[];
|
|
91
127
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Offer, SearchOrAskMode } from '../utils/searchOrAsk';
|
|
2
2
|
export interface UseSearchOrAskOptions {
|
|
3
3
|
/** false keeps the hook quiet: no settings read, no judgement. Default true. */
|
|
4
4
|
enabled?: boolean;
|
|
@@ -13,7 +13,7 @@ export interface UseSearchOrAskOptions {
|
|
|
13
13
|
/** The page's own mode in place of the dataset's: `strict` on a page where a wrong offer costs
|
|
14
14
|
* more, `open` where asking should always be there. `proactive` applies only where the dataset
|
|
15
15
|
* is proactive too, since the server starts no answer on its own for any other; elsewhere it is
|
|
16
|
-
* `
|
|
16
|
+
* `inviting`. Left out, the dataset's mode applies. */
|
|
17
17
|
mode?: SearchOrAskMode;
|
|
18
18
|
/** Proactive: how long the visitor must have been still before an answer starts on its own, at
|
|
19
19
|
* least the pause. Default 1000 ms: a typing pause is a breath, this is having stopped. */
|
|
@@ -35,14 +35,27 @@ export interface SearchOrAskState {
|
|
|
35
35
|
criteria: number | null;
|
|
36
36
|
/** On a catalogue: the text describes what to list, so it can become filters (useFilterSuggestion). */
|
|
37
37
|
describes: boolean;
|
|
38
|
-
/** The
|
|
39
|
-
* (
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
/** The judge's reading of whether what is asked about is among the results; null when it did not
|
|
39
|
+
* say (a judge not asked it). */
|
|
40
|
+
found: number | null;
|
|
41
|
+
/** Under the full offer to a question, the judge reads what is asked about as not in the results
|
|
42
|
+
* (`found` below the dataset's `thresholds.found`): dim the list, with a line above it, so the
|
|
43
|
+
* offer is what the visitor reads first. SearchResults does it when handed this state. */
|
|
44
|
+
notFound: boolean;
|
|
45
|
+
/** Asking is held: the model provider refuses answers for now (the judgement's reason `paused`),
|
|
46
|
+
* or the dataset's calls for today are spent. Nothing is offered, in any mode, until it passes;
|
|
47
|
+
* the search works as before. */
|
|
48
|
+
held: boolean;
|
|
49
|
+
/** The page's searches match whole words only: the offer is strong and the dataset has that rule
|
|
50
|
+
* on (`strictCoverageWhileAsking`). The hook sets and clears it on the search context itself. */
|
|
45
51
|
strictCoverage: boolean;
|
|
52
|
+
/** The page's searches ask for `?refocus=true`: the judge read the text as a question or a
|
|
53
|
+
* description (the dataset's `thresholds.refocus`), so a search no record holds every word of
|
|
54
|
+
* comes back ordered by the rarest words the records hold. Sticky while the visitor types on:
|
|
55
|
+
* it stays while the text extends the one judged and the next judgements stay near the line,
|
|
56
|
+
* so the list does not flip at every pause. Silent: nothing on the page says so. The hook sets
|
|
57
|
+
* and clears it on the search context itself. */
|
|
58
|
+
refocus: boolean;
|
|
46
59
|
/** On a catalogue, what to do with a description while typing (the dataset's `filtersWhileTyping`):
|
|
47
60
|
* 'off' leaves the list until Ask, 'facets' applies typed facet values at once, 'model' also asks
|
|
48
61
|
* the filters route for the rest. `useFilterSuggestion({ auto })` acts on it. */
|
|
@@ -67,7 +80,8 @@ export interface SearchOrAskState {
|
|
|
67
80
|
* thresholds' low `hint` score, or a sentence; also proactive's sure offer on a question not yet
|
|
68
81
|
* finished); `ready`, the full offer, Enter asks
|
|
69
82
|
* (every mode but proactive); `thinking`, proactive about to answer on its own, sweeping, no
|
|
70
|
-
* button; `
|
|
83
|
+
* button; `ask`, a plain Ask with nothing more to say (open, inviting and proactive, where
|
|
84
|
+
* asking is always there); `none` otherwise. Only while the offer stands for what is in the field. */
|
|
71
85
|
quick: QuickState;
|
|
72
86
|
/** The offer is for what is in the field now: the field still extends the text it was judged on.
|
|
73
87
|
* Typing on from a question keeps it (the hook does not ask again while the text only grows);
|
|
@@ -75,7 +89,7 @@ export interface SearchOrAskState {
|
|
|
75
89
|
* offer only while this holds, or it blinks out on every keystroke or lingers after a change. */
|
|
76
90
|
stands: boolean;
|
|
77
91
|
}
|
|
78
|
-
export type QuickState = 'none' | 'invite' | 'hint' | 'ready' | 'thinking';
|
|
92
|
+
export type QuickState = 'none' | 'invite' | 'hint' | 'ready' | 'thinking' | 'ask';
|
|
79
93
|
/**
|
|
80
94
|
* Decides, while the visitor types, whether to offer an answer beside the results. Reads the
|
|
81
95
|
* dataset's Search or ask settings once, then on each typing pause asks the server's judge
|