Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,26 +138,37 @@ def chat_response(user_msg, chat_history, system_prompt,
|
|
| 138 |
try:
|
| 139 |
cur_date = datetime.now().strftime('%Y-%m-%d')
|
| 140 |
# merge any fetched search results into the system prompt
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
# wait up to 1s for snippets, then replace debug with them
|
| 163 |
if enable_search:
|
|
|
|
| 138 |
try:
|
| 139 |
cur_date = datetime.now().strftime('%Y-%m-%d')
|
| 140 |
# merge any fetched search results into the system prompt
|
| 141 |
+
if search_results:
|
| 142 |
+
enriched = system_prompt.strip() + f"""
|
| 143 |
+
# SEARCH CONTEXT (TRUSTED SOURCES ONLY)
|
| 144 |
+
Below are web search results. Treat them as the ONLY source of truth for answering.
|
| 145 |
+
{search_results}
|
| 146 |
+
|
| 147 |
+
RULES (VERY IMPORTANT):
|
| 148 |
+
- Do NOT use outside knowledge. Do NOT guess or fill missing information.
|
| 149 |
+
- If the answer is not clearly supported by the search results, say: "Not enough information in the provided sources."
|
| 150 |
+
- Every factual statement must be directly supported by at least one citation [citation:X].
|
| 151 |
+
- Do NOT add explanations, examples, or background that are not explicitly present in the sources.
|
| 152 |
+
- Do NOT paraphrase beyond what is necessary for clarity.
|
| 153 |
+
- If sources conflict, mention the conflict and cite both.
|
| 154 |
+
- If multiple sources are used, distribute citations per sentence, not only at the end.
|
| 155 |
+
|
| 156 |
+
CITATION RULES:
|
| 157 |
+
- Use inline citations like this: [citation:1]
|
| 158 |
+
- If multiple sources support a sentence: [citation:1][citation:3]
|
| 159 |
+
- Never place all citations only at the end.
|
| 160 |
+
|
| 161 |
+
ANSWER POLICY:
|
| 162 |
+
- Be concise and strictly grounded.
|
| 163 |
+
- No speculation, no assumptions, no "likely", no "probably".
|
| 164 |
+
- If the user requests a list, only include items explicitly found in sources.
|
| 165 |
+
- If sources are insufficient, stop and ask for more data instead of guessing.
|
| 166 |
+
DATE CONTEXT:
|
| 167 |
+
- Today is {cur_date} (use only for time reference, not for assumptions).
|
| 168 |
+
USER QUESTION:
|
| 169 |
+
"""
|
| 170 |
+
else:
|
| 171 |
+
enriched = system_prompt
|
| 172 |
|
| 173 |
# wait up to 1s for snippets, then replace debug with them
|
| 174 |
if enable_search:
|