From d53026c6e2e2bdea92212dd79e9b8a34ac8b672a Mon Sep 17 00:00:00 2001 From: deep1401 <gandhi0869@gmail.com> Date: Tue, 25 Feb 2025 13:24:11 -0800 Subject: [PATCH] Fix field names and fix bug in View CSV Modal for single scores --- .../components/Experiment/DynamicPluginForm.tsx | 14 +++++++------- .../components/Experiment/Eval/ViewCSVModal.tsx | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/Experiment/DynamicPluginForm.tsx b/src/renderer/components/Experiment/DynamicPluginForm.tsx index d564f264..5876bd07 100644 --- a/src/renderer/components/Experiment/DynamicPluginForm.tsx +++ b/src/renderer/components/Experiment/DynamicPluginForm.tsx @@ -464,8 +464,8 @@ function CustomAutocompleteWidget<T = any, S extends StrictRJSFSchema = RJSFSche type EvaluationField = { name: string; - regex: string; - outputType: 'boolean' | 'number'; + expression: string; + return_type: 'boolean' | 'number'; }; const CustomEvaluationWidget = (props: WidgetProps<any>) => { @@ -480,7 +480,7 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => { const handleAddField = () => { setEvalMetrics([ ...evalMetrics, - { name: '', regex: '', outputType: 'boolean' } + { name: '', expression: '', return_type: 'boolean' } ]); }; @@ -522,18 +522,18 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => { /> <Textarea placeholder="Regular Expression" - value={evaluation.regex} + value={evaluation.expression} onChange={(e) => - handleFieldChange(index, 'regex', e.target.value) + handleFieldChange(index, 'expression', e.target.value) } disabled={disabled || readonly} style={{ marginBottom: '0.5rem' }} /> <Select placeholder="Output Type" - value={evaluation.outputType} + value={evaluation.return_type} onChange={(e, newValue) => - handleFieldChange(index, 'outputType', newValue as string) + handleFieldChange(index, 'return_type', newValue as string) } disabled={disabled || readonly} style={{ marginBottom: '0.5rem' }} diff --git a/src/renderer/components/Experiment/Eval/ViewCSVModal.tsx b/src/renderer/components/Experiment/Eval/ViewCSVModal.tsx index 40e8b815..e933f1c9 100644 --- a/src/renderer/components/Experiment/Eval/ViewCSVModal.tsx +++ b/src/renderer/components/Experiment/Eval/ViewCSVModal.tsx @@ -75,7 +75,8 @@ function formatEvalData(data) { } function formatArrayOfScores(scores) { - const formattedScores = scores.map((score) => { + const scoresArray = Array.isArray(scores) ? scores : [scores]; + const formattedScores = scoresArray.map((score) => { const metricName = Object.keys(score)[0]; const value = Object.values(score)[0]; -- GitLab