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

Method save_single

AgentBench.old/src/task.py:139–151  ·  view source on GitHub ↗
(self, index: int, input: T_INPUT, output: T_OUTPUT, session: Session=None)

Source from the content-addressed store, hash-verified

137 return results
138
139 def save_single(self, index: int, input: T_INPUT, output: T_OUTPUT, session: Session=None):
140 save_obj = {
141 "index": index,
142 "input": serialize(input),
143 "output": serialize(output),
144 "history": session.history if session else None,
145 "exception_raised": session.exception_raised if session else None
146 }
147 if not os.path.exists(self.get_output_dir()):
148 try: os.makedirs(self.get_output_dir())
149 except: pass
150 with open(os.path.join(self.get_output_dir(), "generation.jsonl"), "a", encoding="utf-8") as f:
151 f.write(json.dumps(save_obj, ensure_ascii=False) + "\n")
152
153 def save_runs_all(self, inputs: List[T_INPUT], outputs: List[T_OUTPUT], targets: List[T_TARGET], metrics: Dict[str, Any] = None):
154 if not os.path.exists(self.get_output_dir()):

Callers 2

call_wrapMethod · 0.95
call_wrapMethod · 0.80

Calls 4

get_output_dirMethod · 0.95
joinMethod · 0.80
serializeFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected