From 72e1db340156bf50b9cfbf56c7c49075d4118291 Mon Sep 17 00:00:00 2001 From: deep1401 <gandhi0869@gmail.com> Date: Tue, 4 Feb 2025 09:24:17 -0800 Subject: [PATCH] Load current config on edit button --- .../Experiment/Eval/EditEvalModal.tsx | 29 +++++++++++++++++++ .../Experiment/Eval/EvalTasksTable.tsx | 3 ++ 2 files changed, 32 insertions(+) diff --git a/src/renderer/components/Experiment/Eval/EditEvalModal.tsx b/src/renderer/components/Experiment/Eval/EditEvalModal.tsx index c6973da7..e0208b91 100644 --- a/src/renderer/components/Experiment/Eval/EditEvalModal.tsx +++ b/src/renderer/components/Experiment/Eval/EditEvalModal.tsx @@ -53,12 +53,14 @@ export default function TrainingModalLoRA({ onClose, experimentInfo, pluginId, + currentEvalName, }: { open: boolean; onClose: () => void; experimentInfo: any; template_id?: string; pluginId: string; + currentEvalName: string; }) { // Store the current selected Dataset in this modal const [selectedDataset, setSelectedDataset] = useState(null); @@ -81,6 +83,28 @@ export default function TrainingModalLoRA({ return chatAPI.Endpoints.Dataset.Info(selectedDataset); }, fetcher); + // Set config to the plugin config if it is available based on currentEvalName within experiment info + useEffect(() => { + if (experimentInfo && currentEvalName && pluginId) { + const evaluationsStr = experimentInfo.config?.evaluations; + if (typeof evaluationsStr === 'string') { + try { + const evaluations = JSON.parse(evaluationsStr); + if (Array.isArray(evaluations)) { + const evalConfig = evaluations.find( + (evalItem: any) => evalItem.name === currentEvalName && evalItem.plugin === pluginId + ); + if (evalConfig) { + setConfig(evalConfig.script_parameters); + } + } + } catch (error) { + console.error('Failed to parse evaluations JSON string:', error); + } + } + } + }, [experimentInfo, currentEvalName, pluginId]); + if (!experimentInfo?.id) { return 'Select an Experiment'; } @@ -89,6 +113,11 @@ export default function TrainingModalLoRA({ ? experimentInfo?.config?.foundation_filename : experimentInfo?.config?.foundation; + // Set config to the plugin config if it is available based on currentEvalName within experiment info + + + + function TrainingModalFirstTab() { return ( <Stack spacing={2}> diff --git a/src/renderer/components/Experiment/Eval/EvalTasksTable.tsx b/src/renderer/components/Experiment/Eval/EvalTasksTable.tsx index c2c2c37a..9a25d587 100644 --- a/src/renderer/components/Experiment/Eval/EvalTasksTable.tsx +++ b/src/renderer/components/Experiment/Eval/EvalTasksTable.tsx @@ -40,6 +40,7 @@ export default function EvalTasksTable({ }) { const [open, setOpen] = useState(false); const [currentPlugin, setCurrentPlugin] = useState(''); + const [currentEvalName, setCurrentEvalName] = useState(''); return ( <> @@ -50,6 +51,7 @@ export default function EvalTasksTable({ }} experimentInfo={experimentInfo} pluginId={currentPlugin} + currentEvalName={currentEvalName} /> <Table aria-label="basic table" stickyHeader> <thead> @@ -92,6 +94,7 @@ export default function EvalTasksTable({ onClick={() => { setOpen(true); setCurrentPlugin(evaluations?.plugin); + setCurrentEvalName(evaluations.name); }} > Edit -- GitLab