export type CreateApiApiChatsIdDownloadFilesArgs = {id: string, body: {method: string, prefix?: string | undefined}}; export type CreateApiApiChatsIdDownloadFilesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * download_files * * POST /api/chats/{id}/download_files */ export const createApiApiChatsIdDownloadFiles = async (args: CreateApiApiChatsIdDownloadFilesArgs, options?: CreateApiApiChatsIdDownloadFilesOptions) => { const {baseUrl = "https://llm-api.treasuredata.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "multipart/mixed") if (ApiKeyAuth !== undefined) headers.set('authorization', `TD1 ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/chats/${encodeURIComponent(String(args.id))}/download_files${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };