export type CreateApiV1EvalsCriteriaArgs = {body: {evalId: string, name: string, metric: string, threshold?: (number | null) | undefined, weighting?: number | undefined, parameters?: Record | undefined}}; export type CreateApiV1EvalsCriteriaOptions = {baseUrl?: string | undefined, ProjectPrivateApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a criterion * * POST /v1/evals/criteria */ export const createApiV1EvalsCriteria = async (args: CreateApiV1EvalsCriteriaArgs, options?: CreateApiV1EvalsCriteriaOptions) => { const {baseUrl = "https://api.lunary.ai", fetch: fetchFn = fetch, ProjectPrivateApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ProjectPrivateApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ProjectPrivateApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/evals/criteria${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 };