Spaces:
Sleeping
Sleeping
Zeggai Abdellah
commited on
Commit
·
a738e04
1
Parent(s):
8bdf6ea
add WHO rule
Browse files- rag_pipeline.py +7 -8
rag_pipeline.py
CHANGED
|
@@ -154,12 +154,12 @@ Answer the doctor's question accurately and concisely using only the provided in
|
|
| 154 |
|
| 155 |
### Response Guidelines
|
| 156 |
- Start with the most relevant tool for the question
|
| 157 |
-
- If the
|
|
|
|
| 158 |
- Provide whatever information you find with proper citations using Source IDs only
|
| 159 |
- If information is limited, clearly state what is and isn't available in the documents
|
| 160 |
|
| 161 |
---
|
| 162 |
-
|
| 163 |
"""
|
| 164 |
else:
|
| 165 |
custom_instructions = """
|
|
@@ -189,10 +189,11 @@ Answer the doctor's question accurately and concisely using only the provided in
|
|
| 189 |
|
| 190 |
### CRITICAL: Efficient Response Strategy
|
| 191 |
1. **SEARCH FIRST**: Before doing anything else, use the available tools to search for relevant information about the question.
|
| 192 |
-
2. **
|
| 193 |
-
3. **
|
| 194 |
-
4. **
|
| 195 |
-
5. **
|
|
|
|
| 196 |
|
| 197 |
### Response Guidelines for Complex Questions
|
| 198 |
- For comparative questions: Search once for each topic, then provide the comparison based on found information
|
|
@@ -208,7 +209,6 @@ If you cannot find complete information to fully answer a question:
|
|
| 208 |
4. Do not continue searching or reasoning beyond what is necessary
|
| 209 |
|
| 210 |
---
|
| 211 |
-
|
| 212 |
"""
|
| 213 |
|
| 214 |
# Get the exact original template first
|
|
@@ -235,7 +235,6 @@ If you cannot find complete information to fully answer a question:
|
|
| 235 |
print(f"[LOG] ⚠️ Using fallback prompt template for {'fallback' if is_fallback else 'standard'} agent")
|
| 236 |
return PromptTemplate(template=safe_template)
|
| 237 |
|
| 238 |
-
|
| 239 |
def create_agent(tools, llm, is_fallback=False):
|
| 240 |
"""Create the ReAct agent with custom prompt"""
|
| 241 |
|
|
|
|
| 154 |
|
| 155 |
### Response Guidelines
|
| 156 |
- Start with the most relevant tool for the question
|
| 157 |
+
- **WHO-Specific Rule**: If the query contains keywords like "WHO," "World Health Organization," "international," "global guidance," or references to WHO documents (e.g., page numbers), use the Immunization_in_Practice_tool first to retrieve WHO-specific information.
|
| 158 |
+
- If the question requires both Algerian-specific and global context, use both Guide_vector_tool and Immunization_in_Practice_tool once each
|
| 159 |
- Provide whatever information you find with proper citations using Source IDs only
|
| 160 |
- If information is limited, clearly state what is and isn't available in the documents
|
| 161 |
|
| 162 |
---
|
|
|
|
| 163 |
"""
|
| 164 |
else:
|
| 165 |
custom_instructions = """
|
|
|
|
| 189 |
|
| 190 |
### CRITICAL: Efficient Response Strategy
|
| 191 |
1. **SEARCH FIRST**: Before doing anything else, use the available tools to search for relevant information about the question.
|
| 192 |
+
2. **WHO-Specific Rule**: If the query contains keywords like "WHO," "World Health Organization," " international," "global guidance," or references to WHO documents (e.g., page numbers), use the Immunization_in_Practice_tool first to retrieve WHO-specific information, even if other tools might also apply.
|
| 193 |
+
3. **BE DECISIVE**: Once you find relevant information, formulate your response immediately. Do not search repeatedly for the same information.
|
| 194 |
+
4. **ANSWER DIRECTLY**: Provide a clear, direct answer based on the information found. Do not overthink or search for additional sources unless absolutely necessary.
|
| 195 |
+
5. **STOP WHEN SUFFICIENT**: If you have found adequate information to answer the question, provide the response and stop. Do not continue searching for more sources.
|
| 196 |
+
6. **PARTIAL ANSWERS ARE ACCEPTABLE**: If you can only partially answer a question with the available information, provide what you can find and clearly state what information is not available in the documents.
|
| 197 |
|
| 198 |
### Response Guidelines for Complex Questions
|
| 199 |
- For comparative questions: Search once for each topic, then provide the comparison based on found information
|
|
|
|
| 209 |
4. Do not continue searching or reasoning beyond what is necessary
|
| 210 |
|
| 211 |
---
|
|
|
|
| 212 |
"""
|
| 213 |
|
| 214 |
# Get the exact original template first
|
|
|
|
| 235 |
print(f"[LOG] ⚠️ Using fallback prompt template for {'fallback' if is_fallback else 'standard'} agent")
|
| 236 |
return PromptTemplate(template=safe_template)
|
| 237 |
|
|
|
|
| 238 |
def create_agent(tools, llm, is_fallback=False):
|
| 239 |
"""Create the ReAct agent with custom prompt"""
|
| 240 |
|