All files / shared/src/types/data skill-optimization-evaluation-run.ts

100% Statements 46/46
100% Branches 0/0
100% Functions 0/0
100% Lines 46/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 871x 1x           1x   1x   1x 1x     1x 1x 1x 1x 1x   1x   1x   1x 1x                           1x 1x 1x 1x 1x 1x     1x     1x 1x         1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x         1x 1x 1x 1x 1x 1x 1x 1x 1x        
import { EvaluationMethodName } from '@shared/types/evaluations';
import { z } from 'zod';
 
/**
 * Display information for UI presentation
 * Contains label-value pairs or plain text sections
 */
export const EvaluationDisplayInfo = z.object({
  /** Main label for this display item (e.g., "Verdict", "Reasoning", "Performance") */
  label: z.string(),
  /** Plain text content to display */
  content: z.string(),
});
export type EvaluationDisplayInfo = z.infer<typeof EvaluationDisplayInfo>;
 
export const SkillOptimizationEvaluationResult = z.object({
  evaluation_id: z.uuid(),
  method: z.enum(EvaluationMethodName),
  score: z.number().min(0).max(1),
  extra_data: z.record(z.string(), z.unknown()),
  /** Standardized display information for UI presentation */
  display_info: z.array(EvaluationDisplayInfo),
  /** The name of the model used for judging (null for non-LLM evaluations) */
  judge_model_name: z.string().nullable().optional(),
  /** The provider of the model used for judging (null for non-LLM evaluations) */
  judge_model_provider: z.string().nullable().optional(),
});
export type SkillOptimizationEvaluationResult = z.infer<
  typeof SkillOptimizationEvaluationResult
>;
 
/** An optimized configuration used for AI inference.
 *
 * A group of logs were generated using a clustering algorithm
 * to group similar logs together.
 * Then this **optimal** configuration was generated to produce
 * the best results on one of the clusters.
 * We assume this configuration is also optimal
 * for any future requests that are similar to any of the
 * logs in the cluster. */
export const SkillOptimizationEvaluationRun = z.object({
  id: z.uuid(),
  agent_id: z.uuid(),
  skill_id: z.uuid(),
  cluster_id: z.uuid().nullable(),
  log_id: z.uuid(),
 
  /** The results of when the arm pull was evaluated */
  results: z.array(SkillOptimizationEvaluationResult),
 
  /** When the evaluation run was created */
  created_at: z.iso.datetime({ offset: true }),
});
export type SkillOptimizationEvaluationRun = z.infer<
  typeof SkillOptimizationEvaluationRun
>;
 
export const SkillOptimizationEvaluationRunQueryParams = z
  .object({
    id: z.uuid().optional(),
    agent_id: z.uuid().optional(),
    skill_id: z.uuid().optional(),
    cluster_id: z.uuid().optional(),
    log_id: z.uuid().optional(),
    created_after: z.string().datetime().optional(),
    created_before: z.string().datetime().optional(),
    limit: z.number().min(1).max(100).optional(),
    offset: z.number().min(0).optional(),
  })
  .strict();
export type SkillOptimizationEvaluationRunQueryParams = z.infer<
  typeof SkillOptimizationEvaluationRunQueryParams
>;
 
export const SkillOptimizationEvaluationRunCreateParams = z
  .object({
    agent_id: z.uuid(),
    skill_id: z.uuid(),
    cluster_id: z.uuid(),
    log_id: z.uuid(),
    results: z.array(SkillOptimizationEvaluationResult),
  })
  .strict();
export type SkillOptimizationEvaluationRunCreateParams = z.infer<
  typeof SkillOptimizationEvaluationRunCreateParams
>;