Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -220,9 +220,9 @@ def clear_chat():
|
|
| 220 |
def chat_fn(message, history, system_prompt, temperature):
|
| 221 |
"""Main chat function"""
|
| 222 |
if not chat_model.model_loaded:
|
| 223 |
-
return "Please wait for the model to load or reload the space."
|
| 224 |
|
| 225 |
-
# Convert history format
|
| 226 |
formatted_history = []
|
| 227 |
for user_msg, assistant_msg in history:
|
| 228 |
formatted_history.append({"role": "user", "content": user_msg})
|
|
@@ -232,7 +232,8 @@ def chat_fn(message, history, system_prompt, temperature):
|
|
| 232 |
# Generate response
|
| 233 |
response = chat_model.generate_response(message, formatted_history, system_prompt, temperature)
|
| 234 |
|
| 235 |
-
|
|
|
|
| 236 |
|
| 237 |
def chat_stream_fn(message, history, system_prompt, temperature):
|
| 238 |
"""Streaming chat function"""
|
|
|
|
| 220 |
def chat_fn(message, history, system_prompt, temperature):
|
| 221 |
"""Main chat function"""
|
| 222 |
if not chat_model.model_loaded:
|
| 223 |
+
return history + [[message, "Please wait for the model to load or reload the space."]]
|
| 224 |
|
| 225 |
+
# Convert history format for the model
|
| 226 |
formatted_history = []
|
| 227 |
for user_msg, assistant_msg in history:
|
| 228 |
formatted_history.append({"role": "user", "content": user_msg})
|
|
|
|
| 232 |
# Generate response
|
| 233 |
response = chat_model.generate_response(message, formatted_history, system_prompt, temperature)
|
| 234 |
|
| 235 |
+
# Return updated history with new message pair
|
| 236 |
+
return history + [[message, response]]
|
| 237 |
|
| 238 |
def chat_stream_fn(message, history, system_prompt, temperature):
|
| 239 |
"""Streaming chat function"""
|