mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
Address greptile review feedback (greploop iteration 2)
- Memoize promptsForSource with useMemo for consistency - Extract getTestSourceOptions to pipeline_utils.tsx, removing direct getFrameworks import from pipeline_test_drawer.tsx Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c397bc83fc
commit
23a9a4190b
2 changed files with 11 additions and 7 deletions
|
|
@ -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<PipelineTestPanelProps> = ({
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
const [complianceResults, setComplianceResults] = useState<ComplianceRunEntry[]>([]);
|
||||
|
||||
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 () => {
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue