export type GetApiDiV1ModelsModelIdTrainedModelArgs = {model_id: unknown, version?: string | undefined}; export type GetApiDiV1ModelsModelIdTrainedModelOptions = {baseUrl?: string | undefined, basicAuthToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Downloads the trained model. * * GET /di/v1/models/{model_id}/trained_model * * Also accepts auth: watsonAuthToken, watsonAuthTokenQuery */ export const getApiDiV1ModelsModelIdTrainedModel = async (args: GetApiDiV1ModelsModelIdTrainedModelArgs, options?: GetApiDiV1ModelsModelIdTrainedModelOptions) => { const {baseUrl = "https://di.prophecis.com", fetch: fetchFn = fetch, basicAuthToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.version != null) query.append("version", String(args.version)) if (basicAuthToken !== undefined) headers.set("Authorization", basicAuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/di/v1/models/${encodeURIComponent(String(args.model_id))}/trained_model${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 res.blob() };