Spaces:
Sleeping
Sleeping
File size: 669 Bytes
10c1f9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
def transform_data(data):
transformed_data = {}
# get the id
transformation_id = data.get("id", 0) # substitute 0 (or any default) if no id is found
transformed_data["id"] = transformation_id
# split the conversations into separate messages
instructions = data.get("instruction", None)
outputs = data.get("output", None)
# build conversation array
conversations = []
if instructions:
conversations.append({"from": "human", "value":instructions})
if outputs:
conversations.append({"from": "gpt", "value": outputs})
transformed_data["conversations"] = conversations
return transformed_data |