Spaces:
Running
Running
Asish Karthikeya Gogineni commited on
Commit ·
28ec44b
1
Parent(s): 7579835
fix: Add strict anti-hallucination rules to prompts
Browse files- LLM must now say 'I couldn't find code related to [topic]' when context lacks relevant code
- Prohibits making up generic explanations
- Prohibits inventing file paths or function names
- Ensures honest 'I don't know' responses instead of hallucination
- code_chatbot/prompts.py +14 -0
code_chatbot/prompts.py
CHANGED
|
@@ -130,6 +130,15 @@ When users ask to "add", "implement", or "create" features:
|
|
| 130 |
2. **NO UI MIMICRY**: Do NOT attempt to recreate UI elements like "source chips", buttons, or widgets.
|
| 131 |
3. **NO HALLUCINATION**: Only cite files that actually exist in the retrieved context.
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
Remember: You're not just answering questions - you're helping developers deeply understand and confidently modify their codebase.
|
| 134 |
"""
|
| 135 |
|
|
@@ -195,6 +204,11 @@ Provide your answer in well-structured markdown that a developer can immediately
|
|
| 195 |
**CRITICAL RULES:**
|
| 196 |
- **NO HTML**: Do NOT generate HTML tags. Use ONLY standard Markdown.
|
| 197 |
- **NO UI MIMICRY**: Do NOT try to create "source chips" or other UI elements.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
"""
|
| 199 |
|
| 200 |
QUERY_EXPANSION_PROMPT = """Given a user question about a codebase, generate 3-5 diverse search queries optimized for semantic code search.
|
|
|
|
| 130 |
2. **NO UI MIMICRY**: Do NOT attempt to recreate UI elements like "source chips", buttons, or widgets.
|
| 131 |
3. **NO HALLUCINATION**: Only cite files that actually exist in the retrieved context.
|
| 132 |
|
| 133 |
+
**NEVER HALLUCINATE - THIS IS CRITICAL:**
|
| 134 |
+
- If the retrieved code does NOT contain information about the user's question, you MUST say:
|
| 135 |
+
"I searched the codebase but couldn't find code related to [topic]. The codebase may not have this feature implemented, or it may be named differently. Would you like me to search for something specific?"
|
| 136 |
+
- DO NOT make up generic explanations about how something "typically" works
|
| 137 |
+
- DO NOT invent file paths, function names, or code that doesn't exist in the retrieved context
|
| 138 |
+
- DO NOT describe general programming concepts as if they exist in this specific codebase
|
| 139 |
+
- ONLY describe code that you have ACTUALLY seen in the retrieved context
|
| 140 |
+
- If unsure, ASK the user to clarify what they're looking for
|
| 141 |
+
|
| 142 |
Remember: You're not just answering questions - you're helping developers deeply understand and confidently modify their codebase.
|
| 143 |
"""
|
| 144 |
|
|
|
|
| 204 |
**CRITICAL RULES:**
|
| 205 |
- **NO HTML**: Do NOT generate HTML tags. Use ONLY standard Markdown.
|
| 206 |
- **NO UI MIMICRY**: Do NOT try to create "source chips" or other UI elements.
|
| 207 |
+
- **NO HALLUCINATION**: ONLY discuss code that appears in the retrieved context above.
|
| 208 |
+
- If the context does NOT contain relevant code, say: "I couldn't find code related to [topic] in the retrieved context. The codebase may not have this feature, or try asking about specific files or functions."
|
| 209 |
+
- DO NOT make up generic explanations or describe how things "typically" work
|
| 210 |
+
- DO NOT invent file paths, function names, or code
|
| 211 |
+
- Be honest: if you don't see it in the context, don't pretend it exists
|
| 212 |
"""
|
| 213 |
|
| 214 |
QUERY_EXPANSION_PROMPT = """Given a user question about a codebase, generate 3-5 diverse search queries optimized for semantic code search.
|