export type CreateApiTavilySearchArgs = {body: {query: string, search_depth?: string | undefined, chunks_per_source?: number | undefined, max_results?: number | undefined, topic?: string | undefined, time_range?: string | undefined, start_date?: string | undefined, end_date?: string | undefined, include_answer?: boolean | undefined, include_raw_content?: boolean | undefined, include_images?: boolean | undefined, include_image_descriptions?: boolean | undefined, include_favicon?: boolean | undefined, include_domains?: Array | undefined, exclude_domains?: Array | undefined, country?: string | undefined, auto_parameters?: boolean | undefined}}; export type CreateApiTavilySearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Execute a search query using Tavily Search. * * POST /tavily/search */ export const createApiTavilySearch = async (args: CreateApiTavilySearchArgs, options?: CreateApiTavilySearchOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/tavily/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };