启动完整评测流程 参数: - dataset: 数据列表 - dataset_path: JSON 文件路径(包含测试用例列表) - tool_registry: 自定义工具注册表(可选) - output_dir: 结果保存路径(JSONL) - yaml_tool_path: 工具 YAML 配置路径(如果传入,会覆盖当前 tools)
(
self,
dataset: Optional[List[dict]] = None,
dataset_path: Optional[str] = None,
output_dir: Optional[str] = None,
yaml_tool_path: Optional[str] = None,
yaml_interaction_path: Optional[str] = None,
max_concurrent: int = 1,
bootcamp_registry: Optional[str] = None,
resume_from_result_path: Optional[str] = None
)
| 796 | raise e |
| 797 | |
| 798 | async def run_evaluation( |
| 799 | self, |
| 800 | dataset: Optional[List[dict]] = None, |
| 801 | dataset_path: Optional[str] = None, |
| 802 | output_dir: Optional[str] = None, |
| 803 | yaml_tool_path: Optional[str] = None, |
| 804 | yaml_interaction_path: Optional[str] = None, |
| 805 | max_concurrent: int = 1, |
| 806 | bootcamp_registry: Optional[str] = None, |
| 807 | resume_from_result_path: Optional[str] = None |
| 808 | ) -> List[dict]: |
| 809 | """ |
| 810 | 启动完整评测流程 |
| 811 | |
| 812 | 参数: |
| 813 | - dataset: 数据列表 |
| 814 | - dataset_path: JSON 文件路径(包含测试用例列表) |
| 815 | - tool_registry: 自定义工具注册表(可选) |
| 816 | - output_dir: 结果保存路径(JSONL) |
| 817 | - yaml_tool_path: 工具 YAML 配置路径(如果传入,会覆盖当前 tools) |
| 818 | """ |
| 819 | # 加载工具配置(可选) |
| 820 | if yaml_tool_path: |
| 821 | self.tool_schemas, self.tool_instances = self._load_tools_from_yaml(yaml_tool_path) |
| 822 | else: |
| 823 | self.tool_schemas, self.tool_instances = None, None |
| 824 | if yaml_interaction_path: |
| 825 | self.interaction = self._load_interaction_from_yaml(yaml_interaction_path) |
| 826 | else: |
| 827 | self.interaction = None |
| 828 | if bootcamp_registry: |
| 829 | self._load_bootcamp_registry(bootcamp_registry) |
| 830 | # 加载数据集 |
| 831 | if dataset_path and not dataset: |
| 832 | dataset = load_dataset(dataset_path) |
| 833 | |
| 834 | if not dataset: |
| 835 | raise ValueError("必须提供 dataset 或 dataset_path") |
| 836 | |
| 837 | # 断点重试逻辑 |
| 838 | completed_inputs = set() |
| 839 | original_dataset_size = len(dataset) |
| 840 | |
| 841 | if resume_from_result_path: |
| 842 | print(f"🔄 检测到断点重试模式,正在从 {resume_from_result_path} 加载已完成的结果...") |
| 843 | if os.path.exists(resume_from_result_path): |
| 844 | try: |
| 845 | with open(resume_from_result_path, "r", encoding="utf-8") as f: |
| 846 | for line in f: |
| 847 | if line.strip(): |
| 848 | result = json.loads(line.strip()) |
| 849 | if result.get("input"): |
| 850 | # 将input转换为字符串作为唯一标识 |
| 851 | input_key = json.dumps(result["input"], sort_keys=True, ensure_ascii=False) |
| 852 | completed_inputs.add(input_key) |
| 853 | loops = result.get("loops") |
| 854 | if loops and len(loops) > 0 and loops[0].get["input"]: |
| 855 | input_key = json.dumps(result["loops"][0]["input"], sort_keys=True, ensure_ascii=False) |
no test coverage detected