From 0b6172dd437ea084a53b87b7a93a304144fc98c9 Mon Sep 17 00:00:00 2001 From: Xisen Wang <118058822+Xisen-Wang@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:41:22 +0800 Subject: [PATCH] Updated Trace class - Updated get_last_experiment_info(), a very useful function that returns the information of last experiment (to be used in feedback generation). --- rdagent/core/proposal.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rdagent/core/proposal.py b/rdagent/core/proposal.py index 93e20453..cf7e7cbf 100644 --- a/rdagent/core/proposal.py +++ b/rdagent/core/proposal.py @@ -54,6 +54,14 @@ class Trace(Generic[ASpecificScen]): self.scen: ASpecificScen = scen self.hist: list[Tuple[Hypothesis, Experiment, HypothesisFeedback]] = [] + def get_last_experiment_info(self) -> Tuple[Hypothesis, ASpecificTask, Any]: + """Access the last experiment result, sub-task, and the corresponding hypothesis.""" + if not self.hist: + return None + last_hypothesis, last_experiment, _ = self.hist[-1] + last_task = last_experiment.sub_tasks[-1] + last_result = last_experiment.result + return last_hypothesis, last_task, last_result class HypothesisGen: def __init__(self, scen: Scenario):