diff --git a/agenta-backend/agenta_backend/services/evaluator_manager.py b/agenta-backend/agenta_backend/services/evaluator_manager.py index de262987cc..d5b22279c7 100644 --- a/agenta-backend/agenta_backend/services/evaluator_manager.py +++ b/agenta-backend/agenta_backend/services/evaluator_manager.py @@ -80,15 +80,6 @@ async def create_evaluator_config( EvaluatorConfigDB: The newly created evaluator configuration object. """ app = await db_manager.fetch_app_by_id(app_id) - evaluator_config = evaluators.get_evaluator_by_key(evaluator_key) - - if evaluator_config is not None: - if "correct_answer_keys" in evaluator_config.get("settings_template", {}): - if settings_values is None: - settings_values = {} - settings_values["correct_answer_keys"] = evaluator_config[ - "settings_template" - ]["correct_answer_keys"]["default"] evaluator_config = await db_manager.create_evaluator_config( app=app, diff --git a/agenta-web/src/components/pages/evaluations/evaluators/AdvancedSettings.tsx b/agenta-web/src/components/pages/evaluations/evaluators/AdvancedSettings.tsx index 0c8d4cfc6d..b86c54d8b7 100644 --- a/agenta-web/src/components/pages/evaluations/evaluators/AdvancedSettings.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluators/AdvancedSettings.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect} from "react" +import React from "react" import {Form, Input, Collapse} from "antd" import {CaretRightOutlined} from "@ant-design/icons" import {createUseStyles} from "react-jss" @@ -16,41 +16,29 @@ const useStyles = createUseStyles((theme: any) => ({ })) type AdvancedSettingsProps = { - settings: {key: string; label: string; default: string[]; required?: boolean}[] - form: any + settings: Record[] } -const AdvancedSettings: React.FC = ({settings, form}) => { +const AdvancedSettings: React.FC = ({settings}) => { const classes = useStyles() - const [isCollapsed, setIsCollapsed] = useState(true) - const handleCollapseChange = (key: string[]) => { - setIsCollapsed(!key.length) - } - - useEffect(() => { - // Initialize the form with default values for advanced settings - const initialValues = settings.reduce((acc, field) => { - acc[field.key] = field.default - return acc - }, {}) - form.setFieldsValue({advancedSettings: initialValues}) - }, [form, settings]) - - console.log("Passed settings to AdvancedSettings:", settings) + const initialValues = settings.reduce((acc, field) => { + acc[field.key] = field.default + return acc + }, {}) return ( } className={"my-[10px]"} - onChange={handleCollapseChange} > {settings.map((field) => ( {field.label} diff --git a/agenta-web/src/components/pages/evaluations/evaluators/NewEvaluatorModal.tsx b/agenta-web/src/components/pages/evaluations/evaluators/NewEvaluatorModal.tsx index 546fa9e815..8114845751 100644 --- a/agenta-web/src/components/pages/evaluations/evaluators/NewEvaluatorModal.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluators/NewEvaluatorModal.tsx @@ -285,10 +285,25 @@ const NewEvaluatorModal: React.FC = ({ const onSubmit = (values: CreateEvaluationConfigData) => { setSubmitLoading(true) if (!selectedEval?.key) throw new Error("No selected key") + const settingsValues = values.settings_values || {} + + if (settingsValues.correct_answer_keys) { + settingsValues.correct_answer_keys = Array.isArray(settingsValues.correct_answer_keys) + ? settingsValues.correct_answer_keys + : [settingsValues.correct_answer_keys] + } + + if ( + !settingsValues.correct_answer_keys && + selectedEval.settings_template.correct_answer_keys + ) { + settingsValues["correct_answer_keys"] = ["correct_answer"] + } + const data = { ...values, evaluator_key: selectedEval.key, - settings_values: values.settings_values || {}, + settings_values: settingsValues, } ;(editMode ? updateEvaluatorConfig(initialValues?.id!, data) @@ -427,7 +442,7 @@ const NewEvaluatorModal: React.FC = ({ ))} {advancedSettingsFields.length > 0 && ( - + )}