You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

32 lines
1.4 KiB

import os
import csv
fichier = "Data bulletin tuning.csv"
fichier_out = "finetunning.jsonl"
with open(fichier, 'r') as file:
reader = csv.reader(file)
data = list(reader)
output = []
content = "rédige un commentaire de bulletin de fin d'année scolaire, maximum 300 caractères, tutoiement de l'élève, commentaire sur la moyenne du trimestre et éventuellement sur la moyenne annuelle, ne pas indiquer de valeur chiffrée."
for i in range(1, len(data)):
prompt = data[i][0]+", moyenne du trimestre "+data[i][2]+"/20, moyenne annuelle "+data[i][1]+"/20, comportement en classe niveau "+data[i][7]+"/3, participation orale niveau "+data[i][8]+"/3"
if data[i][5]!="":
if int(data[i][5])>2:
prompt += ", nombre oublis de matériel "+data[i][5]
if data[i][6]!="":
if int(data[i][6])>2:
prompt += ", nombre exercices non faits "+data[i][6]
if data[i][3]!="":
if int(data[i][3])>2:
prompt += ", nombre absences "+data[i][3]
if data[i][4]!="":
if int(data[i][4])>2:
prompt += ", nombre de retards "+data[i][4]
output.append('{"messages": [{"role": "system", "content": "'+content+'"},{"role": "user", "content": "'+prompt+'"},{"role": "assistant", "content": "'+data[i][9]+'"}]}')
with open(fichier_out, 'w') as fp:
for item in output:
fp.write("%s\n" % item)