Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub issue: Modified correct_answer_keys in payload to return array #1659

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions agenta-backend/agenta_backend/services/evaluator_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ const DynamicFormField: React.FC<DynamicFormFieldProps> = ({
const {appTheme} = useAppTheme()
const classes = useStyles()
const {token} = theme.useToken()
const [showAdvancedSettings, setShowAdvancedSettings] = useState(false)

const rules: Rule[] = [{required: required ?? true, message: "This field is required"}]
if (type === "regex")
Expand Down Expand Up @@ -312,10 +311,26 @@ const NewEvaluatorModal: React.FC<Props> = ({
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)
Expand Down
Loading