From b94072a4fdc134c0305d8acd03159631a85f8dfd Mon Sep 17 00:00:00 2001 From: Dylan Tientcheu Date: Tue, 29 Apr 2025 11:24:03 +0200 Subject: [PATCH] fix: a few stuff --- packages/docsearch-react/src/AskAiScreen.tsx | 4 ++-- packages/docsearch-react/src/DocSearch.tsx | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/docsearch-react/src/AskAiScreen.tsx b/packages/docsearch-react/src/AskAiScreen.tsx index 2be406a2..592595cf 100644 --- a/packages/docsearch-react/src/AskAiScreen.tsx +++ b/packages/docsearch-react/src/AskAiScreen.tsx @@ -17,13 +17,13 @@ type AskAiScreenProps = Omit, 'translatio export function AskAiScreen({ translations = {}, ...props }: AskAiScreenProps): JSX.Element { const { - titleText = 'How to run a crawl?', disclaimerText = 'Answers are generated using artificial intelligence. This is an experimental technology, and information may occasionally be incorrect or misleading.', relatedSourcesText = 'Related Sources', } = translations; const genAiClient = props.genAiClient; if (!genAiClient) { + // @todo: add a link to the documentation throw new Error('You have to provide credentials to use the Ask AI feature.\nSee documentation:'); } @@ -35,7 +35,7 @@ export function AskAiScreen({ translations = {}, ...props }: AskAiScreenProps): } // determine the initial query to display - const displayedQuery = messages.find((m) => m.role === 'user')?.content || titleText; + const displayedQuery = messages.find((m) => m.role === 'user')?.content || 'No query provided'; // select the content to display based on the status const displayedAnswer = diff --git a/packages/docsearch-react/src/DocSearch.tsx b/packages/docsearch-react/src/DocSearch.tsx index beae74f4..7abd05b1 100644 --- a/packages/docsearch-react/src/DocSearch.tsx +++ b/packages/docsearch-react/src/DocSearch.tsx @@ -51,13 +51,18 @@ export function DocSearch(props: DocSearchProps): JSX.Element { let currentPlaceholder = props?.translations?.modal?.searchBox?.placeholderText || props?.placeholder || 'Search docs'; - if (isAskAiActive) { - currentPlaceholder = props?.translations?.modal?.searchBox?.placeholderTextAskAi || 'Ask another question...'; - } // check if the instance is configured to handle ask ai const canHandleAskAi = Boolean(props?.dataSourceId && props?.promptId); + if (canHandleAskAi) { + currentPlaceholder = props?.translations?.modal?.searchBox?.placeholderText || 'Search docs or ask AI a question'; + } + + if (isAskAiActive) { + currentPlaceholder = props?.translations?.modal?.searchBox?.placeholderTextAskAi || 'Ask another question...'; + } + const onAskAiToggle = React.useCallback( (askAitoggle: boolean) => { setIsAskAiActive(askAitoggle);