Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,17 +19,14 @@ YOUR_APP_NAME = "MonChatbot"
|
|
| 19 |
# ID de l'étudiant
|
| 20 |
#student_id = 34
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
# Dans une fonction de votre interface Gradio
|
| 28 |
-
request = Request() # Obtient les informations de la requête actuelle
|
| 29 |
-
username = request.username # Récupère le nom d'utilisateur connecté
|
| 30 |
-
return username
|
| 31 |
|
| 32 |
-
student_name = get_user_info()
|
| 33 |
|
| 34 |
def get_id_by_name(student_name):
|
| 35 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|
|
@@ -63,7 +60,6 @@ def get_id_by_name(student_name):
|
|
| 63 |
logger.error(f"Erreur lors de la récupération des informations : {str(e)}")
|
| 64 |
return None
|
| 65 |
|
| 66 |
-
student_id = get_id_by_name(student_name)
|
| 67 |
|
| 68 |
def get_user_info_by_id(student_id):
|
| 69 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|
|
@@ -330,12 +326,16 @@ def delete_compatibility_records(student_id):
|
|
| 330 |
return f"Erreur lors de la suppression des enregistrements : {str(e)}"
|
| 331 |
|
| 332 |
|
| 333 |
-
def start_conversation():
|
|
|
|
|
|
|
| 334 |
description = get_student_description(student_id)
|
| 335 |
initial_message = f"Bienvenue ! Voici vos compétences :\n{description}\n\nQue souhaitez-vous modifier ou améliorer dans vos compétences ?"
|
| 336 |
return [[None, initial_message]], description
|
| 337 |
|
| 338 |
-
def chatbot_conversation(message, history):
|
|
|
|
|
|
|
| 339 |
student_name, student_mail = get_user_info_by_id(student_id)
|
| 340 |
current_skills = get_student_description(student_id)
|
| 341 |
|
|
@@ -358,7 +358,9 @@ def chatbot_conversation(message, history):
|
|
| 358 |
|
| 359 |
return history, updated_skills
|
| 360 |
|
| 361 |
-
def validate_update(updated_skills):
|
|
|
|
|
|
|
| 362 |
response = update_student_description(student_id, updated_skills)
|
| 363 |
return response
|
| 364 |
|
|
|
|
| 19 |
# ID de l'étudiant
|
| 20 |
#student_id = 34
|
| 21 |
|
| 22 |
+
def getParams(x, request: gr.Request):
|
| 23 |
+
params = request.query_params
|
| 24 |
|
| 25 |
+
if 'name' in params:
|
| 26 |
+
return params['name']
|
| 27 |
+
else:
|
| 28 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
| 30 |
|
| 31 |
def get_id_by_name(student_name):
|
| 32 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|
|
|
|
| 60 |
logger.error(f"Erreur lors de la récupération des informations : {str(e)}")
|
| 61 |
return None
|
| 62 |
|
|
|
|
| 63 |
|
| 64 |
def get_user_info_by_id(student_id):
|
| 65 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|
|
|
|
| 326 |
return f"Erreur lors de la suppression des enregistrements : {str(e)}"
|
| 327 |
|
| 328 |
|
| 329 |
+
def start_conversation(request: gr.Request):
|
| 330 |
+
student_name = getParams(None, request)
|
| 331 |
+
student_id = get_id_by_name(student_name)
|
| 332 |
description = get_student_description(student_id)
|
| 333 |
initial_message = f"Bienvenue ! Voici vos compétences :\n{description}\n\nQue souhaitez-vous modifier ou améliorer dans vos compétences ?"
|
| 334 |
return [[None, initial_message]], description
|
| 335 |
|
| 336 |
+
def chatbot_conversation(message, history, request: gr.Request):
|
| 337 |
+
student_name = getParams(None, request)
|
| 338 |
+
student_id = get_id_by_name(student_name)
|
| 339 |
student_name, student_mail = get_user_info_by_id(student_id)
|
| 340 |
current_skills = get_student_description(student_id)
|
| 341 |
|
|
|
|
| 358 |
|
| 359 |
return history, updated_skills
|
| 360 |
|
| 361 |
+
def validate_update(updated_skills, request: gr.Request):
|
| 362 |
+
student_name = getParams(None, request)
|
| 363 |
+
student_id = get_id_by_name(student_name)
|
| 364 |
response = update_student_description(student_id, updated_skills)
|
| 365 |
return response
|
| 366 |
|