MCPcopy Create free account
hub / github.com/THUDM/AgentBench / _evaluate_answer

Method _evaluate_answer

src/server/tasks/os_interaction/task.py:671–698  ·  view source on GitHub ↗

评估答案

(
            self, answer, config: JudgeConfig, container: Container, session: Session
    )

Source from the content-addressed store, hash-verified

669 ))
670
671 async def _evaluate_answer(
672 self, answer, config: JudgeConfig, container: Container, session: Session
673 ) -> dict:
674 """评估答案"""
675 result = {"success": False}
676
677 # 处理答案格式
678 if isinstance(answer, str) and config.match and config.match["strip"]:
679 answer = answer.strip()
680 logging.info(f"Final answer: {answer}")
681
682 # 使用匹配标准评估
683 if config.match:
684 result["success"] = self._evaluate_by_match(answer, config)
685 # 使用检查脚本评估
686 elif config.check:
687 result["success"] = await self._evaluate_by_check_scripts(answer, config, container)
688 # 无评估方法
689 else:
690 logging.error("No evaluation method specified")
691 final_rewardhistory = RewardHistoryItem(reward=0, score=0)
692 session.inject(final_rewardhistory)
693 result["error"] = True
694 result["result"] = TaskSampleExecutionResult(
695 status=SampleStatus.TASK_ERROR, result={"result": False}
696 )
697
698 return result
699
700 def _evaluate_by_match(self, answer: str, config: JudgeConfig) -> bool:
701 """使用匹配标准评估答案"""

Callers 1

_judgeMethod · 0.95

Calls 3

_evaluate_by_matchMethod · 0.95

Tested by

no test coverage detected