commit
e83ff6f142
5 changed files with 63 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||||||
|
# Virtualenv |
||||||
|
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ |
||||||
|
.Python |
||||||
|
[Bb]in |
||||||
|
[Ii]nclude |
||||||
|
[Ll]ib |
||||||
|
[Ll]ib64 |
||||||
|
[Ll]ocal |
||||||
|
[Ss]cripts |
||||||
|
pyvenv.cfg |
||||||
|
.venv |
||||||
|
pip-selfcheck.json |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
# openaiAppreciations |
||||||
|
|
||||||
|
Script python permettant de générer des synthèses de bulletins depuis un export PDF pronote. |
||||||
|
|
||||||
|
#### Usage : |
||||||
|
|
||||||
|
Exécuter le script openaiAppreciations.py (le fichier bulletin par défaut se nomme sample.pdf) |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
from PyPDF2 import PdfReader |
||||||
|
from openai import OpenAI |
||||||
|
|
||||||
|
def getEleve(value): |
||||||
|
sub1 = "Trimestre" |
||||||
|
sub2 = "Né" |
||||||
|
idx1 = value.index(sub1) |
||||||
|
idx2 = value.index(sub2) |
||||||
|
res = '' |
||||||
|
# récupération du nom |
||||||
|
for idx in range(idx1 + len(sub1) + 1, idx2): |
||||||
|
res = res + value[idx] |
||||||
|
return res |
||||||
|
|
||||||
|
client = OpenAI(api_key="sk-proj-hrV9Se3D3Vn6ro66AoMFT3BlbkFJ3kgB6P9xQFpcaymQQHFI") |
||||||
|
current_eleve = '' |
||||||
|
|
||||||
|
reader = PdfReader("sample.pdf") |
||||||
|
#number_of_pages = len(reader.pages) |
||||||
|
|
||||||
|
for page in reader.pages: |
||||||
|
|
||||||
|
text = page.extract_text() |
||||||
|
|
||||||
|
#évite les doublons dans les exports pdf |
||||||
|
if getEleve(text) != current_eleve: |
||||||
|
|
||||||
|
current_eleve = getEleve(text) |
||||||
|
print("\r\n"+current_eleve) |
||||||
|
|
||||||
|
completion = client.chat.completions.create( |
||||||
|
model="ft:gpt-4o-2024-08-06:personal:app-gen-gangneux2:AYJecsON", |
||||||
|
messages=[ |
||||||
|
{"role": "system", "content": "Rédige une appréciation générale (500 caractères max) en utilisant la liste suivante."}, |
||||||
|
{"role": "user", "content": text} |
||||||
|
], |
||||||
|
temperature=0.7, |
||||||
|
presence_penalty=0.6, |
||||||
|
frequency_penalty=0.6, |
||||||
|
top_p=0.5) |
||||||
|
|
||||||
|
print(completion.choices[0].message.content) |
||||||
Binary file not shown.
Loading…
Reference in new issue