Update agent.py
Browse files
agent.py
CHANGED
@@ -198,9 +198,11 @@ class FlagRiskInput(BaseModel):
|
|
198 |
urgency: str = Field("High")
|
199 |
|
200 |
# ββ Tool Implementations ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
201 |
-
@tool("order_lab_test", args_schema=LabOrderInput
|
202 |
def order_lab_test(test_name: str, reason: str, priority: str = "Routine") -> str:
|
203 |
-
"""
|
|
|
|
|
204 |
logger.info(f"Ordering lab test: {test_name}, reason: {reason}, priority: {priority}")
|
205 |
return json.dumps({
|
206 |
"status": "success",
|
@@ -208,7 +210,7 @@ def order_lab_test(test_name: str, reason: str, priority: str = "Routine") -> st
|
|
208 |
"details": f"Reason: {reason}"
|
209 |
})
|
210 |
|
211 |
-
@tool("prescribe_medication", args_schema=PrescriptionInput
|
212 |
def prescribe_medication(
|
213 |
medication_name: str,
|
214 |
dosage: str,
|
@@ -217,7 +219,9 @@ def prescribe_medication(
|
|
217 |
duration: str,
|
218 |
reason: str
|
219 |
) -> str:
|
220 |
-
"""
|
|
|
|
|
221 |
logger.info(f"Preparing prescription: {medication_name} {dosage}, route: {route}, freq: {frequency}")
|
222 |
return json.dumps({
|
223 |
"status": "success",
|
@@ -225,13 +229,15 @@ def prescribe_medication(
|
|
225 |
"details": f"Duration: {duration}. Reason: {reason}"
|
226 |
})
|
227 |
|
228 |
-
@tool("check_drug_interactions", args_schema=InteractionCheckInput
|
229 |
def check_drug_interactions(
|
230 |
potential_prescription: str,
|
231 |
current_medications: Optional[List[str]] = None,
|
232 |
allergies: Optional[List[str]] = None
|
233 |
) -> str:
|
234 |
-
"""
|
|
|
|
|
235 |
logger.info(f"Checking interactions for: {potential_prescription}")
|
236 |
warnings: List[str] = []
|
237 |
pm = [m.lower().strip() for m in (current_medications or []) if m]
|
@@ -266,9 +272,11 @@ def check_drug_interactions(
|
|
266 |
)
|
267 |
return json.dumps({"status": status, "message": message, "warnings": warnings})
|
268 |
|
269 |
-
@tool("flag_risk", args_schema=FlagRiskInput
|
270 |
def flag_risk(risk_description: str, urgency: str = "High") -> str:
|
271 |
-
"""
|
|
|
|
|
272 |
logger.info(f"Flagging risk: {risk_description} (urgency={urgency})")
|
273 |
return json.dumps({
|
274 |
"status": "flagged",
|
|
|
198 |
urgency: str = Field("High")
|
199 |
|
200 |
# ββ Tool Implementations ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
201 |
+
@tool("order_lab_test", args_schema=LabOrderInput)
|
202 |
def order_lab_test(test_name: str, reason: str, priority: str = "Routine") -> str:
|
203 |
+
"""
|
204 |
+
Place an order for a laboratory test.
|
205 |
+
"""
|
206 |
logger.info(f"Ordering lab test: {test_name}, reason: {reason}, priority: {priority}")
|
207 |
return json.dumps({
|
208 |
"status": "success",
|
|
|
210 |
"details": f"Reason: {reason}"
|
211 |
})
|
212 |
|
213 |
+
@tool("prescribe_medication", args_schema=PrescriptionInput)
|
214 |
def prescribe_medication(
|
215 |
medication_name: str,
|
216 |
dosage: str,
|
|
|
219 |
duration: str,
|
220 |
reason: str
|
221 |
) -> str:
|
222 |
+
"""
|
223 |
+
Prepare a medication prescription.
|
224 |
+
"""
|
225 |
logger.info(f"Preparing prescription: {medication_name} {dosage}, route: {route}, freq: {frequency}")
|
226 |
return json.dumps({
|
227 |
"status": "success",
|
|
|
229 |
"details": f"Duration: {duration}. Reason: {reason}"
|
230 |
})
|
231 |
|
232 |
+
@tool("check_drug_interactions", args_schema=InteractionCheckInput)
|
233 |
def check_drug_interactions(
|
234 |
potential_prescription: str,
|
235 |
current_medications: Optional[List[str]] = None,
|
236 |
allergies: Optional[List[str]] = None
|
237 |
) -> str:
|
238 |
+
"""
|
239 |
+
Check for drugβdrug interactions and allergy risks.
|
240 |
+
"""
|
241 |
logger.info(f"Checking interactions for: {potential_prescription}")
|
242 |
warnings: List[str] = []
|
243 |
pm = [m.lower().strip() for m in (current_medications or []) if m]
|
|
|
272 |
)
|
273 |
return json.dumps({"status": status, "message": message, "warnings": warnings})
|
274 |
|
275 |
+
@tool("flag_risk", args_schema=FlagRiskInput)
|
276 |
def flag_risk(risk_description: str, urgency: str = "High") -> str:
|
277 |
+
"""
|
278 |
+
Flag a clinical risk with given urgency.
|
279 |
+
"""
|
280 |
logger.info(f"Flagging risk: {risk_description} (urgency={urgency})")
|
281 |
return json.dumps({
|
282 |
"status": "flagged",
|