From 703e9e91302f8204301f348edbfa88a4151bcb43 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 23 Apr 2026 15:18:24 -0700 Subject: [PATCH] feat(ui): add LLMJudgeFields criteria builder component --- .../guardrails/llm_judge/LLMJudgeFields.tsx | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 ui/litellm-dashboard/src/components/guardrails/llm_judge/LLMJudgeFields.tsx diff --git a/ui/litellm-dashboard/src/components/guardrails/llm_judge/LLMJudgeFields.tsx b/ui/litellm-dashboard/src/components/guardrails/llm_judge/LLMJudgeFields.tsx new file mode 100644 index 00000000000..a5c7590cd9c --- /dev/null +++ b/ui/litellm-dashboard/src/components/guardrails/llm_judge/LLMJudgeFields.tsx @@ -0,0 +1,190 @@ +"use client"; + +import React from "react"; +import { Form, Select, InputNumber, Input, Tooltip } from "antd"; +import { PlusOutlined, QuestionCircleOutlined } from "@ant-design/icons"; +import { Button } from "@tremor/react"; + +interface LLMJudgeFieldsProps { + availableModels: string[]; + form: any; +} + +const LLMJudgeFields: React.FC = ({ availableModels, form }) => { + return ( + <> +
+ After each LLM response, the Judge Model scores it 0–100 against your criteria. + If the weighted average falls below the threshold, the response is blocked (or logged). +
+ + + Judge Model  + + + + + } + rules={[{ required: true, message: "Select a judge model" }]} + > + + Block (return 422) + Log only + + + + + Evaluation Criteria  + + + + + } + > + + {(fields, { add, remove }) => ( + <> + {fields.map(({ key, name, ...restField }) => ( +
+
+ + + + + + Weight + + + } + rules={[{ required: true, message: "Enter weight" }]} + style={{ flex: 1, marginBottom: 8 }} + > + + +
+ +
+
+ + + +
+ ))} + + {fields.length > 0 && ( + + {() => { + const allCriteria: any[] = form.getFieldValue("criteria") || []; + const weightTotal = allCriteria.reduce( + (sum: number, c: any) => sum + (Number(c?.weight) || 0), + 0, + ); + const weightOk = weightTotal === 100; + return ( +
+ Weights total: {weightTotal}%{weightOk ? " ✓" : " — must add up to 100%"} +
+ ); + }} +
+ )} + + )} +
+
+ + ); +}; + +export default LLMJudgeFields;