33 lines
825 B
Python
33 lines
825 B
Python
# -*- coding: utf-8 -*-
|
|
# @Time : 2024/10/24 20:47
|
|
# @Author : 黄子寒
|
|
# @Email : 1064071566@qq.com
|
|
# @File : jsonl2json.py
|
|
# @Project : EmoLLM
|
|
import json
|
|
|
|
|
|
input_file = 'output/fine_tune_data.jsonl'
|
|
output_file = 'output/fine_tune_data.json'
|
|
|
|
|
|
data_list = []
|
|
with open(input_file, 'r', encoding='utf-8') as f:
|
|
for line in f:
|
|
entry = json.loads(line.strip())
|
|
|
|
new_entry = {
|
|
"instruction": entry.get("instruction", ""),
|
|
"input": entry.get("input", ""),
|
|
"output": entry.get("output", ""),
|
|
"system": entry.get("system", ""),
|
|
"history": entry.get("history", [])
|
|
}
|
|
data_list.append(new_entry)
|
|
|
|
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
json.dump(data_list, f, ensure_ascii=False, indent=4)
|
|
|
|
print(f" {output_file}")
|