SPB Git

spb/airiskindex Public

The most methodologically rigorous, fully transparent AI job-exposure index.

TypeScript 88% Python 6.1% SQL 2.7% CSS 1.2% JavaScript 0.9% Shell 0.8%
1.6 KB · 55 lines typescript
Raw Blame History
1//  File:    schema.ts2//  Path:    apps/worker/src/raters/schema.ts3//  Project: AI Risk Index — airiskindex.io4//  Author:  Simon-Pierre Boucher5//  Contact: contact@spboucher.ai6//  Copyright © 2026 Simon-Pierre Boucher. All rights reserved.7//8//  Description: Rating response schemas (zod parse + structured-output JSON schema).910import { z } from "zod";11import { DIMENSIONS } from "@airiskindex/scoring";1213const RATED_DIMENSIONS = [...DIMENSIONS, "augmentation"] as const;1415const dimensionRating = z.object({16  rating: z.number().int().min(1).max(5),17  rationale: z.string(),18});1920/** Parsed shape of one rater response (all six dimensions of one task). */21export const ratingResponseSchema = z.object(22  Object.fromEntries(RATED_DIMENSIONS.map((dimension) => [dimension, dimensionRating])) as Record<23    (typeof RATED_DIMENSIONS)[number],24    typeof dimensionRating25  >,26);2728export type RatingResponse = z.infer<typeof ratingResponseSchema>;2930/**31 * JSON schema for the structured-outputs feature (score as enum — numeric32 * min/max is unsupported there; docs/research/03-llm-rater-api.md).33 */34export const RATING_OUTPUT_JSON_SCHEMA = {35  type: "object",36  additionalProperties: false,37  required: [...RATED_DIMENSIONS],38  properties: Object.fromEntries(39    RATED_DIMENSIONS.map((dimension) => [40      dimension,41      {42        type: "object",43        additionalProperties: false,44        required: ["rating", "rationale"],45        properties: {46          rating: { enum: [1, 2, 3, 4, 5] },47          rationale: { type: "string" },48        },49      },50    ]),51  ),52} as const;5354export { RATED_DIMENSIONS };55