Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,10 +36,13 @@ def chat_with_bot(message, history):
|
|
| 36 |
)
|
| 37 |
|
| 38 |
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
| 39 |
response = decoded[len(prompt):].strip().split("\n")[0]
|
| 40 |
-
#
|
| 41 |
history.append([message, response])
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# Gradio ChatInterface expects fn(message, history) → (response, updated_history)
|
| 45 |
gr.ChatInterface(
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 39 |
+
# Extract assistant output after the prompt.
|
| 40 |
response = decoded[len(prompt):].strip().split("\n")[0]
|
| 41 |
+
# Append the new conversation pair as a list of strings.
|
| 42 |
history.append([message, response])
|
| 43 |
+
# Ensure that every conversation pair is a list of strings.
|
| 44 |
+
safe_history = [[str(u), str(b)] for u, b in history]
|
| 45 |
+
return response, safe_history
|
| 46 |
|
| 47 |
# Gradio ChatInterface expects fn(message, history) → (response, updated_history)
|
| 48 |
gr.ChatInterface(
|