Spaces:
Sleeping
Sleeping
def transform_data(data): | |
transformed_data = { | |
'id': data['id'], | |
'conversations': [] | |
} | |
for conversation in data['conversations']: | |
if conversation['from'] == 'human': | |
transformed_data['conversations'].append({'input': conversation['value']}) | |
elif conversation['from'] == 'gpt': | |
transformed_data['conversations'][-1]['output'] = conversation['value'] | |
return transformed_data |