@@ -4,12 +4,49 @@ import type { JSX } from 'react';
44import React from 'react' ;
55import { createPortal } from 'react-dom' ;
66
7- import type { AskAiSearchParameters } from './DocSearch' ;
8- import type { SidepanelButtonProps , SidepanelProps } from './Sidepanel/index' ;
7+ import type { AgentStudioSearchParameters , AskAiSearchParameters } from './DocSearch' ;
8+ import type { SidepanelButtonProps , SidepanelProps as SidepanelPanelProps } from './Sidepanel/index' ;
99import { SidepanelButton , Sidepanel } from './Sidepanel/index' ;
1010
1111export type { DocSearchRef , DocSearchCallbacks } from '@docsearch/core' ;
1212
13+ export type SidepanelSearchParameters =
14+ | {
15+ /**
16+ * **Experimental:** Whether to use Agent Studio as the chat backend.
17+ *
18+ * This is an experimental feature and its API may change without notice in future releases.
19+ * Use with caution in production environments.
20+ *
21+ * @default false
22+ */
23+ agentStudio ?: never ;
24+ /**
25+ * The search parameters to use for the ask AI feature.
26+ *
27+ * **NOTE**: If using `agentStudio = true`, the `searchParameters` object is
28+ * keyed by the index name.
29+ */
30+ searchParameters ?: AskAiSearchParameters ;
31+ }
32+ | {
33+ agentStudio : false ;
34+ searchParameters ?: AskAiSearchParameters ;
35+ }
36+ | {
37+ agentStudio : true ;
38+ /**
39+ * The search parameters to use for the ask AI feature.
40+ * Keyed by the index name.
41+ *
42+ * @example
43+ * {
44+ * "INDEX_NAME": { distinct: false }
45+ * }
46+ */
47+ searchParameters ?: AgentStudioSearchParameters ;
48+ } ;
49+
1350export type DocSearchSidepanelProps = DocSearchCallbacks & {
1451 /**
1552 * The assistant ID to use for the ask AI feature.
@@ -27,10 +64,6 @@ export type DocSearchSidepanelProps = DocSearchCallbacks & {
2764 * The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
2865 */
2966 indexName : string ;
30- /**
31- * The search parameters to use for the ask AI feature.
32- */
33- searchParameters ?: AskAiSearchParameters ;
3467 /**
3568 * Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
3669 *
@@ -50,29 +83,13 @@ export type DocSearchSidepanelProps = DocSearchCallbacks & {
5083 /**
5184 * Props specific to the Sidepanel panel.
5285 */
53- panel ?: Omit < SidepanelProps , 'keyboardShortcuts' > ;
54- /**
55- * **Experimental:** Whether to use Agent Studio as the chat backend.
56- *
57- * This is an experimental feature and its API may change without notice in future releases.
58- * Use with caution in production environments.
59- *
60- * @default false
61- */
62- agentStudio ?: boolean ;
86+ panel ?: Omit < SidepanelPanelProps , 'keyboardShortcuts' > ;
6387} ;
6488
89+ type SidepanelProps = DocSearchSidepanelProps & SidepanelSearchParameters ;
90+
6591function DocSearchSidepanelComponent (
66- {
67- keyboardShortcuts,
68- theme,
69- onReady,
70- onOpen,
71- onClose,
72- onSidepanelOpen,
73- onSidepanelClose,
74- ...props
75- } : DocSearchSidepanelProps ,
92+ { keyboardShortcuts, theme, onReady, onOpen, onClose, onSidepanelOpen, onSidepanelClose, ...props } : SidepanelProps ,
7693 ref : React . ForwardedRef < DocSearchRef > ,
7794) : JSX . Element {
7895 return (
0 commit comments