评估答案
(
self, answer, config: JudgeConfig, container: Container, session: Session
)
| 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 | """使用匹配标准评估答案""" |
no test coverage detected