@@ -1435,7 +1435,8 @@ def build_minimal_philosophical_prompt(
14351435 language: str,
14361436 detected_lang_name: str,
14371437 context: Optional[Dict[str, Any]] = None,
1438- validation_info: Optional[Dict[str, Any]] = None
1438+ validation_info: Optional[Dict[str, Any]] = None,
1439+ knowledge_gap_instruction: str = ""
14391440) -> str:
14401441 """
14411442 Build a minimal prompt for philosophical questions when context overflow occurs.
@@ -2236,10 +2237,13 @@ def build_philosophical_lead_in(question: str) -> str:
22362237"""
22372238
22382239 # Build minimal prompt
2240+ # CRITICAL: Inject knowledge_gap_instruction if provided (has higher priority than other instructions)
22392241 minimal_prompt = f"""{language_instruction}
22402242
22412243{short_identity}
22422244
2245+ {knowledge_gap_instruction if knowledge_gap_instruction else ""}
2246+
22432247{stillme_technical_instruction}
22442248
22452249{rag_context_section}
@@ -7474,7 +7478,8 @@ def estimate_tokens_safe(text: str) -> int:
74747478 language=detected_lang,
74757479 detected_lang_name=detected_lang_name,
74767480 context=context, # Pass context to include retrieved documents info
7477- validation_info=None # Validation hasn't run yet, but will be included if available
7481+ validation_info=None, # Validation hasn't run yet, but will be included if available
7482+ knowledge_gap_instruction=knowledge_gap_instruction # CRITICAL: Pass knowledge_gap_instruction for Knowledge Gap questions
74787483 )
74797484 logger.info(f"🔄 Using minimal philosophical prompt (pre-check prevention)")
74807485 enhanced_prompt = minimal_prompt
@@ -7665,7 +7670,8 @@ def estimate_tokens_safe(text: str) -> int:
76657670 language=detected_lang,
76667671 detected_lang_name=detected_lang_name,
76677672 context=context, # Pass context to include retrieved documents info
7668- validation_info=None # Validation hasn't run yet in retry path
7673+ validation_info=None, # Validation hasn't run yet in retry path
7674+ knowledge_gap_instruction=knowledge_gap_instruction # CRITICAL: Pass knowledge_gap_instruction for Knowledge Gap questions
76697675 )
76707676
76717677 logger.info(f"🔄 Retrying with minimal philosophical prompt (no history, no RAG, no metrics, no provenance)")
@@ -8882,12 +8888,90 @@ def estimate_tokens(text: str) -> int:
88828888 # For philosophical questions, use minimal prompt
88838889 logger.info("🔄 Retrying with minimal philosophical prompt...")
88848890 # Non-RAG path: no context available, but still pass None for consistency
8891+ # CRITICAL: Create knowledge_gap_instruction for non-RAG path if needed
8892+ knowledge_gap_instruction_non_rag = ""
8893+ if is_knowledge_gap_query:
8894+ if detected_lang == "vi":
8895+ knowledge_gap_instruction_non_rag = """
8896+ 🚨🚨🚨 CRITICAL: KNOWLEDGE GAP QUESTION - EPISTEMIC AWARENESS REQUIRED 🚨🚨🚨
8897+
8898+ **MANDATORY: RESPOND WITH PHILOSOPHICAL DEPTH AND SPECIFICITY**
8899+
8900+ Câu hỏi này yêu cầu bạn chỉ ra một "vùng tối tri thức" (Knowledge Gap) cụ thể. Đây KHÔNG phải là câu hỏi đơn giản.
8901+
8902+ **CRITICAL RULES - YOU MUST FOLLOW:**
8903+
8904+ 1. **DO NOT use "lấp đầy" (fill) concept**:
8905+ - ❌ WRONG: "chưa có dữ liệu để lấp đầy" - tri thức không phải container để "lấp đầy"
8906+ - ❌ WRONG: "cần bổ sung thông tin" - ngụ ý có thể "hoàn thiện" tri thức
8907+ - ✅ CORRECT: "vùng tri thức mà hệ thống chưa có dữ liệu" hoặc "lĩnh vực mà hệ thống chưa được tiếp cận"
8908+
8909+ 2. **MUST identify SPECIFIC gaps, not generic statements**:
8910+ - ❌ WRONG: "vẫn tồn tại một 'vùng tối tri thức'" (quá chung chung)
8911+ - ✅ CORRECT: "Một vùng tối tri thức cụ thể mà mình nhận diện được là: [specific topic/domain]"
8912+ - ✅ CORRECT: Phải chỉ ra ví dụ cụ thể, không chỉ nói chung chung
8913+
8914+ 3. **MUST acknowledge epistemic limits**:
8915+ - Tri thức là vô hạn - không thể "lấp đầy" hoàn toàn
8916+ - Phân biệt "không biết" (temporary gap) vs "không thể biết" (fundamental limit)
8917+ - Acknowledge rằng AI có giới hạn nhận thức cố hữu
8918+
8919+ 4. **MUST have philosophical depth**:
8920+ - Không chỉ liệt kê gap, mà phải phân tích tại sao gap này tồn tại
8921+ - Phân tích về bản chất của tri thức và giới hạn của AI
8922+ - Acknowledge rằng một số gaps có thể là fundamental limits, không phải temporary
8923+
8924+ **ABSOLUTELY FORBIDDEN:**
8925+ - ❌ Dùng khái niệm "lấp đầy" tri thức
8926+ - ❌ Trả lời chung chung không chỉ ra gap cụ thể
8927+ - ❌ Không acknowledge epistemic limits
8928+ - ❌ Ngụ ý có thể "hoàn thiện" tri thức
8929+
8930+ """
8931+ else:
8932+ knowledge_gap_instruction_non_rag = """
8933+ 🚨🚨🚨 CRITICAL: KNOWLEDGE GAP QUESTION - EPISTEMIC AWARENESS REQUIRED 🚨🚨🚨
8934+
8935+ **MANDATORY: RESPOND WITH PHILOSOPHICAL DEPTH AND SPECIFICITY**
8936+
8937+ This question asks you to identify a specific "Knowledge Gap". This is NOT a simple question.
8938+
8939+ **CRITICAL RULES - YOU MUST FOLLOW:**
8940+
8941+ 1. **DO NOT use "fill" concept**:
8942+ - ❌ WRONG: "no data to fill" - knowledge is not a container to "fill"
8943+ - ❌ WRONG: "need to supplement information" - implies knowledge can be "completed"
8944+ - ✅ CORRECT: "knowledge domain that the system doesn't have data for" or "area that the system hasn't accessed"
8945+
8946+ 2. **MUST identify SPECIFIC gaps, not generic statements**:
8947+ - ❌ WRONG: "there still exists a 'knowledge dark zone'" (too generic)
8948+ - ✅ CORRECT: "A specific knowledge gap I've identified is: [specific topic/domain]"
8949+ - ✅ CORRECT: Must provide concrete examples, not just generic statements
8950+
8951+ 3. **MUST acknowledge epistemic limits**:
8952+ - Knowledge is infinite - cannot be "filled" completely
8953+ - Distinguish "don't know" (temporary gap) vs "cannot know" (fundamental limit)
8954+ - Acknowledge that AI has inherent cognitive limits
8955+
8956+ 4. **MUST have philosophical depth**:
8957+ - Not just list gap, but analyze why this gap exists
8958+ - Analyze the nature of knowledge and AI's limits
8959+ - Acknowledge that some gaps may be fundamental limits, not temporary
8960+
8961+ **ABSOLUTELY FORBIDDEN:**
8962+ - ❌ Use "fill" knowledge concept
8963+ - ❌ Generic response without specific gap
8964+ - ❌ Not acknowledging epistemic limits
8965+ - ❌ Implying knowledge can be "completed"
8966+
8967+ """
88858968 minimal_prompt = build_minimal_philosophical_prompt(
88868969 user_question=chat_request.message,
88878970 language=detected_lang,
88888971 detected_lang_name=detected_lang_name,
88898972 context=None, # Non-RAG path: no context available
8890- validation_info=None # Validation hasn't run yet
8973+ validation_info=None, # Validation hasn't run yet
8974+ knowledge_gap_instruction=knowledge_gap_instruction_non_rag # CRITICAL: Pass knowledge_gap_instruction for Knowledge Gap questions
88918975 )
88928976 try:
88938977 response = await generate_ai_response(
0 commit comments