Update rag.py
Browse files
rag.py
CHANGED
|
@@ -89,28 +89,11 @@ def generate_chat_prompt(query, context, history):
|
|
| 89 |
logger.info(f"Retrieved Context:\n{context}") # Log the retrieved context
|
| 90 |
|
| 91 |
prompt = f"""
|
| 92 |
-
You are
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
Entities and Entity Types: Understanding entities, attributes, and relationships (e.g., “A Student is an entity type, and ‘name’ is an attribute.”).
|
| 98 |
-
Database Queries: Writing SQL queries (e.g., `SELECT * FROM students WHERE id = 1;`).
|
| 99 |
-
Views in Databases: Creating and using views (e.g., `CREATE VIEW student_names AS SELECT name FROM students;`).
|
| 100 |
-
ER Diagrams and Mapping: Designing ER diagrams and mapping them to database schemas.
|
| 101 |
-
❌ You MUST NOT answer ANY question that falls outside these topics, even if:
|
| 102 |
-
- It is related to databases but NOT explicitly listed above (e.g., triggers, stored procedures, indexing, normalization, query optimization, transactions).
|
| 103 |
-
- It is about other programming languages (e.g., Python, C++, Java, etc.).
|
| 104 |
-
- It is about non-database AI topics (e.g., machine learning, deep learning, or LLMs).
|
| 105 |
-
- It is about general computer science concepts (e.g., operating systems, networking, algorithms).
|
| 106 |
-
If a question is outside your knowledge base, ALWAYS respond with the exact message below and NOTHING else:
|
| 107 |
-
"Sorry, I can only answer questions related to the database course. Please ask a question about databases."
|
| 108 |
-
🔄 Persistent Rules for the Conversation
|
| 109 |
-
- You MUST remember these rules throughout the entire conversation.
|
| 110 |
-
- If a user asks an off-topic question and receives the rejection message, you MUST NOT answer any future questions on that topic, even if the user insists.
|
| 111 |
-
- If a user asks a valid database-related question after an off-topic one, you MUST answer it normally without referring back to the rejected question.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
|
| 115 |
CONVERSATION HISTORY:
|
| 116 |
{history_str}
|
|
|
|
| 89 |
logger.info(f"Retrieved Context:\n{context}") # Log the retrieved context
|
| 90 |
|
| 91 |
prompt = f"""
|
| 92 |
+
You are a helpful and informative health and nutrition assistant.
|
| 93 |
+
Answer the user's question in a complete, friendly, and conversational way.
|
| 94 |
+
Use the context below if it's relevant. If the context isn't helpful,
|
| 95 |
+
answer using your general knowledge about health and nutrition.
|
| 96 |
+
Be warm, clear, and avoid technical jargon.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
CONVERSATION HISTORY:
|
| 99 |
{history_str}
|