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.
 

43 lines
2.0 KiB

import uno
from openai import OpenAI
promptCol = -1
answerCol = 9
client = OpenAI(api_key="sk-proj-hrV9Se3D3Vn6ro66AoMFT3BlbkFJ3kgB6P9xQFpcaymQQHFI")
def Generation_Appreciations():
oDoc = XSCRIPTCONTEXT.getDocument()
sheet = oDoc.getCurrentController().getActiveSheet()
row = 1
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 trimestrielle et éventuellement sur la moyenne annuelle, ne pas indiquer de valeur chiffrée."
while sheet[row,0].String!="":
prompt = sheet[row,0].String+", moyenne du trimestre "+sheet[row,2].String+"/20, moyenne annuelle "+sheet[row,1].String+"/20, comportement en classe niveau "+sheet[row,7].String+"/3, participation orale niveau "+sheet[row,8].String+"/3"
if sheet[row,5].String!="":
if int(sheet[row,5].String)>2:
prompt += ", nombre oublis de matériel "+sheet[row,5].String
if sheet[row,6].String!="":
if int(sheet[row,6].String)>2:
prompt += ", nombre exercices non faits "+sheet[row,6].String
if sheet[row,3].String!="":
if int(sheet[row,3].String)>2:
prompt += ", nombre absences "+sheet[row,3].String
if sheet[row,4].String!="":
if int(sheet[row,4].String)>2:
prompt += ", nombre de retards "+sheet[row,4].String
if promptCol != -1:
sheet[row,promptCol].String = prompt
if answerCol != -1:
chat_completion = client.chat.completions.create(
messages=[
{"role": "system","content": content},
{"role": "user","content": prompt}],
model="ft:gpt-3.5-turbo-1106:personal:bulletins2:9S8U7KuE",
temperature=0.5,
presence_penalty=0.6,
frequency_penalty=0.6,
top_p=0.5);
sheet[row,answerCol].String = chat_completion.choices[0].message.content
row = row+1
return None