Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,10 @@ def retrieve_context(query, max_results=6, max_chars=600):
|
|
| 107 |
|
| 108 |
def format_conversation(history, system_prompt, tokenizer):
|
| 109 |
if hasattr(tokenizer, "chat_template") and tokenizer.chat_template:
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
|
| 112 |
else:
|
| 113 |
# Fallback for base LMs without chat template
|
|
|
|
| 107 |
|
| 108 |
def format_conversation(history, system_prompt, tokenizer):
|
| 109 |
if hasattr(tokenizer, "chat_template") and tokenizer.chat_template:
|
| 110 |
+
if len(history) > 0:
|
| 111 |
+
messages = [{"role": "system", "content": system_prompt.strip()}] + history
|
| 112 |
+
else:
|
| 113 |
+
messages = [{"role": "system", "content": system_prompt.strip()}]
|
| 114 |
return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
|
| 115 |
else:
|
| 116 |
# Fallback for base LMs without chat template
|