Update src/qa.py
Browse files
src/qa.py
CHANGED
|
@@ -182,29 +182,28 @@ def cache_embeddings(file_name: str, chunks, embed_func, chunk_size: int = None,
|
|
| 182 |
return embeddings
|
| 183 |
|
| 184 |
# ==========================================================
|
| 185 |
-
# 6️⃣ Prompt Templates (
|
| 186 |
# ==========================================================
|
|
|
|
| 187 |
STRICT_PROMPT = (
|
| 188 |
"You are an enterprise documentation assistant.\n"
|
| 189 |
"Use all relevant information from the CONTEXT below.\n"
|
| 190 |
-
"
|
| 191 |
-
"
|
| 192 |
-
"
|
| 193 |
-
"
|
| 194 |
-
"'the document' or quote the excerpt directly.\n"
|
| 195 |
"If the answer cannot be found even after considering all chunks, say exactly:\n"
|
| 196 |
"'I don't know based on the provided document.'\n\n"
|
| 197 |
"Context:\n{context}\n\nQuestion: {query}\nAnswer:"
|
| 198 |
)
|
| 199 |
|
|
|
|
| 200 |
REASONING_PROMPT = (
|
| 201 |
"You are an expert enterprise assistant capable of reasoning.\n"
|
| 202 |
"Think step by step and synthesize information even if scattered across chunks.\n"
|
| 203 |
"Base your answer primarily on the CONTEXT, but if multiple partial clues exist, combine them logically.\n"
|
| 204 |
"You may fill reasonable gaps with general knowledge to form a complete answer.\n"
|
| 205 |
-
"Do
|
| 206 |
-
"(for example, do NOT say 'Chunk 7' or 'chunk 3:'). If you need to reference source text, say 'the document' "
|
| 207 |
-
"or provide a short quoted excerpt.\n"
|
| 208 |
"If absolutely nothing in the document relates, say exactly:\n"
|
| 209 |
"'I don't know based on the provided document.'\n\n"
|
| 210 |
"Context:\n{context}\n\nQuestion: {query}\nLet's reason step-by-step:\nAnswer:"
|
|
|
|
| 182 |
return embeddings
|
| 183 |
|
| 184 |
# ==========================================================
|
| 185 |
+
# 6️⃣ Prompt Templates (Enhanced for Structured Formatting + Clean Output)
|
| 186 |
# ==========================================================
|
| 187 |
+
|
| 188 |
STRICT_PROMPT = (
|
| 189 |
"You are an enterprise documentation assistant.\n"
|
| 190 |
"Use all relevant information from the CONTEXT below.\n"
|
| 191 |
+
"When multiple causes, steps, or key points are discussed, present them as short, well-structured bullet points.\n"
|
| 192 |
+
"When the answer focuses on a single concept, definition, or explanation, write it as a clear and compact paragraph.\n"
|
| 193 |
+
"Keep the tone professional and concise. Do not invent facts outside the provided content.\n"
|
| 194 |
+
"Do not mention or refer to internal elements such as 'chunks', 'chunk numbers', 'passages', or 'sections of the document'.\n"
|
|
|
|
| 195 |
"If the answer cannot be found even after considering all chunks, say exactly:\n"
|
| 196 |
"'I don't know based on the provided document.'\n\n"
|
| 197 |
"Context:\n{context}\n\nQuestion: {query}\nAnswer:"
|
| 198 |
)
|
| 199 |
|
| 200 |
+
|
| 201 |
REASONING_PROMPT = (
|
| 202 |
"You are an expert enterprise assistant capable of reasoning.\n"
|
| 203 |
"Think step by step and synthesize information even if scattered across chunks.\n"
|
| 204 |
"Base your answer primarily on the CONTEXT, but if multiple partial clues exist, combine them logically.\n"
|
| 205 |
"You may fill reasonable gaps with general knowledge to form a complete answer.\n"
|
| 206 |
+
"Do not mention or refer to internal elements such as 'chunks', 'chunk numbers', 'passages', or 'sections of the document'.\n"
|
|
|
|
|
|
|
| 207 |
"If absolutely nothing in the document relates, say exactly:\n"
|
| 208 |
"'I don't know based on the provided document.'\n\n"
|
| 209 |
"Context:\n{context}\n\nQuestion: {query}\nLet's reason step-by-step:\nAnswer:"
|