Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ YOUR_APP_NAME = "MonChatbot"
|
|
| 19 |
# ID de l'étudiant
|
| 20 |
#student_id = 34
|
| 21 |
|
|
|
|
| 22 |
def getParams(x, request: gr.Request):
|
| 23 |
params = request.query_params
|
| 24 |
|
|
@@ -219,7 +220,8 @@ def get_enterprise_descriptions():
|
|
| 219 |
(
|
| 220 |
record['fields'].get('Recruteur / Entreprise'),
|
| 221 |
record['fields'].get('Compétences requises'),
|
| 222 |
-
record['fields'].get('ID_Offre')
|
|
|
|
| 223 |
)
|
| 224 |
for record in data['records']
|
| 225 |
]
|
|
@@ -266,7 +268,7 @@ def compare_skills_ai(student_skills, enterprise_skills):
|
|
| 266 |
logger.error(f"Erreur lors de l'appel API: {str(e)}")
|
| 267 |
return f"Erreur lors de l'analyse des compétences : {str(e)}"
|
| 268 |
|
| 269 |
-
def update_compatibility_table(student_id, skill_assessment, enterprise_skills, offer_id, compatibility_rate, student_name, student_mail):
|
| 270 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/TauxCompatibilité"
|
| 271 |
headers = {
|
| 272 |
"Authorization": f"Bearer {AIRTABLE_API_KEY}",
|
|
@@ -281,7 +283,9 @@ def update_compatibility_table(student_id, skill_assessment, enterprise_skills,
|
|
| 281 |
"DescriptionOffre": enterprise_skills,
|
| 282 |
"Taux de compatibilité" : compatibility_rate,
|
| 283 |
"Nom": student_name,
|
| 284 |
-
"EmailEtudiant": student_mail
|
|
|
|
|
|
|
| 285 |
}
|
| 286 |
}
|
| 287 |
|
|
@@ -346,10 +350,10 @@ def chatbot_conversation(message, history, request: gr.Request):
|
|
| 346 |
enterprise_descriptions = get_enterprise_descriptions()
|
| 347 |
results = []
|
| 348 |
delete_compatibility_records(student_id)
|
| 349 |
-
for enterprise_name, enterprise_desc, offer_id in enterprise_descriptions:
|
| 350 |
analysis = compare_skills_ai(updated_skills, enterprise_desc)
|
| 351 |
|
| 352 |
-
add_response = update_compatibility_table(student_id, updated_skills, enterprise_desc, offer_id, analysis, student_name, student_mail)
|
| 353 |
|
| 354 |
results.append(f"Entreprise : {enterprise_name}\n{add_response}")
|
| 355 |
|
|
@@ -367,22 +371,11 @@ def validate_update(updated_skills, request: gr.Request):
|
|
| 367 |
|
| 368 |
# Création de l'interface
|
| 369 |
with gr.Blocks() as demo:
|
| 370 |
-
gr.
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
padding: 20px; /* Optionnel : ajoute un peu d'espace autour */
|
| 376 |
-
}
|
| 377 |
-
</style>
|
| 378 |
-
""")
|
| 379 |
-
with gr.Row(elem_id="scroll-container"):
|
| 380 |
-
with gr.Column(scale=1):
|
| 381 |
-
chatbot = gr.Chatbot(label="Chatbot", elem_id="chatbot") # Chatbot pour la conversation
|
| 382 |
-
msg = gr.Textbox(label="Message", placeholder="Tapez votre message ici...") # Champ de texte pour envoyer des messages
|
| 383 |
-
skill_assessment_output = gr.Textbox(label="Compétences actuelles", interactive=False) # Sortie des compétences
|
| 384 |
-
validate_button = gr.Button("Valider la mise à jour") # Bouton pour valider la mise à jour
|
| 385 |
-
validation_output = gr.Textbox(label="Résultat de la mise à jour", interactive=False)
|
| 386 |
|
| 387 |
|
| 388 |
|
|
|
|
| 19 |
# ID de l'étudiant
|
| 20 |
#student_id = 34
|
| 21 |
|
| 22 |
+
|
| 23 |
def getParams(x, request: gr.Request):
|
| 24 |
params = request.query_params
|
| 25 |
|
|
|
|
| 220 |
(
|
| 221 |
record['fields'].get('Recruteur / Entreprise'),
|
| 222 |
record['fields'].get('Compétences requises'),
|
| 223 |
+
record['fields'].get('ID_Offre'),
|
| 224 |
+
record['fields'].get('email')
|
| 225 |
)
|
| 226 |
for record in data['records']
|
| 227 |
]
|
|
|
|
| 268 |
logger.error(f"Erreur lors de l'appel API: {str(e)}")
|
| 269 |
return f"Erreur lors de l'analyse des compétences : {str(e)}"
|
| 270 |
|
| 271 |
+
def update_compatibility_table(student_id, skill_assessment, enterprise_skills, offer_id, compatibility_rate, student_name, student_mail, emailEntreprise, enterprise_name):
|
| 272 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/TauxCompatibilité"
|
| 273 |
headers = {
|
| 274 |
"Authorization": f"Bearer {AIRTABLE_API_KEY}",
|
|
|
|
| 283 |
"DescriptionOffre": enterprise_skills,
|
| 284 |
"Taux de compatibilité" : compatibility_rate,
|
| 285 |
"Nom": student_name,
|
| 286 |
+
"EmailEtudiant": student_mail,
|
| 287 |
+
"EmailEntreprise": emailEntreprise,
|
| 288 |
+
"Nom_Recruteur_Entreprise": enterprise_name
|
| 289 |
}
|
| 290 |
}
|
| 291 |
|
|
|
|
| 350 |
enterprise_descriptions = get_enterprise_descriptions()
|
| 351 |
results = []
|
| 352 |
delete_compatibility_records(student_id)
|
| 353 |
+
for enterprise_name, enterprise_desc, offer_id, emailEntreprise in enterprise_descriptions:
|
| 354 |
analysis = compare_skills_ai(updated_skills, enterprise_desc)
|
| 355 |
|
| 356 |
+
add_response = update_compatibility_table(student_id, updated_skills, enterprise_desc, offer_id, analysis, student_name, student_mail, emailEntreprise, enterprise_name)
|
| 357 |
|
| 358 |
results.append(f"Entreprise : {enterprise_name}\n{add_response}")
|
| 359 |
|
|
|
|
| 371 |
|
| 372 |
# Création de l'interface
|
| 373 |
with gr.Blocks() as demo:
|
| 374 |
+
chatbot = gr.Chatbot(label="Chatbot", elem_id="chatbot")
|
| 375 |
+
msg = gr.Textbox(label="Message")
|
| 376 |
+
skill_assessment_output = gr.Textbox(label="Compétences actuelles", interactive=False)
|
| 377 |
+
validate_button = gr.Button("Valider la mise à jour") # Nouveau bouton pour valider
|
| 378 |
+
validation_output = gr.Textbox(label="Résultat de la mise à jour", interactive=False) # Nouveau bloc pour afficher le résultat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
|
| 381 |
|