OpenCAI / convert-to-vicuna.py
Norquinal's picture
Upload convert-to-vicuna.py
9ec26b4 verified
raw
history blame
851 Bytes
import json
import random
import re
import names
def parse_example(example):
parsed_objects = []
for i in range(len(example)):
text = """A transcript of a roleplay chat between several participants."""
for j in range(len(example[i]['conversations'])):
sender = example[i]['conversations'][j]['author']
text += f"\n{sender}: {example[i]['conversations'][j]['message']}"
parsed_objects.append({"text": text.strip()})
return parsed_objects
# Load the JSON file containing numerous objects
with open('discord_logs.json', 'r', encoding="UTF-8") as file:
data = json.load(file)
parsed_data = parse_example(data)
# Save the parsed data to a new JSON file
with open('discord_logs_vicuna.json', 'w') as output_file:
json.dump(parsed_data, output_file, indent=2)