import {z} from 'zod' export type GetApiApiV1EuaiactAccuracyHistoryArgs = {'X-Org-ID'?: string | undefined, model_id?: string | undefined, metric_type?: ('accuracy' | 'precision' | 'recall' | 'f1_score' | 'auc_roc' | 'auc_pr' | 'mse' | 'mae' | 'custom') | undefined, from?: string | undefined, to?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiApiV1EuaiactAccuracyHistoryOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const accuracyMetric = z.object({id: z.string().optional(), org_id: z.string().optional(), model_id: z.string().optional(), metric_type: z.enum(["accuracy", "precision", "recall", "f1_score", "auc_roc", "auc_pr", "mse", "mae", "custom"]).optional(), value: z.number().optional(), sample_size: z.number().int().optional(), timestamp: z.string().optional(), window_start: z.string().optional(), window_end: z.string().optional(), metadata: z.object({}).optional()}); export const getApiApiV1EuaiactAccuracyHistoryResponse = z.object({metrics: z.array(accuracyMetric).optional(), total: z.number().int().optional(), limit: z.number().int().optional(), offset: z.number().int().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get accuracy history * * GET /api/v1/euaiact/accuracy/history */ export const getApiApiV1EuaiactAccuracyHistory = async (args: GetApiApiV1EuaiactAccuracyHistoryArgs, options?: GetApiApiV1EuaiactAccuracyHistoryOptions) => { const {baseUrl = "https://orchestrator.getaxonflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['X-Org-ID'] != null) headers.set("X-Org-ID", String(args['X-Org-ID'])) if (args.model_id != null) query.append("model_id", String(args.model_id)) if (args.metric_type != null) query.append("metric_type", String(args.metric_type)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/euaiact/accuracy/history${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 validateResponse(getApiApiV1EuaiactAccuracyHistoryResponse, await res.json()) };