fix: make ask ai use config id
This commit is contained in:
parent
f2cba37ea2
commit
e60cb97ecc
3 changed files with 25 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ function App(): JSX.Element {
|
|||
indexName="beta-react"
|
||||
appId="betaHAXPMHIMMC"
|
||||
apiKey="8b00405cba281a7d800ccec393e9af24"
|
||||
askAi={true}
|
||||
askAi="askai-react-demo"
|
||||
insights={true}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,17 +23,32 @@ export type DocSearchTransformClient = {
|
|||
};
|
||||
|
||||
export type DocSearchAskAi = {
|
||||
indexName: string;
|
||||
apiKey: string;
|
||||
appId: string;
|
||||
promptId?: string | null;
|
||||
/**
|
||||
* The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
|
||||
* If not provided, the index name will be used.
|
||||
*/
|
||||
indexName?: string;
|
||||
/**
|
||||
* The API key to use for the ask AI feature. Your assistant will use this API key to search the index.
|
||||
* If not provided, the API key will be used.
|
||||
*/
|
||||
apiKey?: string;
|
||||
/**
|
||||
* The app ID to use for the ask AI feature. Your assistant will use this app ID to search the index.
|
||||
* If not provided, the app ID will be used.
|
||||
*/
|
||||
appId?: string;
|
||||
/**
|
||||
* The assistant ID to use for the ask AI feature.
|
||||
*/
|
||||
assistantId: string | null;
|
||||
};
|
||||
|
||||
export interface DocSearchProps {
|
||||
appId: string;
|
||||
apiKey: string;
|
||||
indexName: string;
|
||||
askAi?: DocSearchAskAi | boolean;
|
||||
askAi?: DocSearchAskAi | string;
|
||||
placeholder?: string;
|
||||
searchParameters?: SearchParamsObject;
|
||||
maxResultsPerGroup?: number;
|
||||
|
|
@ -60,6 +75,7 @@ export function DocSearch(props: DocSearchProps): JSX.Element {
|
|||
|
||||
// check if the instance is configured to handle ask ai
|
||||
const canHandleAskAi = Boolean(props?.askAi);
|
||||
const askAiConfigurationId = typeof props?.askAi === 'string' ? props?.askAi : props?.askAi?.assistantId || null;
|
||||
|
||||
if (canHandleAskAi) {
|
||||
currentPlaceholder = props?.translations?.modal?.searchBox?.placeholderText || 'Search docs or ask AI a question';
|
||||
|
|
@ -117,6 +133,7 @@ export function DocSearch(props: DocSearchProps): JSX.Element {
|
|||
translations={props?.translations?.modal}
|
||||
isAskAiActive={isAskAiActive}
|
||||
canHandleAskAi={canHandleAskAi}
|
||||
askAiConfigurationId={askAiConfigurationId}
|
||||
onAskAiToggle={onAskAiToggle}
|
||||
onClose={onClose}
|
||||
/>,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export type DocSearchModalProps = DocSearchProps & {
|
|||
onClose?: () => void;
|
||||
isAskAiActive?: boolean;
|
||||
canHandleAskAi?: boolean;
|
||||
askAiConfigurationId: string | null;
|
||||
translations?: ModalTranslations;
|
||||
};
|
||||
|
||||
|
|
@ -279,6 +280,7 @@ export function DocSearchModal({
|
|||
onAskAiToggle,
|
||||
isAskAiActive = false,
|
||||
canHandleAskAi = false,
|
||||
askAiConfigurationId,
|
||||
}: DocSearchModalProps): JSX.Element {
|
||||
const { footer: footerTranslations, searchBox: searchBoxTranslations, ...screenStateTranslations } = translations;
|
||||
const [state, setState] = React.useState<DocSearchState<InternalDocSearchHit>>({
|
||||
|
|
|
|||
Loading…
Reference in a new issue