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

Method __init__

AgentBench.old/src/tasks/alfworld/task.py:27–70  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

25class ALFWorld(Task):
26
27 def __init__(self, **kwargs):
28 mp.set_start_method('spawn')
29
30 # load data_path
31 self.data_path = kwargs.get("data_path", None)
32 if self.data_path is None:
33 raise Exception("missing parameter data_path")
34 os.environ["ALFWORLD_DATA"] = self.data_path
35
36 # load config for alfworld benchmark
37 self.config_path = kwargs.get("config_path", None)
38 if self.config_path is None:
39 raise Exception("missing parameter config_path")
40 self.config = load_config(self.config_path)
41
42 # load prompts
43 self.prompts_path = kwargs.get("prompts_path", None)
44 if self.prompts_path is None:
45 raise Exception("missing parameter prompts_path")
46 self.prompts = load_prompts(self.prompts_path)
47
48 # prepare data_files
49 self.data_files = []
50 self.split = kwargs.get("split", "dev")
51 data_path = os.path.join("data/alfworld", f"{self.split}.json")
52 with open(data_path, "r") as f:
53 content = json.loads(f.read())
54 for _, v in content.items():
55 self.data_files.extend(v)
56 self.data_files = [os.path.join(self.data_path, file) for file in self.data_files]
57 print(f"> successfully loaded {len(self.data_files)} games")
58
59 # other configs
60 self.max_step = kwargs.get("max_step", 50)
61 self.prefixes = {
62 'pick_and_place': 'put',
63 'pick_clean_then_place': 'clean',
64 'pick_heat_then_place': 'heat',
65 'pick_cool_then_place': 'cool',
66 'look_at_obj': 'examine',
67 'pick_two_obj': 'puttwo'
68 }
69
70 super().__init__(**kwargs)
71
72 def final_score(self, results: List[Dict], targets: List[None]):
73 try:

Callers

nothing calls this directly

Calls 4

load_configFunction · 0.85
load_promptsFunction · 0.85
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected