diff --git a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx index f54b2a39056..8f7691fbb3e 100644 --- a/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx +++ b/ui/litellm-dashboard/src/components/policies/pipeline_test_drawer.tsx @@ -4,12 +4,12 @@ import { Button } from "@tremor/react"; import { GuardrailPipeline, PipelineStep, PipelineTestResult } from "./types"; import { testPipelineCall } from "../networking"; import type { CompliancePrompt } from "../../data/compliancePrompts"; -import { getFrameworks } from "../../data/compliancePrompts"; import { TEST_SOURCE_QUICK, TEST_SOURCE_ALL, ACTION_LABELS, getPromptsForTestSource, + getTestSourceOptions, complianceMatchExpected, } from "./pipeline_utils"; @@ -62,14 +62,10 @@ export const PipelineTestPanel: React.FC = ({ const [error, setError] = useState(null); const [complianceResults, setComplianceResults] = useState([]); - const testSourceOptions = useMemo(() => [ - { value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" }, - ...getFrameworks().map((f) => ({ value: f.name, label: f.name })), - { value: TEST_SOURCE_ALL, label: "All compliance datasets" }, - ], []); + const testSourceOptions = useMemo(() => getTestSourceOptions(), []); const isQuickChat = testSource === TEST_SOURCE_QUICK; - const promptsForSource = getPromptsForTestSource(testSource); + const promptsForSource = useMemo(() => getPromptsForTestSource(testSource), [testSource]); const isDataset = promptsForSource.length > 0; const handleRunTest = async () => { diff --git a/ui/litellm-dashboard/src/components/policies/pipeline_utils.tsx b/ui/litellm-dashboard/src/components/policies/pipeline_utils.tsx index 44c59579bbc..006decf1878 100644 --- a/ui/litellm-dashboard/src/components/policies/pipeline_utils.tsx +++ b/ui/litellm-dashboard/src/components/policies/pipeline_utils.tsx @@ -37,6 +37,14 @@ export function getPromptsForTestSource(source: string): CompliancePrompt[] { return fw ? fw.categories.flatMap((c) => c.prompts) : []; } +export function getTestSourceOptions(): { value: string; label: string }[] { + return [ + { value: TEST_SOURCE_QUICK, label: "Quick chat (custom message)" }, + ...getFrameworks().map((f) => ({ value: f.name, label: f.name })), + { value: TEST_SOURCE_ALL, label: "All compliance datasets" }, + ]; +} + export function createDefaultStep(): PipelineStep { return { guardrail: "",