| from llm_factory import get_llm | |
| from langchain_core.prompts import PromptTemplate | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| def get_pharmacist_agent(): | |
| llm = get_llm(model_type="text", temperature=0.1) | |
| template = """ | |
| Tu es un Pharmacien Clinicien Expert. Ta mission est de sécuriser la prescription. | |
| PATIENT : | |
| - Nom : {patient_name} | |
| - Âge : {patient_age} | |
| - Antécédents : {history} | |
| ORDONNANCE PROPOSÉE : | |
| {prescription} | |
| ANALYSE REQUISE : | |
| 1. Vérifier les contre-indications absolues avec les antécédents. | |
| 2. Vérifier les interactions médicamenteuses majeures. | |
| 3. Vérifier les dosages (si fournis) par rapport à l'âge. | |
| RÉPONSE (En Français) : | |
| - STATUT : [VALIDÉ ✅ / ATTENTION ⚠️ / DANGER ⛔] | |
| - ANALYSE : [Commentaire bref] | |
| - RECOMMANDATION : [Si nécessaire, correction suggérée] | |
| """ | |
| prompt = PromptTemplate( | |
| input_variables=["patient_name", "patient_age", "history", "prescription"], | |
| template=template, | |
| ) | |
| return prompt | llm | |
| async def run_pharmacist_agent(patient_name: str, patient_age: int, history: str, prescription: str) -> str: | |
| agent = get_pharmacist_agent() | |
| response = await agent.ainvoke({ | |
| "patient_name": patient_name, | |
| "patient_age": patient_age, | |
| "history": history, | |
| "prescription": prescription | |
| }) | |
| return response.content | |