MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / __init__

Method __init__

AgentBench.old/src/tasks/os_interaction/task.py:238–277  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

236 return configs
237
238 def __init__(self, **kwargs):
239 # TODO: load config here
240 self.match_problem: bool = kwargs.pop("match_problem", True)
241 self.check_problem: bool = kwargs.pop("check_problem", True)
242 self.round_limit: int = kwargs.pop("round_limit", 8)
243 self.data_config = kwargs.pop("data_config", None)
244 if not self.data_config:
245 raise ValueError("data_config must be set")
246 self.docker_config = kwargs.pop("docker_config", None)
247 if not self.docker_config:
248 raise ValueError("docker_config must be set")
249 configs: List[dict[str, Any]] = []
250 matches = []
251 for item in self.data_config["files"]:
252 path = item["problem_file"]
253 for file in glob.glob(path):
254 if file.endswith(".json") or file.endswith(".jsonl"):
255 matches.append({
256 "problem_file": file,
257 "script_dir": item["script_dir"]
258 })
259 self.data_config["files"] = matches
260 for item in self.data_config["files"]:
261 problem_file, problem_dir = item["problem_file"], item["script_dir"]
262 single_file_configs = self._load_configs(problem_file, problem_dir)
263 single_file_check_configs = []
264 single_file_match_configs = []
265 for idx, config in enumerate(single_file_configs):
266 if config.check:
267 single_file_check_configs.append({"file": problem_file, "config": config, "index": idx})
268 elif config.match:
269 single_file_match_configs.append({"file": problem_file, "config": config, "index": idx})
270 print("Load %s, %d problems, %d check problems, %d match problems." % (problem_file, len(single_file_configs), len(single_file_check_configs), len(single_file_match_configs)))
271 if self.match_problem:
272 configs.extend(single_file_match_configs)
273 if self.check_problem:
274 configs.extend(single_file_check_configs)
275 self.problem_configs = configs
276
277 super().__init__(**kwargs)
278
279 def metric(self, prediction: List[Dict], target: List[None]):
280 files = []

Callers

nothing calls this directly

Calls 2

_load_configsMethod · 0.95
__init__Method · 0.45

Tested by

no test coverage detected