import { SearchIndexToolType, RecommendToolType } from '../../lib/chat'; import type { ChatRenderState, ChatConnectorParams, ChatWidgetDescription } from '../../connectors/chat/connectChat'; import type { WidgetFactory, Hit, TemplateWithBindEvent, BaseHit, Template, IndexUiState } from '../../types'; import type { ChatClassNames, ChatHeaderProps, ChatLayoutOwnProps, ChatMessageActionProps, ChatMessageBase, ChatMessageErrorProps, ChatEmptyProps, ChatMessageLoaderProps, ChatPromptProps, ChatToggleButtonProps, ClientSideToolComponentProps, ClientSideTools, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components'; export { SearchIndexToolType, RecommendToolType }; export type ClientSideToolTemplateData = ClientSideToolComponentProps; export type UserClientSideToolTemplates = Partial<{ layout: TemplateWithBindEvent; }>; type UserClientSideToolWithTemplate = Omit & { templates: UserClientSideToolTemplates; }; type UserClientSideToolsWithTemplate = Record; export type Tool = UserClientSideToolWithTemplate; export type Tools = UserClientSideToolsWithTemplate; export type ChatCSSClasses = Partial; export type ChatLayoutTemplateData = Omit & { templates: { header: () => JSX.Element; messages: () => JSX.Element; prompt: () => JSX.Element; toggleButton: () => JSX.Element; }; }; export type ChatTemplates = BaseHit> = Partial<{ /** * Custom layout template for the chat widget. */ layout: Template; /** * Template to use for each result. This template will receive an object containing a single record. */ item: TemplateWithBindEvent>; /** * Custom loader template for the chat widget. */ loader: Template; /** * Templates to use for the header. */ header: Partial<{ /** * Template to use for the chat header. */ layout: Template; /** * Optional close icon */ closeIcon: Template; /** * Optional minimize icon */ minimizeIcon?: Template; /** * Optional maximize icon */ maximizeIcon?: Template<{ maximized: boolean; }>; /** * Optional title icon (defaults to sparkles) */ titleIcon?: Template; /** * The title to display in the header */ titleText: string; /** * Accessible label for the minimize button */ minimizeLabelText: string; /** * Accessible label for the maximize button */ maximizeLabelText: string; /** * Accessible label for the close button */ closeLabelText: string; /** * Text for the clear button */ clearLabelText: string; }>; /** * Templates to use for the messages. */ messages: Partial<{ /** * Template to use when there is an error loading messages */ error: Template; /** * Label for the scroll to bottom button */ scrollToBottomLabelText?: string; /** * Text to display in the loader */ loaderText?: string; /** * Label for the copy to clipboard action */ copyToClipboardLabelText?: string; /** * Label for the regenerate action */ regenerateLabelText?: string; }>; /** * Templates to use for each message. */ message: Partial<{ /** * Label for the message actions */ actionsLabelText?: string; /** * Label for the message container */ messageLabelText?: string; }>; /** * Templates to use for the assistant message. */ assistantMessage: Partial<{ /** * Template to use for the assistant message leading content. */ leading: Template; /** * Template to use for the assistant message footer content. */ footer: Template; }>; /** * Templates to use for the user message. */ userMessage: Partial<{ /** * Template to use for the user message leading content. */ leading: Template; /** * Template to use for the user message footer content. */ footer: Template; }>; /** * Templates to use for the prompt. */ prompt: Partial<{ /** * Template to use for the chat prompt. */ layout: Template; /** * Template to use for the prompt header. */ header: Template; /** * Template to use for the prompt footer. */ footer: Template; /** * The label for the textarea */ textareaLabelText: string; /** * The placeholder text for the textarea */ textareaPlaceholderText: string; /** * The tooltip for the submit button when message is empty */ emptyMessageTooltipText: string; /** * The tooltip for the stop button */ stopResponseTooltipText: string; /** * The tooltip for the send button */ sendMessageTooltipText: string; /** * The disclaimer text shown in the footer */ disclaimerText: string; }>; /** * Templates to use for the toggle button. */ toggleButton: Partial<{ /** * Template to use for the toggle button layout. */ layout: Template; /** * Template to use for the toggle button icon. */ icon: Template<{ isOpen: boolean; }>; }>; /** * Template to use for the message actions. */ actions: Template<{ actions: ChatMessageActionProps[]; message: ChatMessageBase; }>; /** * Template to use for the empty screen shown when there are no messages */ empty?: Template; /** * Template to use for prompt suggestions. */ suggestions: Template<{ suggestions: string[]; onSuggestionClick: (suggestion: string) => void; }>; }>; type ChatWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * Return the URL of the main search page with the `nextUiState`. * This is used to navigate to the main search page when the user clicks on "View all" in the search tool. * * @example (nextUiState) => `/search?${qs.stringify(nextUiState)}` */ getSearchPageURL?: (nextUiState: IndexUiState) => string; /** * Client-side tools to add to the chat */ tools?: UserClientSideToolsWithTemplate; /** * Templates to use for the widget. */ templates?: ChatTemplates; /** * CSS classes to add. */ cssClasses?: ChatCSSClasses; }; export type ChatWidget = WidgetFactory; declare const _default: (widgetParams: ChatWidgetParams & ChatConnectorParams) => { $$widgetType: "ais.chat"; $$type: "ais.chat"; init(initOptions: import("../../types").InitOptions): void; render(renderOptions: import("../../types").RenderOptions): void; getRenderState(renderState: { answers?: import("../../types").WidgetRenderState | undefined; autocomplete?: import("../../types").WidgetRenderState | undefined; breadcrumb?: { [rootAttribute: string]: import("../../types").WidgetRenderState; } | undefined; chat?: import("../../types").WidgetRenderState>, ChatConnectorParams>> | undefined; clearRefinements?: import("../../types").WidgetRenderState | undefined; configure?: import("../../types").WidgetRenderState | undefined; currentRefinements?: import("../../types").WidgetRenderState | undefined; geoSearch?: import("../../types").WidgetRenderState, import("../../connectors/geo-search/connectGeoSearch").GeoSearchConnectorParams> | undefined; hierarchicalMenu?: { [rootAttribute: string]: import("../../types").WidgetRenderState; } | undefined; hits?: import("../../types").WidgetRenderState, import("../../connectors/hits/connectHits").HitsConnectorParams> | undefined; hitsPerPage?: import("../../types").WidgetRenderState | undefined; infiniteHits?: import("../../types").WidgetRenderState, import("../../connectors/infinite-hits/connectInfiniteHits").InfiniteHitsConnectorParams> | undefined; menu?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; numericMenu?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; pagination?: import("../../types").WidgetRenderState | undefined; poweredBy?: import("../../types").WidgetRenderState | undefined; queryRules?: import("../../types").WidgetRenderState | undefined; range?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; ratingMenu?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; refinementList?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; relevantSort?: import("../../types").WidgetRenderState | undefined; searchBox?: import("../../types").WidgetRenderState | undefined; sortBy?: import("../../types").WidgetRenderState | undefined; stats?: import("../../types").WidgetRenderState | undefined; toggleRefinement?: { [attribute: string]: import("../../types").WidgetRenderState; } | undefined; voiceSearch?: import("../../types").WidgetRenderState | undefined; analytics?: import("../../types").WidgetRenderState, import("../analytics/analytics").AnalyticsWidgetParams> | undefined; places?: import("../../types").WidgetRenderState, import("../places/places").PlacesWidgetParams> | undefined; }, renderOptions: import("../../types").InitOptions | import("../../types").RenderOptions): import("../../types").IndexRenderState & ChatWidgetDescription["indexRenderState"]; getWidgetRenderState(renderOptions: import("../../types").InitOptions | import("../../types").RenderOptions): { indexUiState: Partial<{ query: string; } & { configure: import("algoliasearch-helper").PlainSearchParameters; } & { geoSearch: { boundingBox: string; }; } & { hierarchicalMenu: { [rootAttribute: string]: string[]; }; } & { hitsPerPage: number; } & { page: number; } & { menu: { [attribute: string]: string; }; } & { numericMenu: { [attribute: string]: string; }; } & { page: number; } & { range: { [attribute: string]: string; }; } & { ratingMenu: { [attribute: string]: number | undefined; }; } & { refinementList: { [attribute: string]: string[]; }; } & { relevantSort: number; } & { query: string; } & { sortBy: string; } & { toggle: { [attribute: string]: boolean; }; } & { query: string; } & { places: { query: string; position: string; }; }>; input: string; open: boolean; sendEvent: import("../../lib/utils").SendEventForHits; setIndexUiState: (indexUiState: Partial<{ query: string; } & { configure: import("algoliasearch-helper").PlainSearchParameters; } & { geoSearch: { boundingBox: string; }; } & { hierarchicalMenu: { [rootAttribute: string]: string[]; }; } & { hitsPerPage: number; } & { page: number; } & { menu: { [attribute: string]: string; }; } & { numericMenu: { [attribute: string]: string; }; } & { page: number; } & { range: { [attribute: string]: string; }; } & { ratingMenu: { [attribute: string]: number | undefined; }; } & { refinementList: { [attribute: string]: string[]; }; } & { relevantSort: number; } & { query: string; } & { sortBy: string; } & { toggle: { [attribute: string]: boolean; }; } & { query: string; } & { places: { query: string; position: string; }; }> | ((previousIndexUiState: Partial<{ query: string; } & { configure: import("algoliasearch-helper").PlainSearchParameters; } & { geoSearch: { boundingBox: string; }; } & { hierarchicalMenu: { [rootAttribute: string]: string[]; }; } & { hitsPerPage: number; } & { page: number; } & { menu: { [attribute: string]: string; }; } & { numericMenu: { [attribute: string]: string; }; } & { page: number; } & { range: { [attribute: string]: string; }; } & { ratingMenu: { [attribute: string]: number | undefined; }; } & { refinementList: { [attribute: string]: string[]; }; } & { relevantSort: number; } & { query: string; } & { sortBy: string; } & { toggle: { [attribute: string]: boolean; }; } & { query: string; } & { places: { query: string; position: string; }; }>) => Partial<{ query: string; } & { configure: import("algoliasearch-helper").PlainSearchParameters; } & { geoSearch: { boundingBox: string; }; } & { hierarchicalMenu: { [rootAttribute: string]: string[]; }; } & { hitsPerPage: number; } & { page: number; } & { menu: { [attribute: string]: string; }; } & { numericMenu: { [attribute: string]: string; }; } & { page: number; } & { range: { [attribute: string]: string; }; } & { ratingMenu: { [attribute: string]: number | undefined; }; } & { refinementList: { [attribute: string]: string[]; }; } & { relevantSort: number; } & { query: string; } & { sortBy: string; } & { toggle: { [attribute: string]: boolean; }; } & { query: string; } & { places: { query: string; position: string; }; }>)) => void; setInput: (input: string) => void; setOpen: (open: boolean) => void; focusInput: () => void; setMessages: (messagesParam: import("../../lib/chat").UIMessage[] | ((m: import("../../lib/chat").UIMessage[]) => import("../../lib/chat").UIMessage[])) => void; suggestions: string[] | undefined; isClearing: boolean; clearMessages: () => void; onClearTransitionEnd: () => void; tools: ClientSideTools; sendChatMessageFeedback: ((messageId: string, vote: 0 | 1) => void) | undefined; feedbackState: Record; widgetParams: Partial> & ChatConnectorParams>; addToolResult: ({ tool, toolCallId, output, }: { tool: TTool; toolCallId: string; output: unknown; }) => Promise; clearError: () => void; error: Error | undefined; id: string; messages: import("../../lib/chat").UIMessage[]; regenerate: ({ messageId, ...options }?: { messageId?: string; } & import("../../lib/ai-lite").ChatRequestOptions) => Promise; resumeStream: (options?: import("../../lib/ai-lite").ChatRequestOptions) => Promise; sendMessage: (message?: (Omit, "id" | "role"> & { id?: string | undefined; role?: "system" | "user" | "assistant" | undefined; } & { text?: never; files?: never; messageId?: string; }) | { text: string; files?: FileList | import("../../lib/ai-lite").FileUIPart[]; metadata?: unknown; parts?: never; messageId?: string; } | { files: FileList | import("../../lib/ai-lite").FileUIPart[]; metadata?: unknown; parts?: never; messageId?: string; } | undefined, options?: import("../../lib/ai-lite").ChatRequestOptions) => Promise; status: import("../../lib/ai-lite").ChatStatus; stop: () => Promise; }; dispose(): void; shouldRender(): true; chatInstance: import("../../lib/chat").Chat>; }; export default _default;