ChatExplorer / dataset_adapters /e46a55643ce19efc8adfe855f6ff7a2a3e93a60ea42b1897f4c705919e6f821a.py
thomasgauthier's picture
will this work?
10c1f9c
def transform_data(data):
transformed_data = []
for i in range(len(data["data"])):
# Setting the correct "from" field based on the index
if i % 2 == 0:
# Case of input or instruction
if i < len(data["data"]) - 1:
# There is a response after this message, it is an input
msg_type = 'human'
else:
msg_type = 'system' # There is not a response after this message, it is an instruction
transformed_data.append({'from': msg_type, 'value': data["data"][i]})
else:
# The case where the "from" field would be 'gpt'
transformed_data.append({'from': 'gpt', 'value': data["data"][i]})
return {'conversations': transformed_data}