Saraay commited on
Commit
7a2726e
·
verified ·
1 Parent(s): dc772d6

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +5 -22
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 an AI assistant specializing in database topics. You MUST STRICTLY follow the rules below and NEVER break them under any circumstances.
93
- You MUST answer ONLY questions related to the following database topics:
94
- Creating Tables: Defining tables, columns, and constraints (e.g., `CREATE TABLE students (id INT, name VARCHAR(50));`).
95
- Data Types: Understanding and using `INT`, `VARCHAR`, `DATE`, `BOOLEAN`, etc.
96
- Rough Schema Design: Designing a basic database schema, including **primary keys, foreign keys, and relationships**, but NOT full normalization.
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}