The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat(ui): give the Decisions playground a clearer request hierarchy (#45981)
devin-ai-integration[bot]ffec84f918dd
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsxindex ecefd87933b..583486a3d81 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx@@ -8,7 +8,7 @@ interface CurlPreviewProps extends CurlCommandInput {export default function CurlPreview({ errorCount = 0, ...input }: CurlPreviewProps) {const command = buildCurlCommand(input);return (- <div className="flex min-h-0 flex-1 flex-col rounded-md border">+ <div className="flex min-h-0 flex-1 flex-col"><div className="flex items-center justify-between gap-2 border-b px-3 py-2 text-sm"><span className="font-medium">cURL request</span><div className="flex items-center gap-2 text-xs text-muted-foreground">diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/DecisionFormControls.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/DecisionFormControls.tsxindex afa88bf7051..dee45f59c11 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/DecisionFormControls.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/DecisionFormControls.tsx@@ -1,8 +1,7 @@import { Button } from "@/components/ui/button";-import { cn } from "@/lib/cva.config";import { Plus, Trash2 } from "lucide-react";import { useId, type ReactNode } from "react";-import { IssueList, ValidationStatus } from "./ValidationFeedback";+import { IssueList } from "./ValidationFeedback";import type { PayloadValidation } from "./lib/validatePayload";export function RemoveButton({ label, onClick }: { label: string; onClick: () => void }) {@@ -15,28 +14,40 @@ export function RemoveButton({ label, onClick }: { label: string; onClick: () =>export function AddButton({ children, onClick }: { children: ReactNode; onClick: () => void }) {return (- <Button variant="outline" size="sm" className="w-fit" onClick={onClick}>+ <Button+ variant="outline"+ className="w-full border-dashed text-muted-foreground shadow-none hover:text-foreground"+ onClick={onClick}+ ><Plus />{children}</Button>);}+export function QuestionCardHeader({+ index,+ removeLabel,+ onRemove,+}: {+ index: number;+ removeLabel: string;+ onRemove: () => void;+}) {+ return (+ <div className="flex items-center justify-between gap-2">+ <span className="text-xs font-semibold tracking-wide text-muted-foreground uppercase">Question {index + 1}</span>+ <RemoveButton label={removeLabel} onClick={onRemove} />+ </div>+ );+}+export function FormFrame({ validation, children }: { validation: PayloadValidation<unknown>; children: ReactNode }) {const issuesId = useId();return (- <div- className={cn(- "flex min-h-96 flex-1 flex-col overflow-hidden rounded-md border bg-background",- !validation.isValid && "border-destructive/60",- )}- >- <div className="flex items-center gap-2 border-b px-3 py-2">- <span className="text-sm font-medium">Request form</span>- <ValidationStatus validation={validation} />- </div>- <div className="grid min-h-80 flex-1 content-start gap-4 overflow-auto p-3">{children}</div>+ <div className="flex min-h-96 flex-1 flex-col overflow-hidden">+ <div className="grid min-h-80 flex-1 content-start gap-5 overflow-auto p-4">{children}</div><IssueList id={issuesId} validation={validation} /></div>);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/OpenAIDecisionsForm.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/OpenAIDecisionsForm.tsxindex e7a1e14ca02..3fa6a75959f 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/OpenAIDecisionsForm.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/OpenAIDecisionsForm.tsx@@ -6,7 +6,7 @@ import { Label } from "@/components/ui/label";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Textarea } from "@/components/ui/textarea";import { useId, useMemo } from "react";-import { AddButton, FormFrame, RemoveButton } from "./DecisionFormControls";+import { AddButton, FormFrame, QuestionCardHeader, RemoveButton } from "./DecisionFormControls";import { freeName, removeAt, replaceAt } from "./lib/formPayload";import {readDecisionsForm,@@ -124,38 +124,52 @@ interface QuestionCardProps extends QuestionEditorProps {onRemove: () => void;}+const blankDecisionsQuestion = (existing: DecisionsFormQuestion[]): DecisionsFormQuestion => ({+ type: "predicate",+ name: freeName(+ existing.map((q) => q.name ?? ""),+ "question",+ ),+ instructions: "",+});+function QuestionCard({ question, index, onChange, onRemove }: QuestionCardProps) {const instructionsId = useId();return (- <fieldset aria-label={`Question ${index + 1}`} className="grid gap-3 rounded-md border p-3">- <div className="flex flex-wrap items-center gap-2">- <Input- aria-label="Question name"- className="min-w-0 flex-1"- value={question.name ?? ""}- placeholder="Optional question name"- onChange={(event) => onChange({ ...question, name: event.target.value })}- />- <Select- value={question.type}- onValueChange={(type) => {- const next = QUESTION_TYPES.find((value) => value === type);- if (next) onChange(retypeDecisionQuestion(question, next));- }}- >- <SelectTrigger className="w-36" aria-label="Answer type">- <SelectValue>{TYPE_LABELS[question.type]}</SelectValue>- </SelectTrigger>- <SelectContent>- {QUESTION_TYPES.map((type) => (- <SelectItem key={type} value={type}>- {TYPE_LABELS[type]}- </SelectItem>- ))}- </SelectContent>- </Select>- <RemoveButton label={`Remove question ${index + 1}`} onClick={onRemove} />+ <fieldset aria-label={`Question ${index + 1}`} className="grid gap-3 rounded-lg border bg-muted/30 p-3">+ <QuestionCardHeader index={index} onRemove={onRemove} removeLabel={`Remove question ${index + 1}`} />+ <div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]">+ <div className="grid gap-1.5">+ <span className="text-sm font-medium">Name</span>+ <Input+ aria-label="Question name"+ value={question.name ?? ""}+ placeholder="Optional question name"+ onChange={(event) => onChange({ ...question, name: event.target.value })}+ />+ </div>+ <div className="grid gap-1.5">+ <span className="text-sm font-medium">Answer type</span>+ <Select+ value={question.type}+ onValueChange={(type) => {+ const next = QUESTION_TYPES.find((value) => value === type);+ if (next) onChange(retypeDecisionQuestion(question, next));+ }}+ >+ <SelectTrigger className="w-full" aria-label="Answer type">+ <SelectValue>{TYPE_LABELS[question.type]}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {QUESTION_TYPES.map((type) => (+ <SelectItem key={type} value={type}>+ {TYPE_LABELS[type]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div></div><div className="grid gap-1.5"><Label htmlFor={instructionsId}>Instructions</Label>@@ -229,21 +243,7 @@ export default function OpenAIDecisionsForm({ value, onChange, validation, onResonRemove={() => writeQuestions(removeAt(questions, index))}/>))}- <AddButton- onClick={() =>- writeQuestions([- ...questions,- {- type: "predicate",- name: freeName(- questions.map((q) => q.name ?? ""),- "question",- ),- instructions: "",- },- ])- }- >+ <AddButton onClick={() => writeQuestions([...questions, blankDecisionsQuestion(questions)])}>Add question</AddButton><div className="grid gap-1.5">diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.integration.test.tsxindex 141fdc43374..f6c5794fa5c 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.integration.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.integration.test.tsx@@ -106,7 +106,7 @@ describe("ResponseView integration", () => {expect(screen.getByText("99% yes")).toBeInTheDocument();expect(screen.getByRole("meter", { name: "Yes probability" })).toHaveAttribute("aria-valuenow", "99");expect(screen.getByRole("meter", { name: "2: angry probability" })).toBeInTheDocument();- expect(screen.getByText("378 input / 63 output tokens")).toBeInTheDocument();+ expect(screen.getByText("378 in / 63 out")).toBeInTheDocument();});it("selects the score level nearest a fractional calibrated score", () => {diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.tsxindex 538d2f659a6..cc73b44265c 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ResponseView.tsx@@ -1,9 +1,9 @@import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";-import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";-import { ChevronDown, LoaderCircle } from "lucide-react";+import { ChevronRight, Inbox, LoaderCircle } from "lucide-react";import { useState } from "react";import type { SystemOneAnswer, SystemOneResponse } from "./lib/schemas";import type { OpenAIDecisionsResponse } from "./lib/openAIDecisions";@@ -175,17 +175,19 @@ function AnswerCards({ answers }: { answers: SystemOneResponse["answers"] | Opentype: answer.type,details: <AnswerDetails answer={answer} />,}));- return cards.map(({ id, name, type, details }) => (- <Card key={id} size="sm">- <CardHeader>- <CardTitle className="font-mono">{name}</CardTitle>- <CardAction>- <Badge variant="secondary">{type}</Badge>- </CardAction>- </CardHeader>- <CardContent>{details}</CardContent>- </Card>- ));+ return (+ <ul className="grid gap-3">+ {cards.map(({ id, name, type, details }) => (+ <li key={id} className="grid gap-3 rounded-lg bg-muted/50 p-4">+ <div className="flex items-baseline justify-between gap-2">+ <h3 className="font-mono text-[13px] font-medium">{name}</h3>+ <span className="text-xs text-muted-foreground">{type}</span>+ </div>+ {details}+ </li>+ ))}+ </ul>+ );}export default function ResponseView({@@ -220,11 +222,16 @@ export default function ResponseView({if (!response) {return (- <Card>- <CardHeader>- <CardTitle>Calibrated probabilities</CardTitle>- <CardDescription>Send a request to see decision answers and probabilities.</CardDescription>+ <Card className="gap-0 py-0">+ <CardHeader className="flex min-h-12 flex-row items-center border-b px-4 py-2">+ <CardTitle className="text-sm font-medium">Response</CardTitle></CardHeader>+ <CardContent className="flex min-h-[360px] flex-col items-center justify-center gap-3 p-4 text-center">+ <div className="flex size-10 items-center justify-center rounded-lg bg-muted">+ <Inbox className="size-5 text-muted-foreground" />+ </div>+ <p className="text-sm text-muted-foreground">Send a request to see answers here</p>+ </CardContent></Card>);}@@ -232,36 +239,43 @@ export default function ResponseView({const model = response.model ?? fallbackModel;return (- <Card className="wrap-anywhere">- <CardHeader>- <div className="flex flex-wrap items-start justify-between gap-3">- <div className="grid gap-1">- <CardTitle>{view === "curl" ? "Response JSON" : "Calibrated probabilities"}</CardTitle>- {model && <CardDescription>{model}</CardDescription>}- </div>- <div className="flex flex-wrap items-center gap-2 text-xs">- {latencyMs !== undefined && <Badge variant="outline">{Math.round(latencyMs)} ms</Badge>}- {response.usage && (- <Badge variant="outline">- {response.usage.input_tokens} input / {response.usage.output_tokens} output tokens- </Badge>- )}- </div>+ <Card className="gap-0 overflow-hidden py-0 wrap-anywhere">+ <CardHeader className="min-h-12 flex-row flex-wrap items-center justify-between gap-2 border-b px-4 py-2">+ <CardTitle className="text-sm font-medium">{view === "curl" ? "Response JSON" : "Response"}</CardTitle>+ <div className="flex flex-wrap items-center gap-1.5">+ {latencyMs !== undefined && (+ <Badge variant="outline" className="font-mono text-[11px] font-normal tabular-nums">+ {Math.round(latencyMs)} ms+ </Badge>+ )}+ {model && (+ <Badge+ variant="outline"+ className="h-auto max-w-full min-w-0 shrink font-mono text-[11px] font-normal wrap-anywhere whitespace-normal"+ >+ {model}+ </Badge>+ )}+ {response.usage && (+ <Badge variant="outline" className="font-mono text-[11px] font-normal tabular-nums">+ {response.usage.input_tokens} in / {response.usage.output_tokens} out+ </Badge>+ )}</div></CardHeader>- <CardContent className="grid gap-3">+ <CardContent className="grid gap-3 p-4">{view === "curl" ? <RawResponse response={response} /> : <AnswerCards answers={response.answers} />}{view === "form" && (- <Collapsible open={showRaw} onOpenChange={setShowRaw}>+ <Collapsible open={showRaw} onOpenChange={setShowRaw} className="-mx-4 -mb-4 border-t"><CollapsibleTriggerrender={- <Button variant="ghost" size="sm">- <ChevronDown className="size-4" />+ <Button variant="ghost" className="w-full justify-start rounded-none px-4 text-muted-foreground">+ <ChevronRight className={`size-4 transition-transform ${showRaw ? "rotate-90" : ""}`} />Raw response</Button>}/>- <CollapsibleContent>+ <CollapsibleContent className="px-4 pb-4"><RawResponse response={response} /></CollapsibleContent></Collapsible>diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneForm.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneForm.tsxindex a241e68cb9e..1e3ae9e07fe 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneForm.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneForm.tsx@@ -6,7 +6,7 @@ import { Label } from "@/components/ui/label";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Textarea } from "@/components/ui/textarea";import { useId, useMemo, useState } from "react";-import { AddButton, FormFrame, RemoveButton } from "./DecisionFormControls";+import { AddButton, FormFrame, QuestionCardHeader, RemoveButton } from "./DecisionFormControls";import {blankQuestion,freeName,@@ -70,7 +70,7 @@ function KeyInput({ value, taken, onCommit, label, placeholder }: KeyInputProps)const errorId = useId();const [draft, setDraft] = useState(value);const next = draft.trim();- const error = keyError(next, value, taken);+ const error = next === value ? undefined : keyError(next, value, taken);function commit() {if (error === undefined && next !== value) {@@ -203,34 +203,49 @@ function CriteriaEditor({ question, onChange }: QuestionEditorProps<FormQuestioninterface QuestionCardProps extends QuestionEditorProps<FormQuestion> {name: string;+ index: number;taken: readonly string[];onRename: (name: string) => void;onRemove: () => void;}-function QuestionCard({ name, question, taken, onChange, onRename, onRemove }: QuestionCardProps) {+function QuestionCard({ name, index, question, taken, onChange, onRename, onRemove }: QuestionCardProps) {const instructionsId = useId();+ const title = name === "" ? String(index + 1) : name;return (- <fieldset aria-label={`Question ${name}`} className="grid gap-3 rounded-md border p-3">- <div className="flex flex-wrap items-start gap-2">- <KeyInput key={name} label="Question name" value={name} taken={taken} onCommit={onRename} />- <Select- value={question.type}- onValueChange={(type) => isQuestionType(type) && onChange(retype(question, type))}- >- <SelectTrigger className="w-36" aria-label="Answer type">- <SelectValue>{TYPE_LABELS[question.type]}</SelectValue>- </SelectTrigger>- <SelectContent>- {QUESTION_TYPES.map((type) => (- <SelectItem key={type} value={type} title={TYPE_HELP[type]}>- {TYPE_LABELS[type]}- </SelectItem>- ))}- </SelectContent>- </Select>- <RemoveButton label={`Remove question ${name}`} onClick={onRemove} />+ <fieldset aria-label={`Question ${title}`} className="grid gap-3 rounded-lg border bg-muted/30 p-3">+ <QuestionCardHeader index={index} onRemove={onRemove} removeLabel={`Remove question ${title}`} />+ <div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]">+ <div className="grid gap-1.5">+ <span className="text-sm font-medium">Name</span>+ <KeyInput+ key={name}+ label="Question name"+ value={name}+ taken={taken}+ onCommit={onRename}+ placeholder="e.g. area"+ />+ </div>+ <div className="grid gap-1.5">+ <span className="text-sm font-medium">Answer type</span>+ <Select+ value={question.type}+ onValueChange={(type) => isQuestionType(type) && onChange(retype(question, type))}+ >+ <SelectTrigger className="w-full" aria-label="Answer type">+ <SelectValue>{TYPE_LABELS[question.type]}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {QUESTION_TYPES.map((type) => (+ <SelectItem key={type} value={type} title={TYPE_HELP[type]}>+ {TYPE_LABELS[type]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div></div><div className="grid gap-1.5"><Label htmlFor={instructionsId}>Instructions</Label>@@ -286,6 +301,7 @@ export default function SystemOneForm({ value, onChange, validation, onReset }:<QuestionCardkey={index}name={name}+ index={index}question={question}taken={names}onChange={(next) => writeQuestions({ ...questions, [name]: next })}diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.integration.test.tsxindex 8158e5782bb..680fea187c9 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.integration.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.integration.test.tsx@@ -75,9 +75,13 @@ const selectEndpoint = async (endpoint: "/v1/decisions" | "/v1/systemone") => {};const selectPreset = async (label: string) => {- screen.getByRole("combobox", { name: "Example" }).focus();- await userEvent.keyboard("{ArrowDown}");- await userEvent.click(await screen.findByRole("option", { name: label }));+ await userEvent.click(screen.getByRole("button", { name: "Load example" }));+ await userEvent.click(await screen.findByRole("menuitem", { name: label }));+};++const renderPopulated = async (ui: ReactElement) => {+ render(ui);+ await selectPreset("Triage a bug report");};const createResponse = (body: SystemOneResponse | OpenAIDecisionsResponse, status = 200, errorText = "") =>@@ -108,36 +112,38 @@ describe("SystemOneUI integration", () => {document.cookie = "token=; path=/; max-age=0";});- it("switches between example presets and reads Custom once the request is edited", async () => {+ it("starts empty with one blank question and loads examples from the menu", async () => {render(<SystemOneUI accessToken="session-key" />);- const input = screen.getByRole("textbox", { name: "Input" }) as HTMLTextAreaElement;- const example = input.value;- const picker = screen.getByRole("combobox", { name: "Example" });- expect(picker).toHaveTextContent("Triage a bug report");+ expect(screen.getByRole("textbox", { name: "Input" })).toHaveValue("");+ expect(screen.getAllByRole("group", { name: /Question / })).toHaveLength(1);+ expect(screen.getByRole("button", { name: "Clear form" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();- fireEvent.change(input, { target: { value: "Something else" } });- expect(picker).toHaveTextContent("Custom");await selectPreset("Triage a bug report");- expect(screen.getByRole("textbox", { name: "Input" })).toHaveValue(example);- expect(picker).toHaveTextContent("Triage a bug report");+ const input = screen.getByRole("textbox", { name: "Input" }) as HTMLTextAreaElement;+ expect(input).toHaveDisplayValue(/streaming responses/);+ expect(screen.getByRole("button", { name: "Clear form" })).toBeEnabled();await selectPreset("Score a sales lead");- expect(picker).toHaveTextContent("Score a sales lead");expect(await readCurlPayload()).toMatchObject({ questions: { fit: { type: "score" } } });});it("clears the whole request and lets a preset be picked from nothing", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);- const clear = screen.getByRole("button", { name: "Clear" });+ await renderPopulated(<SystemOneUI accessToken="session-key" />);+ const clear = screen.getByRole("button", { name: "Clear form" });expect(screen.getByRole("textbox", { name: "Input" })).toHaveDisplayValue(/streaming responses/);await user.click(clear);expect(screen.getByRole("textbox", { name: "Input" })).toHaveValue("");- expect(screen.queryAllByRole("group", { name: /Question / })).toHaveLength(0);+ expect(screen.getAllByRole("group", { name: /Question / })).toHaveLength(1);+ expect(screen.getByRole("textbox", { name: "Question name" })).toHaveValue("");+ expect(screen.queryByText("Enter a name")).not.toBeInTheDocument();+ expect(screen.getByRole("textbox", { name: "Instructions" })).toHaveValue("");+ expect(screen.queryByRole("textbox", { name: "Option label" })).not.toBeInTheDocument();+ expect(screen.getByText("1 issue to fix")).toBeInTheDocument();expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();expect(clear).toBeDisabled();- expect(screen.getByRole("combobox", { name: "Example" })).toHaveTextContent("Custom");await selectPreset("Route a support ticket");expect(screen.getByRole("textbox", { name: "Input" })).toHaveDisplayValue(/charged twice/);@@ -148,26 +154,28 @@ describe("SystemOneUI integration", () => {it("keeps the preset label after picking a model and keeps that model when clearing", async () => {const user = userEvent.setup();mockModelLookup.mockResolvedValue(modelGroupInfoResponse(DECISION_AND_CHAT_MODELS));- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);const modelPicker = screen.getByRole("combobox", { name: "Decision model" });await waitFor(() => expect(modelPicker).toHaveValue("jev-latest"));- const picker = screen.getByRole("combobox", { name: "Example" });await user.clear(modelPicker);await user.type(modelPicker, "p");await user.click(await screen.findByRole("option", { name: "pplx-decider" }));- expect(picker).toHaveTextContent("Triage a bug report");expect(await readCurlPayload()).toMatchObject({ model: "pplx-decider" });- await user.click(screen.getByRole("button", { name: "Clear" }));- expect(await readCurlPayload()).toEqual({ model: "pplx-decider", state: "", questions: {} });+ await user.click(screen.getByRole("button", { name: "Clear form" }));+ expect(await readCurlPayload()).toEqual({+ model: "pplx-decider",+ state: "",+ questions: { "": { type: "choice", instructions: "", criteria: {} } },+ });await selectPreset("Score a sales lead");expect(await readCurlPayload()).toMatchObject({ model: "pplx-decider", questions: { fit: { type: "score" } } });});it("offers the same presets on /v1/decisions in the OpenAI shape and clears to an empty input", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await selectEndpoint("/v1/decisions");await selectPreset("Moderate a forum comment");const payload = await readCurlPayload();@@ -176,13 +184,17 @@ describe("SystemOneUI integration", () => {{ type: "predicate", name: "breaks_rules", instructions: "Does this comment break the community guidelines?" },]);- await user.click(screen.getByRole("button", { name: "Clear" }));- expect(await readCurlPayload()).toEqual({ input: "", questions: [] });+ await user.click(screen.getByRole("button", { name: "Clear form" }));+ expect(await readCurlPayload()).toEqual({+ input: "",+ questions: [{ type: "predicate", name: "", instructions: "" }],+ });+ expect(screen.getByRole("textbox", { name: "Question name" })).toHaveValue("");expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();});it("offers both literal proxy endpoints without TypeSafe or product prefixes", async () => {- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);expect(screen.getByRole("combobox", { name: "Decision endpoint" })).toHaveTextContent("/v1/systemone");screen.getByRole("combobox", { name: "Decision endpoint" }).focus();@@ -204,7 +216,7 @@ describe("SystemOneUI integration", () => {it("opens on /v1/systemone with the first decision model the key can call", async () => {const user = userEvent.setup();mockModelLookup.mockResolvedValue(modelGroupInfoResponse(DECISION_AND_CHAT_MODELS));- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await waitFor(() => expect(screen.getByRole("combobox", { name: "Decision model" })).toHaveValue("jev-latest"));expect(lookupAuthHeaders(mockModelLookup.mock.calls)).toEqual([expect.arrayContaining(["Bearer session-key"])]);@@ -222,12 +234,13 @@ describe("SystemOneUI integration", () => {it("sends each endpoint's real shape and switches existing responses between cards and JSON without resending", async () => {const user = userEvent.setup();mockModelLookup.mockResolvedValue(modelGroupInfoResponse(DECISION_AND_CHAT_MODELS));- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await waitFor(() => expect(screen.getByRole("combobox", { name: "Decision model" })).toHaveValue("jev-latest"));fireEvent.change(screen.getByRole("textbox", { name: "Input" }), { target: { value: "An outage" } });await selectEndpoint("/v1/decisions");expect(screen.getByRole("textbox", { name: "Input" })).not.toHaveValue("An outage");+ await selectPreset("Triage a bug report");expect(await readCurlPayload()).toMatchObject({input: expect.any(String),questions: expect.arrayContaining([expect.objectContaining({ type: "predicate" })]),@@ -261,7 +274,9 @@ describe("SystemOneUI integration", () => {await selectEndpoint("/v1/systemone");expect(screen.getByRole("textbox", { name: "Input" })).toHaveValue("An outage");- expect(screen.queryByRole("region", { name: "Decisions results" })).not.toBeInTheDocument();+ expect(+ within(screen.getByRole("region", { name: "Decisions results" })).getByText("Send a request to see answers here"),+ ).toBeInTheDocument();await user.click(screen.getByRole("button", { name: "Send" }));expect(await screen.findByText("Selected choice")).toBeInTheDocument();expect(screen.getByRole("meter", { name: "technical probability" })).toHaveAttribute("aria-valuenow", "90");@@ -284,9 +299,9 @@ describe("SystemOneUI integration", () => {});it("validates /v1/decisions independently and preserves an invalid draft across switches", async () => {- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await selectEndpoint("/v1/decisions");- await userEvent.click(screen.getByRole("button", { name: "Clear" }));+ await userEvent.click(screen.getByRole("button", { name: "Clear form" }));expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();await selectEndpoint("/v1/systemone");expect(screen.getByRole("button", { name: "Send" })).toBeEnabled();@@ -305,8 +320,9 @@ describe("SystemOneUI integration", () => {usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2 },}),);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await selectEndpoint("/v1/decisions");+ await selectPreset("Triage a bug report");expect(screen.getByRole("tab", { name: "Form" })).toHaveAttribute("aria-selected", "true");fireEvent.change(screen.getByRole("textbox", { name: "Input" }), { target: { value: "Login is broken" } });const firstQuestion = within(screen.getByRole("group", { name: "Question 1" }));@@ -341,8 +357,9 @@ describe("SystemOneUI integration", () => {it("adds and removes Decisions questions, boolean choices and score levels without stale fields", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await selectEndpoint("/v1/decisions");+ await selectPreset("Triage a bug report");const question = (index: number) => within(screen.getByRole("group", { name: `Question ${index}` }));const pick = async (control: HTMLElement, label: string) => {control.focus();@@ -410,6 +427,7 @@ describe("SystemOneUI integration", () => {<SystemOneUI accessToken="session-key" /></QueryClientProvider>,);+ await selectPreset("Triage a bug report");await userEvent.click(screen.getByRole("button", { name: "Send" }));await screen.findByRole("button", { name: "Cancel request" });await selectEndpoint("/v1/decisions");@@ -426,14 +444,15 @@ describe("SystemOneUI integration", () => {expect(screen.queryByRole("alert")).not.toBeInTheDocument();expect(screen.queryByText("stale-model")).not.toBeInTheDocument();expect(screen.getByRole("tab", { name: "Form" })).toHaveAttribute("aria-selected", "true");- expect(screen.getByRole("button", { name: "Send" })).toBeEnabled();+ expect(screen.queryByRole("button", { name: "Cancel request" })).not.toBeInTheDocument();});it("offers only decision models and writes the picked one into the request", async () => {const user = userEvent.setup();mockModelLookup.mockResolvedValue(modelGroupInfoResponse(DECISION_AND_CHAT_MODELS));- render(<SystemOneUI accessToken="session-key" />);- const picker = await screen.findByRole("combobox", { name: "Decision model" });+ await renderPopulated(<SystemOneUI accessToken="session-key" />);++ const picker = screen.getByRole("combobox", { name: "Decision model" });await user.clear(picker);await user.type(picker, "p");@@ -456,7 +475,7 @@ describe("SystemOneUI integration", () => {mockModelLookup.mockResolvedValue(modelGroupInfoResponse([{ model_group: "typesafe/jev-latest", mode: "evaluation" }]),);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await waitFor(() =>expect(screen.getByRole("combobox", { name: "Decision model" })).toHaveValue("typesafe/jev-latest"),);@@ -470,7 +489,7 @@ describe("SystemOneUI integration", () => {});it("links to Add Model when the key cannot call any decision model", async () => {- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);expect(await screen.findByRole("link", { name: "Add a decision model" })).toHaveAttribute("href",@@ -496,7 +515,7 @@ describe("SystemOneUI integration", () => {it("keeps the admin signed in when a typed virtual key has expired", async () => {document.cookie = "token=ui-session; path=/";mockModelLookup.mockResolvedValue(EXPIRED_KEY_RESPONSE);- render(<SystemOneUI accessToken={null} disabledPersonalKeyCreation />);+ await renderPopulated(<SystemOneUI accessToken={null} disabledPersonalKeyCreation />);fireEvent.change(screen.getByLabelText("Virtual Key", { exact: true }), { target: { value: "sk-expired" } });@@ -511,7 +530,7 @@ describe("SystemOneUI integration", () => {it("keeps an edited request in place when decision models load afterwards", async () => {const models = Promise.withResolvers<Response>();mockModelLookup.mockReturnValue(models.promise);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);fireEvent.change(screen.getByRole("textbox", { name: "Input" }), { target: { value: "edited" } });await act(async () => {@@ -535,9 +554,10 @@ describe("SystemOneUI integration", () => {usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2 },}),);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);if (endpoint === "/v1/decisions") {await selectEndpoint(endpoint);+ await selectPreset("Triage a bug report");}await userEvent.click(screen.getByRole("button", { name: "Send" }));expect(await screen.findByText("jev-latest")).toBeInTheDocument();@@ -554,7 +574,7 @@ describe("SystemOneUI integration", () => {it("shows a read-only cURL command for the proxy with a key placeholder instead of the real key", async () => {const user = userEvent.setup();sessionStorage.setItem("customProxyBaseUrl", "https://proxy.example/");- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await user.click(screen.getByRole("tab", { name: "cURL" }));const command = screen.getByLabelText("cURL request");@@ -568,35 +588,68 @@ describe("SystemOneUI integration", () => {expect(screen.getByRole("button", { name: "Copy cURL" })).toBeInTheDocument();await selectEndpoint("/v1/decisions");+ await selectPreset("Triage a bug report");expect(screen.getByLabelText("cURL request")).toHaveTextContent("https://proxy.example/v1/decisions");expect(screen.getByRole("button", { name: "Send" })).toBeEnabled();});it("keeps Send below the form and shows results only after a request", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);const send = screen.getByRole("button", { name: "Send" });const editor = screen.getByRole("region", { name: "Decisions request editor" });const form = within(editor).getByRole("textbox", { name: "Input" });expect(form.compareDocumentPosition(send) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();- expect(screen.queryByRole("region", { name: "Decisions results" })).not.toBeInTheDocument();+ expect(+ within(screen.getByRole("region", { name: "Decisions results" })).getByText("Send a request to see answers here"),+ ).toBeInTheDocument();expect(screen.queryByRole("note")).not.toBeInTheDocument();await user.click(send);const results = await screen.findByRole("region", { name: "Decisions results" });- expect(within(results).getByText("Calibrated probabilities")).toBeInTheDocument();+ expect(within(results).getByText("Response")).toBeInTheDocument();expect(editor.compareDocumentPosition(results) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();fireEvent.change(within(editor).getByRole("textbox", { name: "Input" }), { target: { value: "Edited state" } });- expect(screen.queryByRole("region", { name: "Decisions results" })).not.toBeInTheDocument();+ expect(+ within(screen.getByRole("region", { name: "Decisions results" })).getByText("Send a request to see answers here"),+ ).toBeInTheDocument();+ });++ it("ties each setup label to its control, numbers question cards and keeps the actions in the editor footer", async () => {+ await renderPopulated(<SystemOneUI accessToken="session-key" />);++ expect(screen.getByText("Endpoint")).toHaveAttribute("for", screen.getByLabelText("Decision endpoint").id);+ expect(screen.getByText("Model")).toHaveAttribute("for", screen.getByLabelText("Decision model").id);+ expect(screen.getByText("API key")).toHaveAttribute("for", screen.getByLabelText("Virtual Key Source").id);++ const question = screen.getByRole("group", { name: "Question area" });+ expect(within(question).getByText("Question 1")).toBeInTheDocument();+ expect(within(question).getByText("Name")).toBeInTheDocument();+ expect(within(question).getByText("Answer type")).toBeInTheDocument();++ const editor = screen.getByRole("region", { name: "Decisions request editor" });+ const card = within(editor).getByRole("group", { name: "Request editor" });+ const actions = within(card).getByRole("toolbar", { name: "Request actions" });+ const status = within(actions).getByRole("status");+ const send = within(actions).getByRole("button", { name: "Send" });+ expect(status).toHaveTextContent("Ready to send");+ expect(status.compareDocumentPosition(send) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(within(actions).queryByRole("button", { name: "Clear form" })).not.toBeInTheDocument();+ const clear = within(card).getByRole("button", { name: "Clear form" });+ expect(clear.compareDocumentPosition(actions) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ expect(+ within(card).getByRole("button", { name: "Load example" }).compareDocumentPosition(clear) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();});it("sends to /v1/systemone even without discovered models and renders calibrated answers", async () => {const user = userEvent.setup();sessionStorage.setItem("customProxyBaseUrl", "https://stale.example.com/");- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);sessionStorage.setItem("customProxyBaseUrl", "https://tenant.example.com/");await user.click(screen.getByRole("button", { name: "Send" }));@@ -622,7 +675,7 @@ describe("SystemOneUI integration", () => {answers: responseBody.answers,}),);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await waitFor(() => expect(screen.getByRole("combobox", { name: "Decision model" })).toHaveValue("jev-latest"));@@ -634,7 +687,7 @@ describe("SystemOneUI integration", () => {it("sends a native request without model so the proxy can select its default", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);fireEvent.change(screen.getByRole("textbox", { name: "Input" }), { target: { value: "An outage" } });expect(screen.getByRole("button", { name: "Send" })).toBeEnabled();await user.click(screen.getByRole("button", { name: "Send" }));@@ -655,6 +708,7 @@ describe("SystemOneUI integration", () => {<SystemOneUI accessToken="session-key" /></QueryClientProvider>,);+ await selectPreset("Triage a bug report");await user.click(screen.getByRole("button", { name: "Send" }));await screen.findByRole("button", { name: "Cancel request" });fireEvent.change(screen.getByRole("textbox", { name: "Input" }), { target: { value: "A new request" } });@@ -685,7 +739,7 @@ describe("SystemOneUI integration", () => {it("uses a custom virtual key when personal key creation is disabled", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken={null} disabledPersonalKeyCreation />);+ await renderPopulated(<SystemOneUI accessToken={null} disabledPersonalKeyCreation />);expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();fireEvent.change(screen.getByLabelText("Virtual Key", { exact: true }), {target: { value: "test-virtual-key" },@@ -698,7 +752,7 @@ describe("SystemOneUI integration", () => {it("renders upstream errors inline", async () => {const user = userEvent.setup();mockFetch.mockResolvedValueOnce(createResponse(responseBody, 401, "Virtual key rejected"));- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await user.click(screen.getByRole("button", { name: "Send" }));@@ -721,7 +775,7 @@ describe("SystemOneUI integration", () => {},}),} as Response);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await user.click(screen.getByRole("button", { name: "Send" }));@@ -731,7 +785,7 @@ describe("SystemOneUI integration", () => {it("clears a previous answer when the request editor changes", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await user.click(screen.getByRole("button", { name: "Send" }));expect(await screen.findByText("Selected choice")).toBeInTheDocument();@@ -752,6 +806,8 @@ describe("SystemOneUI integration", () => {<SystemOneUI accessToken="session-key" /></QueryClientProvider>,);+ await selectPreset("Triage a bug report");+ await selectPreset("Triage a bug report");await user.click(screen.getByRole("button", { name: "Send" }));expect(await screen.findByText("Selected choice")).toBeInTheDocument();@@ -775,7 +831,7 @@ describe("SystemOneUI integration", () => {});}),);- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await user.click(screen.getByRole("button", { name: "Send" }));await user.click(await screen.findByRole("button", { name: "Cancel request" }));@@ -803,7 +859,7 @@ describe("SystemOneUI integration", () => {it("explains the yes / no answer type option", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);question("has_repro_steps").getByRole("combobox", { name: "Answer type" }).focus();await user.keyboard("{ArrowDown}");@@ -816,7 +872,7 @@ describe("SystemOneUI integration", () => {it("sends a choice and a yes/no question built in the form without opening JSON", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);const input = screen.getByRole("textbox", { name: "Input" });fill(input, "The login page is blank after the upgrade");for (const name of ["area", "has_repro_steps", "severity"]) {@@ -826,6 +882,8 @@ describe("SystemOneUI integration", () => {await user.click(screen.getByRole("button", { name: "Add question" }));rename(question("question_1").getByRole("textbox", { name: "Question name" }), "team");fill(question("team").getByRole("textbox", { name: "Instructions" }), "Which team owns this?");+ await user.click(question("team").getByRole("button", { name: "Add option" }));+ await user.click(question("team").getByRole("button", { name: "Add option" }));const [first, second] = question("team").getAllByRole("textbox", { name: "Option label" });rename(first, "frontend");rename(second, "backend");@@ -862,7 +920,7 @@ describe("SystemOneUI integration", () => {it("edits score levels and keeps instructions when a question changes type", async () => {const user = userEvent.setup();mockModelLookup.mockResolvedValue(modelGroupInfoResponse(DECISION_AND_CHAT_MODELS));- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);await waitFor(() => expect(screen.getByRole("combobox", { name: "Decision model" })).toHaveValue("jev-latest"));const level = question("severity").getByRole("textbox", { name: "Level 0" });@@ -889,14 +947,14 @@ describe("SystemOneUI integration", () => {expect(sentBody().questions.has_repro_steps).toEqual({type: "choice",instructions: "Does the issue include steps someone could follow to reproduce it?",- criteria: { option_1: "", option_2: "", option_3: "" },+ criteria: { option_1: "" },});expect(Object.keys(sentBody().questions.area.criteria)).toEqual(["backend", "sdk", "ui"]);});it("refuses an empty or taken question name and trims a new one", async () => {const user = userEvent.setup();- render(<SystemOneUI accessToken="session-key" />);+ await renderPopulated(<SystemOneUI accessToken="session-key" />);const name = question("severity").getByRole("textbox", { name: "Question name" });expect(name).toHaveAttribute("aria-invalid", "false");diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.tsxindex 5ece80abaf3..43d9d4f3024 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/SystemOneUI.tsx@@ -3,6 +3,12 @@import { Button, buttonVariants } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { SimpleTooltip } from "@/components/ui/tooltip";import { SearchSelect } from "@/components/shared/SearchSelect";@@ -11,13 +17,14 @@ import { DECISIONS_DOCS_URL } from "@/lib/decisionModels";import { getGlobalLitellmHeaderName, getProxyBaseUrl } from "@/components/networking";import { uiHref } from "@/utils/uiHref";import { useMutation } from "@tanstack/react-query";-import { BookOpen, Eraser, LoaderCircle, Send } from "lucide-react";-import { useEffect, useMemo, useRef, useState } from "react";+import { BookOpen, ChevronDown, Eraser, FileText, LoaderCircle, Send } from "lucide-react";+import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";import { makePlaygroundDecisionRequest, type PlaygroundDecisionRequest } from "../../llm_calls/system_one";-import { DECISION_PRESETS, emptyPayload, matchPreset, presetPayload, type DecisionPreset } from "./lib/example";+import { DECISION_PRESETS, emptyPayload, presetPayload } from "./lib/example";import { payloadModel, withPayloadModel } from "./lib/payloadModel";import CurlPreview from "./CurlPreview";import ResponseView from "./ResponseView";+import { ValidationSummary } from "./ValidationFeedback";import SystemOneForm from "./SystemOneForm";import OpenAIDecisionsForm from "./OpenAIDecisionsForm";import { validateSystemOnePayload, validateOpenAIDecisionsPayload, errorCount } from "./lib/validatePayload";@@ -36,32 +43,33 @@ interface SystemOneSendVariables {signal: AbortSignal;}-const CUSTOM_PRESET = "custom";--interface PresetPickerProps {- activePreset: DecisionPreset | undefined;- onPick: (id: string | null) => void;+function SetupField({ label, htmlFor, children }: { label: string; htmlFor: string; children: ReactNode }) {+ return (+ <div className="grid min-w-0 content-start gap-1.5">+ <label htmlFor={htmlFor} className="text-xs font-medium text-muted-foreground">+ {label}+ </label>+ {children}+ </div>+ );}-function PresetPicker({ activePreset, onPick }: PresetPickerProps) {+function ExamplesMenu({ onPick }: { onPick: (id: string) => void }) {return (- <Select value={activePreset?.id ?? CUSTOM_PRESET} onValueChange={onPick}>- <SelectTrigger className="w-56" aria-label="Example">- <SelectValue>{activePreset?.label ?? "Custom"}</SelectValue>- </SelectTrigger>- <SelectContent>- {activePreset === undefined && (- <SelectItem value={CUSTOM_PRESET} disabled>- Custom- </SelectItem>- )}+ <DropdownMenu>+ <DropdownMenuTrigger className={cn(buttonVariants({ variant: "outline", size: "sm" }))}>+ <FileText className="text-muted-foreground" />+ Load example+ <ChevronDown className="text-muted-foreground" />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-48">{DECISION_PRESETS.map((preset) => (- <SelectItem key={preset.id} value={preset.id}>+ <DropdownMenuItem key={preset.id} onClick={() => onPick(preset.id)}>{preset.label}- </SelectItem>+ </DropdownMenuItem>))}- </SelectContent>- </Select>+ </DropdownMenuContent>+ </DropdownMenu>);}@@ -81,9 +89,8 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =const [endpoint, setEndpoint] = useState<PlaygroundDecisionRequest["endpoint"]>("/v1/systemone");const [drafts, setDrafts] = useState<Partial<Record<PlaygroundDecisionRequest["endpoint"], string>>>({});const [view, setView] = useState<EditorView>("form");- const rawPayload = drafts[endpoint] ?? presetPayload(DECISION_PRESETS[0], endpoint, decisionModels[0]);+ const rawPayload = drafts[endpoint] ?? emptyPayload(endpoint, decisionModels[0]);const draftModel = drafts[endpoint] === undefined ? decisionModels[0] : payloadModel(rawPayload);- const activePreset = matchPreset(endpoint, rawPayload);const clearedPayload = emptyPayload(endpoint, draftModel);const activeController = useRef<AbortController | null>(null);const validated = useMemo(@@ -100,7 +107,6 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =makePlaygroundDecisionRequest(request, apiKey, getCustomProxyBaseUrl(), { signal }),});const isLoading = systemOne.isPending;- const hasResult = isLoading || systemOne.data !== undefined || systemOne.error !== null;const { reset: resetSystemOne } = systemOne;useEffect(() => () => activeController.current?.abort(), []);@@ -128,7 +134,7 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =}}- function handlePresetPick(id: string | null) {+ function handlePresetPick(id: string) {const preset = DECISION_PRESETS.find((candidate) => candidate.id === id);if (preset !== undefined) {handlePayloadChange(presetPayload(preset, endpoint, draftModel));@@ -160,33 +166,31 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =return (<div className="flex h-full min-h-0 flex-col overflow-auto p-4 xl:overflow-hidden">- <div- className={cn(- "mx-auto grid w-full gap-4 xl:min-h-0 xl:flex-1",- hasResult ? "max-w-7xl xl:grid-cols-2" : "max-w-3xl",- )}- >- <section className="flex min-h-96 flex-col gap-3 xl:min-h-0" aria-label="Decisions request editor">- <div className="flex flex-wrap items-center gap-2">- <Select- value={endpoint}- onValueChange={(value) => {- if (value === "/v1/decisions" || value === "/v1/systemone") {- clearRequestState();- setEndpoint(value);- }- }}- >- <SelectTrigger className="w-44" aria-label="Decision endpoint">- <SelectValue>{endpoint}</SelectValue>- </SelectTrigger>- <SelectContent>- <SelectItem value="/v1/decisions">/v1/decisions</SelectItem>- <SelectItem value="/v1/systemone">/v1/systemone</SelectItem>- </SelectContent>- </Select>- <div className="w-56">+ <div className="mx-auto grid w-full max-w-[1400px] gap-4 xl:min-h-0 xl:flex-1 xl:grid-cols-[minmax(0,11fr)_minmax(0,9fr)]">+ <section className="flex min-h-96 flex-col gap-4 xl:min-h-0" aria-label="Decisions request editor">+ <div className="grid gap-3 rounded-lg border bg-card p-3 sm:grid-cols-3">+ <SetupField label="Endpoint" htmlFor="decision-endpoint">+ <Select+ value={endpoint}+ onValueChange={(value) => {+ if (value === "/v1/decisions" || value === "/v1/systemone") {+ clearRequestState();+ setEndpoint(value);+ }+ }}+ >+ <SelectTrigger id="decision-endpoint" className="w-full" aria-label="Decision endpoint">+ <SelectValue>{endpoint}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="/v1/decisions">/v1/decisions</SelectItem>+ <SelectItem value="/v1/systemone">/v1/systemone</SelectItem>+ </SelectContent>+ </Select>+ </SetupField>+ <SetupField label="Model" htmlFor="decision-model"><SearchSelect+ id="decision-model"aria-label="Decision model"options={decisionModels.map((model) => ({ label: model, value: model }))}value={payloadModel(rawPayload) ?? null}@@ -195,55 +199,73 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =emptyText="No decision models found"allowClear={false}/>- </div>- {decisionModelsLoaded && decisionModels.length === 0 && (- <a href={uiHref("models-and-endpoints")} className="text-sm text-primary underline">- Add a decision model- </a>- )}- <Select- value={apiKeySource}- onValueChange={(value) => {- if (value === "session" || value === "custom") {- setApiKeySource(value);- }- }}- disabled={disabledPersonalKeyCreation}- >- <SelectTrigger className="w-44" aria-label="Virtual Key Source">- <SelectValue>{apiKeySource === "custom" ? "Virtual Key" : "Current UI Session"}</SelectValue>- </SelectTrigger>- <SelectContent>- <SelectItem value="session" disabled={!accessToken}>- Current UI Session- </SelectItem>- <SelectItem value="custom">Virtual Key</SelectItem>- </SelectContent>- </Select>- {apiKeySource === "custom" && (- <Input- type="password"- aria-label="Virtual Key"- value={customApiKey}- onChange={(event) => setCustomApiKey(event.target.value)}- placeholder="Enter Virtual Key"- className="w-56"- />- )}+ {decisionModelsLoaded && decisionModels.length === 0 && (+ <a href={uiHref("models-and-endpoints")} className="text-xs text-primary underline">+ Add a decision model+ </a>+ )}+ </SetupField>+ <SetupField label="API key" htmlFor="decision-key-source">+ <Select+ value={apiKeySource}+ onValueChange={(value) => {+ if (value === "session" || value === "custom") {+ setApiKeySource(value);+ }+ }}+ disabled={disabledPersonalKeyCreation}+ >+ <SelectTrigger id="decision-key-source" className="w-full" aria-label="Virtual Key Source">+ <SelectValue>{apiKeySource === "custom" ? "Virtual Key" : "Current UI Session"}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="session" disabled={!accessToken}>+ Current UI Session+ </SelectItem>+ <SelectItem value="custom">Virtual Key</SelectItem>+ </SelectContent>+ </Select>+ {apiKeySource === "custom" && (+ <Input+ type="password"+ aria-label="Virtual Key"+ value={customApiKey}+ onChange={(event) => setCustomApiKey(event.target.value)}+ placeholder="Enter Virtual Key"+ />+ )}+ </SetupField></div><Tabs+ role="group"+ aria-label="Request editor"value={view}onValueChange={(value) => (value === "form" || value === "curl") && setView(value)}- className="min-h-0 flex-1"+ className={cn(+ "flex min-h-0 flex-1 flex-col gap-0 overflow-hidden rounded-lg border bg-card",+ !validation.isValid && "border-destructive/60",+ )}>- <div className="flex flex-wrap items-center justify-between gap-2">+ <div className="flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2"><TabsList aria-label="Request editor view"><TabsTrigger value="form">Form</TabsTrigger><TabsTrigger value="curl">cURL</TabsTrigger></TabsList>- <div className="flex items-center gap-1">- <PresetPicker activePreset={activePreset} onPick={handlePresetPick} />+ <div className="flex items-center gap-2">+ <ExamplesMenu onPick={handlePresetPick} />+ <SimpleTooltip content="Clear form">+ <Button+ variant="ghost"+ size="icon"+ aria-label="Clear form"+ className="hover:text-destructive"+ onClick={() => handlePayloadChange(clearedPayload)}+ disabled={rawPayload === clearedPayload || isLoading}+ >+ <Eraser />+ </Button>+ </SimpleTooltip><SimpleTooltip content="How to call /v1/decisions and /v1/systemone"><ahref={DECISIONS_DOCS_URL}@@ -257,7 +279,7 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =</SimpleTooltip></div></div>- <TabsContent value="form" className="flex min-h-0 flex-col">+ <TabsContent value="form" className="flex min-h-0 flex-1 flex-col">{validated.endpoint === "/v1/decisions" ? (<OpenAIDecisionsFormvalue={rawPayload}@@ -274,7 +296,7 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =/>)}</TabsContent>- <TabsContent value="curl" className="flex min-h-0 flex-col">+ <TabsContent value="curl" className="flex min-h-0 flex-1 flex-col"><CurlPreviewbaseUrl={getCustomProxyBaseUrl() ?? getProxyBaseUrl()}endpoint={endpoint}@@ -283,48 +305,37 @@ export default function SystemOneUI({ accessToken, disabledPersonalKeyCreation =errorCount={errorCount(validation)}/></TabsContent>- </Tabs>-- <div className="flex flex-wrap items-center gap-2">- <Button- variant="ghost"- onClick={() => handlePayloadChange(clearedPayload)}- disabled={rawPayload === clearedPayload}+ <div+ role="toolbar"+ aria-label="Request actions"+ className="flex flex-wrap items-center justify-between gap-3 border-t bg-muted/50 px-4 py-3">- <Eraser />- Clear- </Button>- <div className="ml-auto flex items-center gap-2">- {isLoading && (- <Button variant="outline" onClick={clearRequestState}>- Cancel request+ <ValidationSummary validation={validation} />+ <div className="flex items-center gap-2">+ {isLoading && (+ <Button variant="outline" onClick={clearRequestState}>+ Cancel request+ </Button>+ )}+ <Button size="sm" onClick={handleSend} disabled={!validation.isValid || isLoading || !effectiveApiKey}>+ {isLoading ? <LoaderCircle className="animate-spin" /> : <Send />}+ Send</Button>- )}- <Button- size="lg"- className="min-w-32"- onClick={handleSend}- disabled={!validation.isValid || isLoading || !effectiveApiKey}- >- {isLoading ? <LoaderCircle className="animate-spin" /> : <Send />}- Send- </Button>+ </div></div>- </div>+ </Tabs></section>- {hasResult && (- <section className="grid content-start gap-4 xl:min-h-0 xl:overflow-auto" aria-label="Decisions results">- <ResponseView- response={systemOne.data?.response}- view={view}- fallbackModel={validation.payload?.model}- latencyMs={systemOne.data?.latencyMs}- error={systemOne.error?.message}- isLoading={isLoading}- />- </section>- )}+ <section className="grid content-start gap-4 xl:min-h-0 xl:overflow-auto" aria-label="Decisions results">+ <ResponseView+ response={systemOne.data?.response}+ view={view}+ fallbackModel={validation.payload?.model}+ latencyMs={systemOne.data?.latencyMs}+ error={systemOne.error?.message}+ isLoading={isLoading}+ />+ </section></div></div>);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.test.tsxindex 24f93c58af9..a2f6c24781a 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.test.tsx@@ -1,6 +1,6 @@import { render, screen } from "@testing-library/react";import { describe, expect, it } from "vitest";-import { IssueList, ValidationStatus } from "./ValidationFeedback";+import { IssueList, ValidationStatus, ValidationSummary } from "./ValidationFeedback";import type { PayloadValidation } from "./lib/validatePayload";const validation = (issues: PayloadValidation<unknown>["issues"]): PayloadValidation<unknown> => ({@@ -29,12 +29,28 @@ describe("ValidationStatus", () => {});describe("IssueList", () => {- it("lists every issue with its path and says ready when there are none", () => {+ it("lists every issue under its field label and renders nothing when there are none", () => {const { rerender } = render(<IssueList id="issues" validation={validation([{ path: "state", message: "Required", severity: "error" }])} />,);- expect(screen.getByRole("list", { name: "Payload validation issues" })).toHaveTextContent("stateRequired");+ expect(screen.getByRole("list", { name: "Payload validation issues" })).toHaveTextContent("InputRequired");rerender(<IssueList id="issues" validation={validation([])} />);+ expect(screen.queryByRole("list", { name: "Payload validation issues" })).not.toBeInTheDocument();+ });+});++describe("ValidationSummary", () => {+ it("says ready when nothing blocks the request and counts the errors otherwise", () => {+ const { rerender } = render(<ValidationSummary validation={validation([])} />);expect(screen.getByRole("status")).toHaveTextContent("Ready to send");+ rerender(+ <ValidationSummary+ validation={validation([+ { path: "state", message: "Required", severity: "error" },+ { path: "q", message: "Long", severity: "warning" },+ ])}+ />,+ );+ expect(screen.getByRole("status")).toHaveTextContent("1 issue to fix");});});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.tsxindex 369c4243857..e8152456d15 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/ValidationFeedback.tsx@@ -1,5 +1,6 @@import { Badge } from "@/components/ui/badge";import { CircleAlert, CircleCheck, TriangleAlert } from "lucide-react";+import { issueLabel } from "./lib/issueLabel";import { errorCount as countErrors, type PayloadValidation } from "./lib/validatePayload";export function ValidationStatus({ validation }: { validation: PayloadValidation<unknown> }) {@@ -14,14 +15,25 @@ export function ValidationStatus({ validation }: { validation: PayloadValidationreturn <Badge variant="secondary">Valid payload</Badge>;}+export function ValidationSummary({ validation }: { validation: PayloadValidation<unknown> }) {+ const errorCount = countErrors(validation);+ return (+ <p role="status" aria-live="polite" className="flex min-w-0 items-center gap-2 text-sm">+ {errorCount === 0 ? (+ <CircleCheck className="size-4 shrink-0 text-emerald-600 dark:text-emerald-400" />+ ) : (+ <CircleAlert className="size-4 shrink-0 text-destructive" />+ )}+ <span className={errorCount === 0 ? "text-muted-foreground" : "text-destructive"}>+ {errorCount === 0 ? "Ready to send" : `${errorCount} ${errorCount === 1 ? "issue" : "issues"} to fix`}+ </span>+ </p>+ );+}+export function IssueList({ id, validation }: { id: string; validation: PayloadValidation<unknown> }) {if (validation.issues.length === 0) {- return (- <p id={id} role="status" className="flex items-center gap-1.5 border-t px-3 py-2 text-xs text-muted-foreground">- <CircleCheck className="size-3.5 text-emerald-600 dark:text-emerald-400" />- Ready to send- </p>- );+ return null;}return (<ul id={id} aria-label="Payload validation issues" className="grid max-h-36 gap-1 overflow-auto border-t px-3 py-2">@@ -32,7 +44,7 @@ export function IssueList({ id, validation }: { id: string; validation: PayloadV) : (<TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400" />)}- <code className="shrink-0 rounded bg-muted px-1 font-mono">{issue.path}</code>+ <span className="shrink-0 font-medium">{issueLabel(issue.path)}</span><span>{issue.message}</span></li>))}diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.test.tsindex e6b10fda545..e24cf8895b3 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.test.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.test.ts@@ -54,7 +54,10 @@ describe("decision presets", () => {it("omits the model from payloads when none is known", () => {expect(JSON.parse(presetPayload(DECISION_PRESETS[1], "/v1/systemone"))).not.toHaveProperty("model");- expect(JSON.parse(emptyPayload("/v1/decisions"))).toEqual({ input: "", questions: [] });+ expect(JSON.parse(emptyPayload("/v1/decisions"))).toEqual({+ input: "",+ questions: [{ type: "predicate", name: "", instructions: "" }],+ });expect(validateSystemOnePayload(emptyPayload("/v1/systemone"), "/v1/systemone").isValid).toBe(false);});});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.tsindex c8cbeaf2e5c..226d47f4a3b 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/example.ts@@ -1,6 +1,7 @@import type { DecisionRequest, SystemOneRequest } from "./schemas";import type { OpenAIDecisionsRequest } from "./openAIDecisions";import { parseJson } from "./validatePayload";+import { blankQuestion } from "./formPayload";type PresetChoice = {type: "choice";@@ -192,7 +193,9 @@ export const matchPreset = (endpoint: PresetEndpoint, raw: string): DecisionPresexport const emptyPayload = (endpoint: PresetEndpoint, model?: string): string =>JSON.stringify(- endpoint === "/v1/decisions" ? { model, input: "", questions: [] } : { model, state: "", questions: {} },+ endpoint === "/v1/decisions"+ ? { model, input: "", questions: [{ type: "predicate", name: "", instructions: "" }] }+ : { model, state: "", questions: { "": blankQuestion() } },null,2,);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.test.tsindex 8339abeadab..ef52876ef52 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.test.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.test.ts@@ -82,7 +82,7 @@ describe("retype", () => {type: "choice",instructions: "Is it urgent?",note: "kept",- criteria: { option_1: "", option_2: "" },+ criteria: {},};const asScore = { type: "score", instructions: "Is it urgent?", note: "kept", criteria: ["", ""] };expect(retype(noul, "choice")).toEqual(asChoice);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.tsindex 754476b8ff1..1906ad80cd9 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/formPayload.ts@@ -64,7 +64,7 @@ export const removeAt = <T>(items: readonly T[], index: number): T[] =>export const blankQuestion = (): ChoiceQuestion => ({type: "choice",instructions: "",- criteria: { option_1: "", option_2: "" },+ criteria: {},});export const retype = (question: FormQuestion, type: QuestionType): FormQuestion => {diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.test.tsnew file mode 100644index 00000000000..29ae0f60ae4--- /dev/null+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.test.ts@@ -0,0 +1,31 @@+import { describe, expect, it } from "vitest";+import { issueLabel } from "./issueLabel";++describe("issueLabel", () => {+ it("names the Input field for both endpoints instead of the JSON key", () => {+ expect(issueLabel("state")).toBe("Input");+ expect(issueLabel("input")).toBe("Input");+ });++ it("names top-level fields and the request itself", () => {+ expect(issueLabel("model")).toBe("Model");+ expect(issueLabel("questions")).toBe("Questions");+ expect(issueLabel("safety_identifier")).toBe("Safety identifier");+ expect(issueLabel("root")).toBe("Request");+ expect(issueLabel("syntax")).toBe("Request");+ });++ it("names a question by its key or its 1-based position and the field inside it", () => {+ expect(issueLabel("questions.urgency")).toBe('Question "urgency"');+ expect(issueLabel("questions.urgency.criteria")).toBe('Question "urgency" options');+ expect(issueLabel("questions.urgency.criteria.1")).toBe('Question "urgency" options');+ expect(issueLabel("questions.category.instructions")).toBe('Question "category" instructions');+ expect(issueLabel("questions.0.name")).toBe("Question 1 name");+ expect(issueLabel("questions.2.type")).toBe("Question 3 answer type");+ });++ it("falls back to the humanized key for anything unknown", () => {+ expect(issueLabel("max_tokens")).toBe("max tokens");+ expect(issueLabel("questions.a.max_items")).toBe('Question "a" max items');+ });+});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.tsnew file mode 100644index 00000000000..76acc266117--- /dev/null+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/issueLabel.ts@@ -0,0 +1,30 @@+const TOP_LEVEL: Record<string, string> = {+ state: "Input",+ input: "Input",+ model: "Model",+ questions: "Questions",+ safety_identifier: "Safety identifier",+ root: "Request",+ syntax: "Request",+};++const QUESTION_FIELD: Record<string, string> = {+ name: "name",+ type: "answer type",+ instructions: "instructions",+ criteria: "options",+};++const humanize = (segment: string): string => segment.replace(/_/g, " ");++export function issueLabel(path: string): string {+ const [head, question, field] = path.split(".");+ if (head !== "questions" || question === undefined) {+ return TOP_LEVEL[head] ?? humanize(head);+ }+ const title = /^\d+$/.test(question) ? `Question ${Number(question) + 1}` : `Question "${question}"`;+ if (field === undefined) {+ return title;+ }+ return `${title} ${QUESTION_FIELD[field] ?? humanize(field)}`;+}diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.test.tsindex 603c22c0830..6e91f09f8bd 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.test.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { SYSTEM_ONE_EXAMPLE } from "./example";-import { validateSystemOnePayload } from "./validatePayload";+import { validateOpenAIDecisionsPayload, validateSystemOnePayload } from "./validatePayload";const requestWith = (fields: Record<string, unknown> = {}) =>JSON.stringify({@@ -331,3 +331,45 @@ describe("validateSystemOnePayload", () => {expect(validateSystemOnePayload(JSON.stringify(SYSTEM_ONE_EXAMPLE))).toMatchObject({ isValid: true, issues: [] });});});++describe("blank context", () => {+ const question = { type: "choice", instructions: "Pick one", criteria: { a: "", b: "" } };++ it.each(["", " "])("rejects /v1/systemone with state %j even when the schema passes", (state) => {+ const result = validateSystemOnePayload(JSON.stringify({ state, questions: { q: question } }), "/v1/systemone");+ expect(result).toMatchObject({ isValid: false, payload: expect.anything() });+ expect(result.issues.map((issue) => issue.path)).toEqual(["state"]);+ });++ it("reports only the missing state while the blank question is still invalid", () => {+ const raw = JSON.stringify({ state: "", questions: { "": { type: "choice", instructions: "", criteria: {} } } });+ expect(validateSystemOnePayload(raw, "/v1/systemone").issues.map((issue) => issue.path)).toEqual(["state"]);+ const filled = validateSystemOnePayload(raw.replace('"state":""', '"state":"A ticket"'), "/v1/systemone");+ expect(filled.isValid).toBe(false);+ expect(filled.issues).toContainEqual({+ path: "questions",+ message: "Give every question a name.",+ severity: "error",+ });+ });++ it("accepts /v1/systemone once the state carries text", () => {+ const raw = JSON.stringify({ state: "A customer wrote in", questions: { q: question } });+ expect(validateSystemOnePayload(raw, "/v1/systemone")).toMatchObject({ isValid: true, issues: [] });+ });++ it.each(["", " ", []])("rejects /v1/decisions with %j input even when the schema passes", (input) => {+ const raw = JSON.stringify({ input, questions: [{ type: "predicate", name: "q", instructions: "Is it?" }] });+ const result = validateOpenAIDecisionsPayload(raw);+ expect(result.isValid).toBe(false);+ expect(result.issues.map((issue) => issue.path)).toEqual(["input"]);+ });++ it("accepts /v1/decisions once the input carries text", () => {+ const raw = JSON.stringify({+ input: "Ship it?",+ questions: [{ type: "predicate", name: "q", instructions: "Is it?" }],+ });+ expect(validateOpenAIDecisionsPayload(raw)).toMatchObject({ isValid: true, issues: [] });+ });+});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.tsindex d74923bb3e6..1fb32efd158 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/validatePayload.ts@@ -26,6 +26,11 @@ export type SystemOnePayloadValidation = PayloadValidation<PlaygroundRequest>;export const errorCount = (validation: PayloadValidation<unknown>): number =>validation.issues.filter((issue) => issue.severity === "error").length;+const toIssue = (path: PropertyKey[], message: string): SystemOnePayloadIssue =>+ path[0] === "questions" && path[1] === ""+ ? { path: "questions", message: "Give every question a name.", severity: "error" }+ : { path: path.length > 0 ? path.join(".") : "root", message, severity: "error" };+const invalid = (path: string, message: string) => ({isValid: false,issues: [{ path, message, severity: "error" as const }],@@ -62,26 +67,47 @@ function validatePayload<T>(raw: string, schema: z.ZodType<T>): PayloadValidatioif (!result.success) {return {isValid: false,- issues: result.error.issues.map((issue) => ({- path: issue.path.length > 0 ? issue.path.join(".") : "root",- message: issue.message,- severity: "error",- })),+ issues: result.error.issues.map((issue) => toIssue(issue.path, issue.message)),};}return { isValid: true, payload: result.data, issues: [] };}+const isBlankContext = (context: unknown): boolean =>+ (typeof context === "string" && context.trim() === "") || (Array.isArray(context) && context.length === 0);++const isMissingContext = (raw: string, path: "state" | "input"): boolean => {+ const json = parseJson(raw);+ if (!json.ok || typeof json.value !== "object" || json.value === null) {+ return false;+ }+ return isBlankContext((json.value as Record<string, unknown>)[path]);+};++const requireContext = <T>(raw: string, path: "state" | "input", result: PayloadValidation<T>): PayloadValidation<T> =>+ isMissingContext(raw, path)+ ? {+ ...result,+ isValid: false,+ issues: [{ path, message: "Add the text the model should decide about.", severity: "error" }],+ }+ : result;+export function validateSystemOnePayload(raw: string,endpoint: DecisionEndpoint = "/typesafe/v1/systemone",): SystemOnePayloadValidation {const schema = endpoint === "/v1/systemone" ? decisionsRequestSchema : systemOneRequestSchema;const result = validatePayload<PlaygroundRequest>(raw, schema);- return result.payload ? { ...result, issues: scoreLevelWarnings(result.payload) } : result;+ return requireContext(+ raw,+ "state",+ result.payload ? { ...result, issues: scoreLevelWarnings(result.payload) } : result,+ );}export function validateOpenAIDecisionsPayload(raw: string): PayloadValidation<OpenAIDecisionsRequest> {- return validatePayload(raw, openAIDecisionsRequestSchema);+ const result = validatePayload<OpenAIDecisionsRequest>(raw, openAIDecisionsRequestSchema);+ return requireContext(raw, "input", result);}diff --git a/ui/litellm-dashboard/src/components/shared/SearchSelect.tsx b/ui/litellm-dashboard/src/components/shared/SearchSelect.tsxindex 21d38e9458c..3649114826d 100644--- a/ui/litellm-dashboard/src/components/shared/SearchSelect.tsx+++ b/ui/litellm-dashboard/src/components/shared/SearchSelect.tsx@@ -30,6 +30,7 @@ interface SearchSelectProps {inputId?: string;allowClear?: boolean;"aria-label"?: string;+ id?: string;}const matchesQuery = (option: SearchSelectOption, query: string): boolean => {@@ -49,6 +50,7 @@ export function SearchSelect({inputId,allowClear = true,"aria-label": ariaLabel,+ id,}: SearchSelectProps) {const selected =value == null || value === "" ? null : options.find((option) => option.value === value) ?? { label: value, value };@@ -66,7 +68,7 @@ export function SearchSelect({disabled={disabled}><ComboboxInput- id={inputId}+ id={id ?? inputId}aria-label={ariaLabel}placeholder={placeholder}showClear={allowClear && value != null && value !== ""}