import { DataSource } from '@sisense/sdk-data'; import { WidgetProps } from '../../domains/widgets/components/widget/types'; import { HookEnableParam } from '../../shared/hooks/types'; import { ChatRestApi } from './api/chat-rest-api.js'; import { GetNlqResultRequest, NlqResult, NlqResultChartType } from './api/types.js'; export interface GetNlqResultParams { /** Data source for queries to run against */ dataSource: DataSource; /** Text containing the natural language query */ query: string; /** Possible chart types to be used in NLQ results */ chartTypes?: NlqResultChartType[]; /** * Enable suggested axis titles in generated widget * * If not specified, the default value is `false` * * @internal */ enableAxisTitlesInWidgetProps?: boolean; } /** * Result type for NLQ request execution * * @internal */ export interface ExecuteGetNlqResult { /** Raw NLQ response from API for additional processing */ nlqResult: NlqResult | undefined; /** Processed widget props ready for rendering */ widgetProps: WidgetProps | undefined; } /** @internal */ export declare function prepareGetNlqResultPayload(params: GetNlqResultParams): { contextTitle: string; request: GetNlqResultRequest; }; /** * Executes a natural language query request and returns processed widget props along with the raw response. * * @param params - NLQ query parameters * @param api - Chat REST API instance * @returns Promise resolving to processed widget props and raw response * @internal */ export declare function executeGetNlqResult(params: GetNlqResultParams, api: ChatRestApi): Promise; /** * Parameters for {@link useGetNlqResult} hook. */ export interface UseGetNlqResultParams extends GetNlqResultParams, HookEnableParam { } /** * State for {@link useGetNlqResult} hook. */ export interface UseGetNlqResultState { /** Whether the data fetching is loading */ isLoading: boolean; /** Whether the data fetching has failed */ isError: boolean; /** Whether the data fetching has succeeded */ isSuccess: boolean; /** The result data */ data: WidgetProps | undefined; /** The error if any occurred */ error: unknown; /** Callback to trigger a refetch of the data */ refetch: () => void; } /** * @param params - {@link UseGetNlqResultParams} * @internal */ export declare const useGetNlqResultInternal: (params: UseGetNlqResultParams) => UseGetNlqResultState; /** * React hook that enables natural language query (NLQ) against a data model or perspective. * * @example * ```tsx * const { data, isLoading } = useGetNlqResult({ * dataSource: 'Sample ECommerce', * query: 'Show me total revenue by age range' * }); * * if (isLoading) { * return
Loading...
; * } * * return ( * { * data && * * } * ); * ``` * @returns NLQ load state that contains the status of the execution, the result (data) as WidgetProps * @group Generative AI * * @beta */ export declare const useGetNlqResult: (params: UseGetNlqResultParams) => UseGetNlqResultState;