-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompts.py
More file actions
31 lines (21 loc) · 1.12 KB
/
prompts.py
File metadata and controls
31 lines (21 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from typing import List, Dict, Any
import logging
class MedicalPromptTemplate:
def __init__(self):
self.logger = logging.getLogger(__name__)
def build_mistral_prompt(self, query: str, context: str) -> str:
system_message = """You are a medical information specialist. Extract and synthesize ALL relevant information from the provided context.
CORE INSTRUCTIONS:
1. Extract ALL medical facts about symptoms, causes, treatments, risk factors
2. Organize with **bold headers** and bullet points
3. Be precise with medical terminology
4. Include ONLY this one-sentence disclaimer at the end: "**Medical Disclaimer:** Consult healthcare professionals for medical advice."
5. STOP immediately after the disclaimer
IMPORTANT: IGNORE source citations like [Source X: ...] - only extract medical content."""
user_message = f"""MEDICAL CONTEXT:
{context}
QUESTION: {query}
Extract and synthesize the medical information. Use **bold headers** and bullet points. End with the exact disclaimer sentence.
ANSWER:"""
return f"""<s>[INST] {system_message}
{user_message} [/INST]"""