From 5709e9ab3d083a329dcebeb991dccf08aa3facf5 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 4 Dec 2024 14:35:07 +0100 Subject: [PATCH] feat(frontend): passed state to open config evaluator modal --- .../NewEvaluation/NewEvaluationModal.tsx | 20 +++++++++++++------ .../autoEvaluation/AutoEvaluation.tsx | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/agenta-web/src/components/pages/evaluations/NewEvaluation/NewEvaluationModal.tsx b/agenta-web/src/components/pages/evaluations/NewEvaluation/NewEvaluationModal.tsx index 34aad5051e..d9b08d2236 100644 --- a/agenta-web/src/components/pages/evaluations/NewEvaluation/NewEvaluationModal.tsx +++ b/agenta-web/src/components/pages/evaluations/NewEvaluation/NewEvaluationModal.tsx @@ -6,7 +6,7 @@ import {fetchSingleProfile, fetchVariants} from "@/services/api" import {createEvalutaiton} from "@/services/evaluations/api" import {fetchTestsets} from "@/services/testsets/api" import {PlusOutlined} from "@ant-design/icons" -import {Form, Modal, Spin, Space, message} from "antd" +import {Modal, Spin, Space, message} from "antd" import {useAtom} from "jotai" import React, {useEffect, useState} from "react" import {createUseStyles} from "react-jss" @@ -49,9 +49,14 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({ type Props = { onSuccess?: () => void + setIsConfigEvaluatorModalOpen: (val: string) => void } & React.ComponentProps -const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { +const NewEvaluationModal: React.FC = ({ + onSuccess, + setIsConfigEvaluatorModalOpen, + ...props +}) => { const classes = useStyles() const appId = useAppId() const [fetching, setFetching] = useState(false) @@ -62,7 +67,6 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { const [evaluators] = useAtom(evaluatorsAtom) const [submitLoading, setSubmitLoading] = useState(false) const [showAdvancedConfig, setshowAdvancedConfig] = useState(false) - const [form] = Form.useForm() const [selectedTestsetId, setSelectedTestsetId] = useState("") const [selectedVariantIds, setSelectedVariantIds] = useState([]) const [selectedEvalConfigs, setSelectedEvalConfigs] = useState([]) @@ -70,7 +74,9 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { useEffect(() => { const fetchData = async () => { setFetching(true) - form.resetFields() + setSelectedEvalConfigs([]) + setSelectedTestsetId("") + setSelectedVariantIds([]) try { const [testSets, variants] = await Promise.all([ @@ -122,7 +128,7 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { setCorrectAnswerColumn(value) } - const validateForm = () => { + const validateSubmission = () => { if (!selectedTestsetId) { message.error("Please select a test set") return false @@ -150,7 +156,7 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { } const onSubmit = () => { - if (!validateForm()) return + if (!validateSubmission()) return setSubmitLoading(true) createEvalutaiton(appId, { @@ -181,6 +187,7 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { @@ -197,6 +204,7 @@ const NewEvaluationModal: React.FC = ({onSuccess, ...props}) => { selectedEvalConfigs={selectedEvalConfigs} setSelectedEvalConfigs={setSelectedEvalConfigs} className={classes.collapseContainer} + setIsConfigEvaluatorModalOpen={setIsConfigEvaluatorModalOpen} /> diff --git a/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx b/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx index 707b27f45f..d1e131eeb3 100644 --- a/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx +++ b/agenta-web/src/components/pages/evaluations/autoEvaluation/AutoEvaluation.tsx @@ -631,6 +631,7 @@ const AutoEvaluation = () => { setNewEvalModalOpen(false) fetchEvaluations() }} + setIsConfigEvaluatorModalOpen={setIsConfigEvaluatorModalOpen} /> {isConfigEvaluatorModalOpen === "open" && (