diff --git a/agenta-backend/agenta_backend/models/converters.py b/agenta-backend/agenta_backend/models/converters.py index f74acebe8e..2534d77d17 100644 --- a/agenta-backend/agenta_backend/models/converters.py +++ b/agenta-backend/agenta_backend/models/converters.py @@ -121,11 +121,11 @@ async def human_evaluation_db_to_pydantic( def human_evaluation_scenario_db_to_pydantic( - evaluation_scenario_db: HumanEvaluationScenarioDB, + evaluation_scenario_db: HumanEvaluationScenarioDB, evaluation_id: str ) -> HumanEvaluationScenario: return HumanEvaluationScenario( id=str(evaluation_scenario_db.id), - evaluation_id=str(evaluation_scenario_db.evaluation.id), + evaluation_id=evaluation_id, inputs=evaluation_scenario_db.inputs, outputs=evaluation_scenario_db.outputs, vote=evaluation_scenario_db.vote, @@ -167,11 +167,11 @@ def evaluation_scenarios_results_to_pydantic( def evaluation_scenario_db_to_pydantic( - evaluation_scenario_db: EvaluationScenarioDB, + evaluation_scenario_db: EvaluationScenarioDB, evaluation_id: str ) -> EvaluationScenario: return EvaluationScenario( id=str(evaluation_scenario_db.id), - evaluation_id=str(evaluation_scenario_db.evaluation.id), + evaluation_id=evaluation_id, inputs=[ EvaluationScenarioInput(**scenario_input.dict()) for scenario_input in evaluation_scenario_db.inputs diff --git a/agenta-backend/agenta_backend/services/evaluation_service.py b/agenta-backend/agenta_backend/services/evaluation_service.py index db79d2f55f..9b633dfa99 100644 --- a/agenta-backend/agenta_backend/services/evaluation_service.py +++ b/agenta-backend/agenta_backend/services/evaluation_service.py @@ -290,10 +290,10 @@ async def fetch_evaluation_scenarios_for_evaluation( **user_org_data, ) scenarios = await EvaluationScenarioDB.find( - EvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id), fetch_links=True + EvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id) ).to_list() eval_scenarios = [ - converters.evaluation_scenario_db_to_pydantic(scenario) + converters.evaluation_scenario_db_to_pydantic(scenario, str(evaluation.id)) for scenario in scenarios ] return eval_scenarios @@ -321,10 +321,11 @@ async def fetch_human_evaluation_scenarios_for_evaluation( ) scenarios = await HumanEvaluationScenarioDB.find( HumanEvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id), - fetch_links=True, ).to_list() eval_scenarios = [ - converters.human_evaluation_scenario_db_to_pydantic(scenario) + converters.human_evaluation_scenario_db_to_pydantic( + scenario, str(evaluation.id) + ) for scenario in scenarios ] return eval_scenarios