Zeggai Abdellah commited on
Commit
85a458e
·
1 Parent(s): dc90437

update the system prompt

Browse files
Files changed (2) hide show
  1. prepare_env.py +35 -29
  2. rag_pipeline.py +2 -2
prepare_env.py CHANGED
@@ -310,22 +310,33 @@ def create_section_tools(embedding_function, llm):
310
  # General-purpose tool (entire Algerian guide)
311
  def guide_retrieval_tool(query: str) -> str:
312
  """
313
- General-purpose retrieval tool for the entire Algerian National Vaccination Guide (2023).
314
-
315
- Use ONLY when a query spans multiple unrelated sections or cannot be confidently routed
316
- to a more specific tool. This tool provides a fallback when the intent is ambiguous
317
- or multi-topic (e.g., combining schedule, cold chain, and public outreach in one query).
318
-
319
- Do NOT use this tool for clearly scoped questions related to vaccination schedules, disease profiles,
320
- vaccine logistics, or procedural workflows — use the specific section tools instead.
321
-
322
- Secondary source: WHO Immunization Guide (use `immunization_tool` when broader context is required).
 
 
 
 
 
 
 
 
 
 
 
323
 
324
  Args:
325
- query (str): A general, complex, or cross-sectional vaccination query.
326
 
327
  Returns:
328
- str: Synthesized answer from the entire national guide.
329
  """
330
  print(f"🏥 GUIDE TOOL CALLED: {query[:50]}...")
331
  if not guide_retriever:
@@ -339,13 +350,8 @@ def create_section_tools(embedding_function, llm):
339
 
340
  def immunization_tool(query: str) -> str:
341
  """
342
- WHO Immunization in Practice 2015 retrieval tool.
343
 
344
- Use ONLY when global guidance or procedural context is needed that is not covered or
345
- is unclear in the Algerian guide. This is a secondary reference for training standards,
346
- general immunization logistics, and vaccine delivery practices.
347
-
348
- Do NOT use this tool to answer country-specific policy or scheduling questions.
349
 
350
  Args:
351
  query (str): A question seeking global immunization practices.
@@ -366,7 +372,7 @@ def create_section_tools(embedding_function, llm):
366
  # Section-Specific Tools - Fixed implementation
367
  def section_one_tool(query: str) -> str:
368
  """
369
- Section 1: Programme Élargi de Vaccination (PEV)
370
 
371
  Use for queries about the national immunization program structure: its objectives,
372
  history, evaluation, and rationale for updates to the Algerian calendar.
@@ -391,7 +397,7 @@ def create_section_tools(embedding_function, llm):
391
 
392
  def section_two_tool(query: str) -> str:
393
  """
394
- Section 2: Maladies Ciblées
395
 
396
  Use ONLY for questions about the characteristics of vaccine-preventable diseases:
397
  symptoms, transmission, complications, and prevention.
@@ -416,7 +422,7 @@ def create_section_tools(embedding_function, llm):
416
 
417
  def section_three_tool(query: str) -> str:
418
  """
419
- Section 3: Vaccins du Calendrier
420
 
421
  Use ONLY for questions about the vaccines themselves: their types, compositions,
422
  methods of administration, and how they work.
@@ -441,7 +447,7 @@ def create_section_tools(embedding_function, llm):
441
 
442
  def section_four_tool(query: str) -> str:
443
  """
444
- Section 4: Rattrapage Vaccinal
445
 
446
  Use ONLY when the question involves missed or delayed vaccinations and how to reschedule them
447
  based on the child's current age.
@@ -466,7 +472,7 @@ def create_section_tools(embedding_function, llm):
466
 
467
  def section_five_tool(query: str) -> str:
468
  """
469
- Section 5: Populations Particulières
470
 
471
  Use ONLY for vaccination questions concerning special populations:
472
  preterm infants, immunosuppressed patients, chronic illness, or allergy conditions.
@@ -491,7 +497,7 @@ def create_section_tools(embedding_function, llm):
491
 
492
  def section_six_tool(query: str) -> str:
493
  """
494
- Section 6: Chaîne du Froid
495
 
496
  Use ONLY for questions about vaccine storage, transport, cold chain equipment,
497
  temperature monitoring, or cold chain failures.
@@ -515,8 +521,8 @@ def create_section_tools(embedding_function, llm):
515
  return f"Error accessing section 6: {str(e)}"
516
 
517
  def section_seven_tool(query: str) -> str:
518
- """
519
- Section 7: Sécurité des Injections
520
 
521
  Use ONLY for questions related to the safe administration of vaccines:
522
  equipment use, technique, safety precautions, and waste disposal.
@@ -541,7 +547,7 @@ def create_section_tools(embedding_function, llm):
541
 
542
  def section_eight_tool(query: str) -> str:
543
  """
544
- Section 8: Séance de Vaccination & Vaccinovigilance
545
 
546
  Use ONLY for questions about running a vaccination session, preparing the setting,
547
  recording injections, and monitoring for adverse events (AEFI).
@@ -566,7 +572,7 @@ def create_section_tools(embedding_function, llm):
566
 
567
  def section_nine_tool(query: str) -> str:
568
  """
569
- Section 9: Planification des Séances de Vaccination
570
 
571
  Use ONLY for planning and logistics questions: session scheduling, stock estimation,
572
  and operational preparation at the facility level.
@@ -591,7 +597,7 @@ def create_section_tools(embedding_function, llm):
591
 
592
  def section_ten_tool(query: str) -> str:
593
  """
594
- Section 10: Mobilisation Sociale
595
 
596
  Use ONLY for questions about communication strategies, overcoming vaccine hesitancy,
597
  rumor management, or community outreach.
 
310
  # General-purpose tool (entire Algerian guide)
311
  def guide_retrieval_tool(query: str) -> str:
312
  """
313
+ General-purpose retrieval tool that searches across the entire Algerian National Vaccination Guide (2023).
314
+ This tool is used to handle broad or ambiguous queries that may span multiple sections, or when no specific
315
+ section tool is confidently matched.
316
+
317
+ It can respond to questions covering all major topics in the guide, including:
318
+ - The national vaccination program (PEV)
319
+ - Targeted vaccine-preventable diseases
320
+ - Vaccine types and administration methods
321
+ - Catch-up vaccination schedules
322
+ - Vaccination of special populations (e.g., premature, immunocompromised)
323
+ - Cold chain logistics and storage protocols
324
+ - Injection safety practices
325
+ - Session planning and vaccine stock management
326
+ - Community mobilization and vaccine hesitancy
327
+ - Operational workflows and vaccinovigilance procedures
328
+
329
+ This tool provides coverage across Sections 1 to 10 and complements the section-specific tools.
330
+ It is especially useful when:
331
+ - A question involves content from multiple sections
332
+ - Tool routing is uncertain or ambiguous
333
+ - A complete or exploratory answer is needed from the full document
334
 
335
  Args:
336
+ query (str): A question related to any topic within the Algerian National Vaccination Guide.
337
 
338
  Returns:
339
+ str: A synthesized response generated from relevant content retrieved across all sections.
340
  """
341
  print(f"🏥 GUIDE TOOL CALLED: {query[:50]}...")
342
  if not guide_retriever:
 
350
 
351
  def immunization_tool(query: str) -> str:
352
  """
353
+ A comprehensive tool for querying global immunization practices, based on the 2015 WHO 'Immunization in Practice: A Practical Guide for Health Staff'. This tool provides detailed information on vaccine-preventable diseases (e.g., diphtheria, measles, polio, hepatitis B, Hib), vaccination schedules, cold chain management, safe injection practices, microplanning, immunization session management, monitoring, surveillance, and community engagement strategies. It is ideal for questions about global immunization programs, disease prevention, vaccine administration, and operational guidelines for health workers, with a focus on practical implementation at health facility and sub-national levels
354
 
 
 
 
 
 
355
 
356
  Args:
357
  query (str): A question seeking global immunization practices.
 
372
  # Section-Specific Tools - Fixed implementation
373
  def section_one_tool(query: str) -> str:
374
  """
375
+ Section 1: Programme Élargi de Vaccination (PEV) from the Algerian National Vaccination Guide
376
 
377
  Use for queries about the national immunization program structure: its objectives,
378
  history, evaluation, and rationale for updates to the Algerian calendar.
 
397
 
398
  def section_two_tool(query: str) -> str:
399
  """
400
+ Section 2: Maladies Ciblées from the Algerian National Vaccination Guide
401
 
402
  Use ONLY for questions about the characteristics of vaccine-preventable diseases:
403
  symptoms, transmission, complications, and prevention.
 
422
 
423
  def section_three_tool(query: str) -> str:
424
  """
425
+ Section 3: Vaccins du Calendrier from the Algerian National Vaccination Guide
426
 
427
  Use ONLY for questions about the vaccines themselves: their types, compositions,
428
  methods of administration, and how they work.
 
447
 
448
  def section_four_tool(query: str) -> str:
449
  """
450
+ Section 4: Rattrapage Vaccinal from the Algerian National Vaccination Guide
451
 
452
  Use ONLY when the question involves missed or delayed vaccinations and how to reschedule them
453
  based on the child's current age.
 
472
 
473
  def section_five_tool(query: str) -> str:
474
  """
475
+ Section 5: Populations Particulières from the Algerian National Vaccination Guide
476
 
477
  Use ONLY for vaccination questions concerning special populations:
478
  preterm infants, immunosuppressed patients, chronic illness, or allergy conditions.
 
497
 
498
  def section_six_tool(query: str) -> str:
499
  """
500
+ Section 6: Chaîne du Froid from the Algerian National Vaccination Guide
501
 
502
  Use ONLY for questions about vaccine storage, transport, cold chain equipment,
503
  temperature monitoring, or cold chain failures.
 
521
  return f"Error accessing section 6: {str(e)}"
522
 
523
  def section_seven_tool(query: str) -> str:
524
+ """
525
+ Section 7: Sécurité des Injections from the Algerian National Vaccination Guide
526
 
527
  Use ONLY for questions related to the safe administration of vaccines:
528
  equipment use, technique, safety precautions, and waste disposal.
 
547
 
548
  def section_eight_tool(query: str) -> str:
549
  """
550
+ Section 8: Séance de Vaccination & Vaccinovigilance from the Algerian National Vaccination Guide
551
 
552
  Use ONLY for questions about running a vaccination session, preparing the setting,
553
  recording injections, and monitoring for adverse events (AEFI).
 
572
 
573
  def section_nine_tool(query: str) -> str:
574
  """
575
+ Section 9: Planification des Séances de Vaccination from the Algerian National Vaccination Guide
576
 
577
  Use ONLY for planning and logistics questions: session scheduling, stock estimation,
578
  and operational preparation at the facility level.
 
597
 
598
  def section_ten_tool(query: str) -> str:
599
  """
600
+ Section 10: Mobilisation Sociale from the Algerian National Vaccination Guide
601
 
602
  Use ONLY for questions about communication strategies, overcoming vaccine hesitancy,
603
  rumor management, or community outreach.
rag_pipeline.py CHANGED
@@ -116,7 +116,7 @@ def create_safe_custom_prompt(tools, llm, is_fallback=False):
116
  if is_fallback:
117
  custom_instructions = """
118
  ## MEDICAL ASSISTANT ROLE - FALLBACK MODE
119
- You are a helpful and knowledgeable AI-powered vaccine assistant designed to support doctors in clinical decision-making.
120
  You are operating in FALLBACK MODE with access to only the most essential and comprehensive tools.
121
  You provide evidence-based guidance using only information from official vaccine medical documents.
122
  Answer the doctor's question accurately and concisely using only the provided information.
@@ -147,7 +147,7 @@ Answer the doctor's question accurately and concisely using only the provided in
147
  else:
148
  custom_instructions = """
149
  ## MEDICAL ASSISTANT ROLE
150
- You are a helpful and knowledgeable AI-powered vaccine assistant designed to support doctors in clinical decision-making.
151
  You provide evidence-based guidance using only information from official vaccine medical documents.
152
  Answer the doctor's question accurately and concisely using only the provided information.
153
 
 
116
  if is_fallback:
117
  custom_instructions = """
118
  ## MEDICAL ASSISTANT ROLE - FALLBACK MODE
119
+ You are a helpful and knowledgeable AI-powered vaccine assistant designed to support the Algerian doctors in clinical decision-making.
120
  You are operating in FALLBACK MODE with access to only the most essential and comprehensive tools.
121
  You provide evidence-based guidance using only information from official vaccine medical documents.
122
  Answer the doctor's question accurately and concisely using only the provided information.
 
147
  else:
148
  custom_instructions = """
149
  ## MEDICAL ASSISTANT ROLE
150
+ You are a helpful and knowledgeable AI-powered vaccine assistant designed to support the Algerian doctors in clinical decision-making.
151
  You provide evidence-based guidance using only information from official vaccine medical documents.
152
  Answer the doctor's question accurately and concisely using only the provided information.
153