MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / save_result

Method save_result

src/benchmark/leetcode.py:174–200  ·  view source on GitHub ↗

保存结果,并过滤掉 prompt, answer (代码), extra 等冗余字段

(self, result: Result)

Source from the content-addressed store, hash-verified

172
173
174 async def save_result(self, result: Result) -> None:
175 """
176 保存结果,并过滤掉 prompt, answer (代码), extra 等冗余字段
177 """
178 try:
179 # [修改点] 使用 exclude 参数过滤不需要的字段
180 # 1. 'prompt': 题目描述太长,且不需要保存
181 # 2. 'answer': 你提到代码不保存在这里
182 # 3. 'ground_truth': 通常为 null 或不重要
183 # 4. 'extra': 这里面包含了重复的 result 信息,直接去掉以减少冗余
184 json_line = result.model_dump_json(
185 exclude={
186 'prompt',
187 'answer',
188 'ground_truth',
189 'extra'
190 }
191 )
192
193 # 使用 'a' (append) 模式写入
194 with open(self.output_file, 'a', encoding='utf-8') as f:
195 f.write(json_line + "\n")
196
197 logger.info(f"| 💾 Saved result for Task {result.task_id} (Score: {result.score})")
198
199 except Exception as e:
200 logger.error(f"| ❌ Failed to save result to file: {e}")
201
202
203 async def _setup_git_repo(self):

Callers 2

flush_eval_queueMethod · 0.45

Calls 4

model_dump_jsonMethod · 0.80
writeMethod · 0.45
infoMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected