(data)
| 333 | # thread pool |
| 334 | lock = threading.Lock() |
| 335 | def process_data(data): |
| 336 | try: |
| 337 | full_traj = call_llm_with_tool(data, args) |
| 338 | final_block = full_traj.split('</think>')[-1] |
| 339 | data['final_response'] = final_block.split('<answer>')[-1].split('</answer>')[0].strip() if "<answer>" in final_block else final_block |
| 340 | data['full_traj'] = full_traj |
| 341 | with lock: |
| 342 | with open(save_path, 'a') as f: |
| 343 | f.write(json.dumps(data, ensure_ascii=False) + '\n') |
| 344 | except Exception as e: |
| 345 | print(f">> Error in processing the question: {data['question']}") |
| 346 | print(traceback.format_exc()) |
| 347 | error_response = getattr(e, 'response', 'N/A') |
| 348 | with open(log_path, 'a') as f: |
| 349 | f.write(f">> Error in processing the question: {data['question']}\n") |
| 350 | f.write(traceback.format_exc() + '\n') |
| 351 | f.write(f">> Response leading to the error: {error_response}\n") |
| 352 | |
| 353 | if args.sequential: |
| 354 | for data in test_data: |
no test coverage detected