Create medical_points_agent.py
Browse files
components/medical_points_agent.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from groq import Groq
|
| 2 |
+
client = Groq(api_key="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")
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def MedicalKeyPoints(content):
|
| 6 |
+
# Insert at index 0
|
| 7 |
+
|
| 8 |
+
SYSTEM_PROMPT="""
|
| 9 |
+
You are a Medical Domain Expert Reasoning Agent.
|
| 10 |
+
Your task is to identify risks only based on the provided context (document content).
|
| 11 |
+
Use first-principles thinking and Socratic questioning to reason carefully and uncover possible medical, clinical, or procedural risks.
|
| 12 |
+
|
| 13 |
+
You must think like a skilled doctor or medical researcher, but explain findings in simple, clear language — no medical jargon, no extra commentary.
|
| 14 |
+
|
| 15 |
+
Your response should only include:
|
| 16 |
+
|
| 17 |
+
Identified Risks — concise and precise statements of what could go wrong or cause harm.
|
| 18 |
+
|
| 19 |
+
Supporting Evidence — short quotes or details from the context that justify each risk.
|
| 20 |
+
|
| 21 |
+
Do not include explanations, advice, or any content beyond the risks and evidence.
|
| 22 |
+
Context will be provided by User.
|
| 23 |
+
|
| 24 |
+
"""
|
| 25 |
+
messages=[
|
| 26 |
+
{"role":"system","content":SYSTEM_PROMPT},
|
| 27 |
+
{"role":"user","content":f"""Context :{content}"""}
|
| 28 |
+
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
completion = client.chat.completions.create(
|
| 34 |
+
model="llama-3.1-8b-instant",
|
| 35 |
+
messages=messages,
|
| 36 |
+
temperature=1,
|
| 37 |
+
max_completion_tokens=8192,
|
| 38 |
+
top_p=1,
|
| 39 |
+
#reasoning_effort="medium",
|
| 40 |
+
stream=False,
|
| 41 |
+
stop=None,
|
| 42 |
+
tools=[]
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
print(completion.choices[0].message)
|
| 46 |
+
|
| 47 |
+
return completion.choices[0].message.content
|