fix: a few stuff
This commit is contained in:
parent
57414e85f2
commit
b94072a4fd
2 changed files with 10 additions and 5 deletions
|
|
@ -17,13 +17,13 @@ type AskAiScreenProps = Omit<ScreenStateProps<InternalDocSearchHit>, '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 =
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue