Spaces:
Sleeping
Sleeping
File size: 625 Bytes
10c1f9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import random
def transform_data(data):
transformed_data = {}
transformed_data['id'] = random.randint(1, 1000000) # generates a random integer as ID
transformed_data['conversations'] = []
conversations = data.get('conversations', [])
for conversation in conversations:
from_val = conversation.get('from', '')
value = conversation.get('value', '')
if from_val.lower() in ['human', 'gpt', 'system']:
transformed_conversation = {'from': from_val, 'value': value}
transformed_data['conversations'].append(transformed_conversation)
return transformed_data |