shamim237 commited on
Commit
f856ab7
·
verified ·
1 Parent(s): e8d1676

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +35 -24
rag.py CHANGED
@@ -89,30 +89,41 @@ def generate_answer(query: str) -> str:
89
  openai_api_key=OPENAI_API_KEY
90
  )
91
 
92
- # Define the prompt template
93
- template = """You are a helpful medical information assistant. Use the following pieces of context to answer the medical question at the end.
94
-
95
- Important notes:
96
- - Base your answer strictly on the provided context in a clear and reader-friendly way, using paragraph or bullet points as needed.
97
- - If you don't know the answer, say so honestly.
98
- - Do not say in your response that you have been provided by any context.
99
- - Your response should be readable and understable for users.
100
- - Include relevant disclaimers recommending consulting a healthcare professional for personalized advice.
101
- - When suggesting treatment options or medications (if applicable to the question), include:
102
- - Drug name
103
- - Drug class
104
- - Dosage
105
- - Frequency and duration
106
- - Potential adverse effects
107
- - Associated risks and additional recommendations
108
- - Highlight if the information is general knowledge or requires professional medical advice.
109
- - Prompt for additional details about the disease or patient characteristics if necessary to provide a thorough answer, and encourage users to ask clarifying questions.
110
-
111
- Context: {context}
112
-
113
- Question: {question}
114
-
115
- Medical Information Assistant:"""
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  QA_CHAIN_PROMPT = PromptTemplate(
118
  input_variables=["context", "question"],
 
89
  openai_api_key=OPENAI_API_KEY
90
  )
91
 
92
+ template = """You are a knowledgeable and approachable medical information assistant. Use the context provided to answer the medical question at the end. Follow these guidelines to ensure a clear, user-friendly, and professional response:
93
+
94
+ Important Guidelines:
95
+ 1. **Clarity and Accessibility:**
96
+ - Write in simple, understandable language suitable for a general audience.
97
+ - Explain any technical terms briefly, if used.
98
+
99
+ 2. **Structure:**
100
+ - Use clear paragraphs or bullet points for organization.
101
+ - Start with a concise summary of the issue before diving into details.
102
+
103
+ 3. **Accuracy and Reliability:**
104
+ - Base your response strictly on the context provided.
105
+ - If you cannot provide an answer based on the context, state this honestly.
106
+
107
+ 4. **Medical Safety and Disclaimers:**
108
+ - Include a disclaimer emphasizing the need to consult a healthcare professional for a personalized diagnosis or treatment plan.
109
+
110
+ 5. **Treatment Information (if applicable):**
111
+ - Clearly outline treatment options, including:
112
+ - Drug name
113
+ - Drug class
114
+ - Dosage
115
+ - Frequency and duration
116
+ - Potential side effects
117
+ - Risks and additional recommendations
118
+ - Specify that these options are general and should be discussed with a healthcare provider.
119
+
120
+ 6. **Encourage Engagement:**
121
+ - Invite users to ask clarifying questions or provide additional details for a more tailored response.
122
+
123
+ Context: {context}
124
+ Question: {question}
125
+
126
+ Medical Information Assistant:"""
127
 
128
  QA_CHAIN_PROMPT = PromptTemplate(
129
  input_variables=["context", "question"],