import {z} from 'zod' export type GetApiScorerFeedbacksScorerScorerIdArgs = {scorer_id: unknown}; export type GetApiScorerFeedbacksScorerScorerIdOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const scorerFeedbackQueueStatus = z.enum(["pending", "generating", "reviewing", "completed"]); export const enrichedScorerFeedbackItem = z.object({id: z.string(), project_id: z.string(), run_id: z.string(), scorer_id: z.string(), source_scorer_version_id: z.string(), record_id: z.string(), original_value: z.string(), annotated_value: z.string(), feedback_text: z.string().nullable(), rationale: z.string().nullable(), queue_id: z.string(), created_by: z.string().nullable(), created_by_name: z.string().nullable().optional(), created_at: z.string(), updated_at: z.string(), project_name: z.string(), run_name: z.string(), input: z.string().nullable().optional(), output: z.string().nullable().optional(), can_submit: z.boolean().optional()}); export const scorerFeedbackListResponse = z.object({queue_id: z.string().nullable().optional(), queue_status: scorerFeedbackQueueStatus.nullable().optional(), generation_task_id: z.string().nullable().optional(), generation_error_message: z.string().nullable().optional(), total_count: z.number().int(), feedback_items: z.array(enrichedScorerFeedbackItem).optional(), restricted_feedback: z.boolean().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 Scorer Feedback * * GET /scorer-feedbacks/scorer/{scorer_id} * * Also accepts auth: ClassicAPIKeyHeader, OAuth2PasswordBearer, HTTPBasic */ export const getApiScorerFeedbacksScorerScorerId = async (args: GetApiScorerFeedbacksScorerScorerIdArgs, options?: GetApiScorerFeedbacksScorerScorerIdOptions) => { const {baseUrl = "https://api.galileo.ai", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (APIKeyHeader !== undefined) headers.set("Splunk-AO-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/scorer-feedbacks/scorer/${encodeURIComponent(String(args.scorer_id))}${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(scorerFeedbackListResponse, await res.json()) };