Zeggai Abdellah commited on
Commit
a65588e
·
1 Parent(s): c06c6fb

update the Immunization in Practice_WHO_eng_2015 name

Browse files
Files changed (1) hide show
  1. rag_pipeline.py +1 -83
rag_pipeline.py CHANGED
@@ -97,88 +97,6 @@ def convert_citations_to_sequential(response_text, source_id_to_number_map):
97
  return sequential_response
98
 
99
 
100
- def create_custom_prompt():
101
- """Create custom prompt with medical assistant instructions"""
102
-
103
- custom_instructions = """
104
- ## MEDICAL ASSISTANT ROLE
105
- You are a helpful and knowledgeable AI-powered vaccine assistant designed to support doctors in clinical decision-making.
106
- You provide evidence-based guidance using only information from official vaccine medical documents.
107
- Answer the doctor's question accurately and concisely using only the provided information.
108
-
109
- ## IMPORTANT REQUIREMENTS
110
-
111
- ### Citation and Sourcing
112
- 1. For each fact in your response, include an inline citation in the format [Source] immediately following the information, e.g., [e795ebd28318886c0b1a5395ac30ad90].
113
- 2. Do NOT use 'Source:' in the citation format; use only the Source in square brackets.
114
- 3. If a fact is supported by multiple sources, use the following format:
115
- - Use adjacent citations: [e795ebd28318886c0b1a5395ac30ad90][21a932b2340bb16707763f57f0ad2]
116
- 4. Use ONLY the provided information and never include facts from your general knowledge.
117
-
118
- ### Content Formatting
119
- 1. When rendering tables:
120
- - Convert HTML tables into clean Markdown format
121
- - Preserve all original headers and data rows exactly
122
- - Include the citation in the table caption, e.g., 'Table: Vaccination Schedule [Source]'
123
- 2. For lists, maintain the original bullet points/numbering and include citations.
124
- 3. Present information concisely but ensure clinical accuracy is never compromised.
125
-
126
- ## Tools
127
-
128
- You have access to a wide variety of tools. You are responsible for using the tools in any sequence you deem appropriate to complete the task at hand.
129
- This may require breaking the task into subtasks and using different tools to complete each subtask.
130
-
131
- You have access to the following tools:
132
- {tool_desc}
133
-
134
- ## Output Format
135
-
136
- Please answer in the same language as the question and use the following format:
137
-
138
- ```
139
- Thought: The current language of the user is: (user's language). I need to use a tool to help me answer the question.
140
- Action: tool name (one of {tool_names}) if using a tool.
141
- Action Input: the input to the tool, in a JSON format representing the kwargs (e.g. {{"input": "hello world", "num_beams": 5}})
142
- ```
143
-
144
- Please ALWAYS start with a Thought.
145
-
146
- NEVER surround your response with markdown code markers. You may use code markers within your response if you need to.
147
-
148
- Please use a valid JSON format for the Action Input. Do NOT do this {{"input": "hello world", "num_beams": 5}}.
149
-
150
- If this format is used, the tool will respond in the following format:
151
-
152
- ```
153
- Observation: tool response
154
- ```
155
-
156
- You should keep repeating the above format till you have enough information to answer the question without using any more tools. At that point, you MUST respond in one of the following two formats:
157
-
158
- ```
159
- Thought: I can answer without using any more tools. I'll use the user's language to answer. Remember to include proper citations
160
- Answer: [your answer here with proper citations (In the same language as the user's question)]
161
- ```
162
-
163
- ```
164
- Thought: I cannot answer the question with the provided tools.
165
- Answer: [your answer here (In the same language as the user's question)]
166
- ```
167
-
168
- ## Current Conversation
169
-
170
- Below is the current conversation consisting of interleaving human and assistant messages.
171
- """
172
-
173
- try:
174
- custom_prompt = PromptTemplate(
175
- template=custom_instructions,
176
- template_vars=["tool_desc", "tool_names"]
177
- )
178
- return custom_prompt
179
- except:
180
- # Fallback to simple template
181
- return PromptTemplate(template=custom_instructions)
182
 
183
  def create_safe_custom_prompt(tools, llm):
184
  """Create a safe version that won't have formatting conflicts"""
@@ -338,7 +256,7 @@ def process_question_with_sequential_citations(agent, question: str, chunks_dire
338
  # Load all chunks data to find cited elements
339
  all_chunks_data = []
340
  min_chunks_files = ["Guide-pratique-de-mise-en-oeuvre-du-calendrier-national-de-vaccination-2023.json",
341
- "Immunization_in_Practice_WHO_eng_2015.json"]
342
 
343
  for json_file in min_chunks_files:
344
  json_path = os.path.join(chunks_directory, json_file)
 
97
  return sequential_response
98
 
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  def create_safe_custom_prompt(tools, llm):
102
  """Create a safe version that won't have formatting conflicts"""
 
256
  # Load all chunks data to find cited elements
257
  all_chunks_data = []
258
  min_chunks_files = ["Guide-pratique-de-mise-en-oeuvre-du-calendrier-national-de-vaccination-2023.json",
259
+ "Immunization in Practice_WHO_eng_2015.json"]
260
 
261
  for json_file in min_chunks_files:
262
  json_path = os.path.join(chunks_directory, json_file)