Implement #4
This commit is contained in:
@ -280,7 +280,7 @@ class SolveAgent(BasicAgent):
|
||||
if len(solution.solution) == 0 or len(solution.explanation) == 0:
|
||||
logger.info(f"Riddle {self._response.id}: Empty solution/ explanation after handling")
|
||||
|
||||
self._response.solution = solution
|
||||
self._response.solution.append(solution)
|
||||
self._response.status.solve.finished = True
|
||||
|
||||
self._do_response = True
|
||||
@ -289,7 +289,7 @@ class SolveAgent(BasicAgent):
|
||||
@validate_call
|
||||
def handle(self, riddle: Riddle, data: List[RiddleData]) -> RiddleSolution:
|
||||
"""
|
||||
Solve the `riddle` using `data` and return a solution.
|
||||
Solve the `riddle` using `data` and return a single solution.
|
||||
"""
|
||||
|
||||
class GatekeeperAgent(BasicAgent):
|
||||
@ -301,25 +301,26 @@ class GatekeeperAgent(BasicAgent):
|
||||
return AgentCapability.GATEKEEPER
|
||||
|
||||
def _process(self):
|
||||
if self._response.solution is None:
|
||||
self._response.solution = RiddleSolution(solution="", explanation="")
|
||||
if len(self._response.solution) == 0:
|
||||
self._response.solution.append(RiddleSolution(solution="", explanation=""))
|
||||
|
||||
logger.debug(f"Start validate: {self._response.id}")
|
||||
solution = self.handle(self._response.solution, self._response.riddle)
|
||||
logger.debug(f"End validate: {self._response.id} ({solution.review}, {solution.accepted})")
|
||||
|
||||
if solution.review is None or len(solution.review) == 0:
|
||||
logger.info(f"Riddle {self._response.id}: Empty review after handling")
|
||||
for single_solution in solution:
|
||||
logger.debug(f"End validate: {self._response.id} ({single_solution.review}, {single_solution.accepted})")
|
||||
if single_solution.review is None or len(single_solution.review) == 0:
|
||||
logger.info(f"Riddle {self._response.id}: Empty review after handling")
|
||||
|
||||
self._response.solution = solution
|
||||
self._response.status.validate.finished = True
|
||||
self._response.status.solved = solution.accepted
|
||||
self._response.status.solved = any(single_solution.accepted for single_solution in solution)
|
||||
|
||||
self._do_response = True
|
||||
|
||||
@abstractmethod
|
||||
@validate_call
|
||||
def handle(self, solution:RiddleSolution, riddle:Riddle) -> RiddleSolution:
|
||||
def handle(self, solution:List[RiddleSolution], riddle:Riddle) -> List[RiddleSolution]:
|
||||
"""
|
||||
Check the `solution` of `riddle` and return solution with populated `solution.accepted` and `solution.review`.
|
||||
Check the `solution` (multiple if multiple solver involved) of `riddle` and return solutions with populated `solution[i].accepted` and `solution[i].review`.
|
||||
"""
|
Reference in New Issue
Block a user