Spaces:
Sleeping
Sleeping
add debug to show web resarch result
Browse files
app.py
CHANGED
|
@@ -141,9 +141,21 @@ def chat_response(user_msg, chat_history, system_prompt,
|
|
| 141 |
else:
|
| 142 |
enriched = system_prompt
|
| 143 |
|
| 144 |
-
#
|
| 145 |
if enable_search:
|
| 146 |
thread_search.join(timeout=1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
prompt = format_conversation(history, enriched)
|
| 149 |
|
|
|
|
| 141 |
else:
|
| 142 |
enriched = system_prompt
|
| 143 |
|
| 144 |
+
# wait up to 1s for snippets, then replace debug with them
|
| 145 |
if enable_search:
|
| 146 |
thread_search.join(timeout=1.0)
|
| 147 |
+
if search_results:
|
| 148 |
+
debug = "### Search results merged into prompt\n\n" + "\n".join(
|
| 149 |
+
f"- {r}" for r in search_results
|
| 150 |
+
)
|
| 151 |
+
else:
|
| 152 |
+
debug = "*No web search results found.*"
|
| 153 |
+
|
| 154 |
+
# merge fetched snippets into the system prompt
|
| 155 |
+
if search_results:
|
| 156 |
+
enriched = system_prompt.strip() + "\n\nRelevant context:\n" + "\n".join(search_results)
|
| 157 |
+
else:
|
| 158 |
+
enriched = system_prompt
|
| 159 |
|
| 160 |
prompt = format_conversation(history, enriched)
|
| 161 |
|