@@ -21,7 +21,7 @@ import type {
2121 DocumentSchema ,
2222 SearchParams as TypesenseSearchParams ,
2323} from 'typesense/lib/Typesense/Documents' ;
24- import type { MultiSearchRequestSchema } from " typesense/lib/Typesense/Types"
24+ import type { MultiSearchRequestSchema } from ' typesense/lib/Typesense/Types' ;
2525
2626import { DocSearchButton } from './DocSearchButton' ;
2727import { DocSearchModal } from './DocSearchModal' ;
@@ -33,6 +33,7 @@ import type {
3333} from './types' ;
3434
3535import type { ButtonTranslations , ModalTranslations } from '.' ;
36+ import type { TypesenseAskAiSearchParameters } from './types/AskiAi' ;
3637
3738export type { DocSearchRef } from '@docsearch/core' ;
3839
@@ -54,85 +55,33 @@ export type DocSearchTransformClient = {
5455 transporter : Pick < LiteClient [ 'transporter' ] , 'algoliaAgent' > ;
5556} ;
5657
57- // Define the specific search parameters allowed for Ask AI
58- export type AskAiSearchParameters = {
59- facetFilters ?: string [ ] ;
60- filters ?: string ;
61- attributesToRetrieve ?: string [ ] ;
62- restrictSearchableAttributes ?: string [ ] ;
63- distinct ?: boolean | number | string ;
64- } ;
65-
66- export type AgentStudioSearchParameters = Record <
67- string ,
68- Omit < AskAiSearchParameters , 'facetFilters' >
69- > ;
70-
7158export type DocSearchAskAi = {
7259 /**
73- * The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
74- * If not provided, the index name will be used.
60+ * Typesense conversational model id.
7561 */
76- indexName ? : string ;
62+ conversationModelId : string ;
7763 /**
78- * The API key to use for the ask AI feature. Your assistant will use this API key to search the index .
79- * If not provided, the API key will be used .
64+ * Collection to query for conversational retrieval .
65+ * Defaults to `typesenseCollectionName` .
8066 */
81- apiKey ?: string ;
67+ collection ?: string ;
8268 /**
83- * The app ID to use for the ask AI feature. Your assistant will use this app ID to search the index.
84- * If not provided, the app ID will be used.
69+ * Query field to use for conversational retrieval.
70+ *
71+ * @default 'embedding'
8572 */
86- appId ?: string ;
73+ queryBy ?: string ;
8774 /**
88- * The assistant ID to use for the ask AI feature.
75+ * Fields excluded from the conversational payload.
76+ *
77+ * @default 'embedding'
8978 */
90- assistantId : string ;
79+ excludeFields ? : string ;
9180 /**
92- * Enables displaying suggested questions on Ask AI's new conversation screen.
93- *
94- * @default false
81+ * Additional Typesense search parameters for the conversational retrieval request.
9582 */
96- suggestedQuestions ?: boolean ;
97- // HACK: This is a hack for testing staging, remove before releasing
98- useStagingEnv ?: boolean ;
99- } & (
100- | {
101- /**
102- * **Experimental:** Whether to use Agent Studio as the chat backend.
103- *
104- * This is an experimental feature and its API may change without notice in future releases.
105- * Use with caution in production environments.
106- *
107- * @default false
108- */
109- agentStudio ?: never ;
110- /**
111- * The search parameters to use for the ask AI feature.
112- *
113- * **NOTE**: If using `agentStudio = true`, the `searchParameters` object is
114- * keyed by the index name.
115- */
116- searchParameters ?: AskAiSearchParameters ;
117- }
118- | {
119- agentStudio : false ;
120- searchParameters ?: AskAiSearchParameters ;
121- }
122- | {
123- agentStudio : true ;
124- /**
125- * The search parameters to use for the ask AI feature.
126- * Keyed by the index name.
127- *
128- * @example
129- * {
130- * "INDEX_NAME": { distinct: false }
131- * }
132- */
133- searchParameters ?: AgentStudioSearchParameters ;
134- }
135- ) ;
83+ searchParameters ?: TypesenseAskAiSearchParameters ;
84+ } ;
13685
13786export interface DocSearchIndex {
13887 name : string ;
@@ -162,9 +111,9 @@ export interface DocSearchProps {
162111 */
163112 indices ?: Array < DocSearchIndex | string > ;
164113 /**
165- * Configuration or assistant id to enable ask ai mode. Pass a string assistant id or a full config object .
114+ * Configuration to enable Typesense conversational search .
166115 */
167- askAi ?: DocSearchAskAi | string ;
116+ askAi ?: DocSearchAskAi ;
168117 /**
169118 * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a suggested question).
170119 *
0 commit comments