export type GetApiApiV1AiSearchArgs = {query?: string | undefined, searchLimit?: number | undefined, searchOffset?: number | undefined, site?: string | undefined, contentType?: string | undefined, indexName?: string | undefined, threshold?: number | undefined, stream?: boolean | undefined, responseLength?: number | undefined, operator?: string | undefined, language?: string | undefined}; export type GetApiApiV1AiSearchOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /api/v1/ai/search */ export const getApiApiV1AiSearch = async (args: GetApiApiV1AiSearchArgs, options: GetApiApiV1AiSearchOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.query != null) query.append("query", String(args.query)) if (args.searchLimit != null) query.append("searchLimit", String(args.searchLimit)) if (args.searchOffset != null) query.append("searchOffset", String(args.searchOffset)) if (args.site != null) query.append("site", String(args.site)) if (args.contentType != null) query.append("contentType", String(args.contentType)) if (args.indexName != null) query.append("indexName", String(args.indexName)) if (args.threshold != null) query.append("threshold", String(args.threshold)) if (args.stream != null) query.append("stream", String(args.stream)) if (args.responseLength != null) query.append("responseLength", String(args.responseLength)) if (args.operator != null) query.append("operator", String(args.operator)) if (args.language != null) query.append("language", String(args.language)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/ai/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };