Skip to content

Commit

Permalink
feat(frontend): passed state to open config evaluator modal
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed Dec 4, 2024
1 parent 1514f5c commit 5709e9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -49,9 +49,14 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({

type Props = {
onSuccess?: () => void
setIsConfigEvaluatorModalOpen: (val: string) => void
} & React.ComponentProps<typeof Modal>

const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
const NewEvaluationModal: React.FC<Props> = ({
onSuccess,
setIsConfigEvaluatorModalOpen,
...props
}) => {
const classes = useStyles()
const appId = useAppId()
const [fetching, setFetching] = useState(false)
Expand All @@ -62,15 +67,16 @@ const NewEvaluationModal: React.FC<Props> = ({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<string[]>([])
const [selectedEvalConfigs, setSelectedEvalConfigs] = useState<string[]>([])

useEffect(() => {
const fetchData = async () => {
setFetching(true)
form.resetFields()
setSelectedEvalConfigs([])
setSelectedTestsetId("")
setSelectedVariantIds([])

try {
const [testSets, variants] = await Promise.all([
Expand Down Expand Up @@ -122,7 +128,7 @@ const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
setCorrectAnswerColumn(value)
}

const validateForm = () => {
const validateSubmission = () => {
if (!selectedTestsetId) {
message.error("Please select a test set")
return false
Expand Down Expand Up @@ -150,7 +156,7 @@ const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
}

const onSubmit = () => {
if (!validateForm()) return
if (!validateSubmission()) return

setSubmitLoading(true)
createEvalutaiton(appId, {
Expand Down Expand Up @@ -181,6 +187,7 @@ const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
<Space direction="vertical" size={16} className="w-full">
<SelectTestsetSection
testSets={testSets}
selectedTestsetId={selectedTestsetId}
setSelectedTestsetId={setSelectedTestsetId}
className={classes.collapseContainer}
/>
Expand All @@ -197,6 +204,7 @@ const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
selectedEvalConfigs={selectedEvalConfigs}
setSelectedEvalConfigs={setSelectedEvalConfigs}
className={classes.collapseContainer}
setIsConfigEvaluatorModalOpen={setIsConfigEvaluatorModalOpen}
/>
</Space>
</Spin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ const AutoEvaluation = () => {
setNewEvalModalOpen(false)
fetchEvaluations()
}}
setIsConfigEvaluatorModalOpen={setIsConfigEvaluatorModalOpen}
/>

{isConfigEvaluatorModalOpen === "open" && (
Expand Down

0 comments on commit 5709e9a

Please sign in to comment.