Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,13 +112,14 @@ def format_conversation(history, system_prompt, tokenizer):
|
|
| 112 |
else:
|
| 113 |
# Fallback for base LMs without chat template
|
| 114 |
prompt = system_prompt.strip() + "\n"
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
return prompt
|
| 123 |
|
| 124 |
def chat_response(user_msg, chat_history, system_prompt,
|
|
|
|
| 112 |
else:
|
| 113 |
# Fallback for base LMs without chat template
|
| 114 |
prompt = system_prompt.strip() + "\n"
|
| 115 |
+
if len(history) > 0:
|
| 116 |
+
for msg in history:
|
| 117 |
+
if msg['role'] == 'user':
|
| 118 |
+
prompt += "User: " + msg['content'].strip() + "\n"
|
| 119 |
+
elif msg['role'] == 'assistant':
|
| 120 |
+
prompt += "Assistant: " + msg['content'].strip() + "\n"
|
| 121 |
+
if not prompt.strip().endswith("Assistant:"):
|
| 122 |
+
prompt += "Assistant: "
|
| 123 |
return prompt
|
| 124 |
|
| 125 |
def chat_response(user_msg, chat_history, system_prompt,
|