From f18ded48607141e371bac0d06e579ac20959499e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 6 Apr 2026 00:18:30 +0200 Subject: [PATCH] feat(ai): add AI provider types and InsightResult Zod schema Co-Authored-By: Claude Opus 4.6 (1M context) --- src/lib/ai/types.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/lib/ai/types.ts diff --git a/src/lib/ai/types.ts b/src/lib/ai/types.ts new file mode 100644 index 000000000..244695e91 --- /dev/null +++ b/src/lib/ai/types.ts @@ -0,0 +1,58 @@ +import { z } from "zod/v4"; + +// ─── Insight Result Schema ───────────────────────────────── + +export const insightFindingSchema = z.object({ + label: z.string(), + value: z.string(), + assessment: z.enum(["positive", "neutral", "attention", "warning"]), + guideline: z.string().optional(), +}); + +export const insightCorrelationSchema = z.object({ + factor: z.string(), + effect: z.string(), + confidence: z.enum(["hoch", "mittel", "gering"]), +}); + +export const insightDataQualitySchema = z.object({ + coverage: z.string(), + gaps: z.array(z.string()), + confidence: z.enum(["hoch", "mittel", "gering"]), +}); + +export const insightResultSchema = z.object({ + summary: z.string(), + classification: z.enum(["optimal", "gut", "grenzwertig", "erhoht", "kritisch"]), + findings: z.array(insightFindingSchema), + correlations: z.array(insightCorrelationSchema), + recommendations: z.array(z.string()), + dataQuality: insightDataQualitySchema, + disclaimer: z.string(), +}); + +export type InsightResult = z.infer; +export type InsightFinding = z.infer; + +// ─── Provider Types ──────────────────────────────────────── + +export type ProviderType = "codex" | "admin-key" | "none"; + +export interface AIProvider { + type: ProviderType; + generateCompletion(params: CompletionParams): Promise; +} + +export interface CompletionParams { + systemPrompt: string; + userPrompt: string; + temperature?: number; + maxTokens?: number; +} + +export interface CompletionResult { + content: string; + tokensUsed: number | null; + model: string; + providerType: ProviderType; +}