Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,7 +130,7 @@ def chat_response(user_msg, chat_history, system_prompt,
|
|
| 130 |
Generates streaming chat responses, optionally with background web search.
|
| 131 |
"""
|
| 132 |
cancel_event.clear()
|
| 133 |
-
history = list(chat_history
|
| 134 |
history.append({'role': 'user', 'content': user_msg})
|
| 135 |
|
| 136 |
# Launch web search if enabled
|
|
@@ -165,6 +165,11 @@ def chat_response(user_msg, chat_history, system_prompt,
|
|
| 165 |
|
| 166 |
pipe = load_pipeline(model_name)
|
| 167 |
prompt = format_conversation(history, enriched, pipe["tokenizer"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
prompt_debug = f"\n\n--- Prompt Preview ---\n```\n{prompt}\n```"
|
| 169 |
streamer = TextIterStreamer(pipe["tokenizer"],
|
| 170 |
skip_prompt=True,
|
|
@@ -197,6 +202,9 @@ def chat_response(user_msg, chat_history, system_prompt,
|
|
| 197 |
break
|
| 198 |
text = chunk
|
| 199 |
|
|
|
|
|
|
|
|
|
|
| 200 |
# Detect start of thinking
|
| 201 |
if not in_thought and '<think>' in text:
|
| 202 |
in_thought = True
|
|
|
|
| 130 |
Generates streaming chat responses, optionally with background web search.
|
| 131 |
"""
|
| 132 |
cancel_event.clear()
|
| 133 |
+
history = list(chat_history) if chat_history else []
|
| 134 |
history.append({'role': 'user', 'content': user_msg})
|
| 135 |
|
| 136 |
# Launch web search if enabled
|
|
|
|
| 165 |
|
| 166 |
pipe = load_pipeline(model_name)
|
| 167 |
prompt = format_conversation(history, enriched, pipe["tokenizer"])
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
# TODO:
|
| 171 |
+
debug += "\nPROMPT:\n" + text
|
| 172 |
+
|
| 173 |
prompt_debug = f"\n\n--- Prompt Preview ---\n```\n{prompt}\n```"
|
| 174 |
streamer = TextIterStreamer(pipe["tokenizer"],
|
| 175 |
skip_prompt=True,
|
|
|
|
| 202 |
break
|
| 203 |
text = chunk
|
| 204 |
|
| 205 |
+
# TODO:
|
| 206 |
+
debug += "\nRESPONSE:\n" + text
|
| 207 |
+
|
| 208 |
# Detect start of thinking
|
| 209 |
if not in_thought and '<think>' in text:
|
| 210 |
in_thought = True
|