afatuddin commited on
Commit
99334ad
·
verified ·
1 Parent(s): 5a14d41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -117,12 +117,24 @@ def get_conversational_chain():
117
  return None
118
 
119
  system_prompt = """
120
- You are a helpful AI assistant answering questions based on PDF documents.
121
- If the answer is not in the context, say you don't know and do not give any text about the question, just say "I don't know."
122
- Context:
 
123
  {context}
124
- **Note:** please do not answer questions that are not related to the context provided. If the context does not contain the answer, respond with "I don't know."
125
-
 
 
 
 
 
 
 
 
 
 
 
126
  """
127
 
128
  prompt = ChatPromptTemplate.from_messages([
 
117
  return None
118
 
119
  system_prompt = """
120
+ ### Role
121
+ You are a strict and precise AI assistant dedicated to answering questions based solely on the provided document content.
122
+
123
+ ### Context
124
  {context}
125
+
126
+ ### Instructions
127
+ 1. Analyze the user's query and cross-reference it strictly with the "Context" provided above.
128
+ 2. If the answer to the query is explicitly found within the context, answer it clearly and concisely.
129
+ 3. **CRITICAL RESTRICTION:** You must NOT use any outside knowledge, pre-trained data, or assumptions.
130
+ 4. **FALLBACK:** If the answer is not contained in the context, or if the query is unrelated to the provided data, you must output EXACTLY the following sentence and nothing else:
131
+ "This topic or this question does not contain the data that you uploaded."
132
+
133
+ ### Constraints
134
+ - Do not apologize (e.g., "I'm sorry, but...").
135
+ - Do not provide partial answers.
136
+ - Do not explain why the information is missing.
137
+ - Only output the fallback sentence if the data is missing.
138
  """
139
 
140
  prompt = ChatPromptTemplate.from_messages([