| #!/usr/bin/env python3 | |
| import json | |
| import os | |
| # 读取 JSON 文件并转换为 JSONL | |
| input_file = "/workspace/hanrui/SpecForge-ext/mtbench_sample.json" | |
| with open(input_file, 'r') as f: | |
| data = json.load(f) | |
| # 保存为 jsonl | |
| cache_dir = os.path.expanduser("~/.cache/sglang") | |
| os.makedirs(cache_dir, exist_ok=True) | |
| output_file = os.path.join(cache_dir, "mtbench.jsonl") | |
| with open(output_file, 'w') as f: | |
| for item in data: | |
| f.write(json.dumps(item) + '\n') | |
| print(f"Converted {len(data)} questions") | |
| print(f"Saved to {output_file}") | |
| print(f"\nFirst question:") | |
| print(json.dumps(data[0], indent=2)) | |