Spaces:
Build error
Build error
reset chat state when history is reset
Browse files
app.py
CHANGED
@@ -109,6 +109,10 @@ def chat(
|
|
109 |
global model
|
110 |
history = history or []
|
111 |
|
|
|
|
|
|
|
|
|
112 |
if model == None:
|
113 |
gc.collect()
|
114 |
if (DEVICE == "cuda"):
|
@@ -213,7 +217,7 @@ chatiface = gr.Interface(
|
|
213 |
gr.Slider(1, 384, value=20), # max_tokens
|
214 |
gr.Slider(0.0, 1.0, value=0.2), # temperature
|
215 |
gr.Slider(0.0, 1.0, value=0.9), # top_p
|
216 |
-
gr.Textbox(lines=1, value="<|endoftext
|
217 |
],
|
218 |
outputs=[gr.Chatbot(color_map=("green", "pink")),"state"],
|
219 |
).queue()
|
|
|
109 |
global model
|
110 |
history = history or []
|
111 |
|
112 |
+
if len(history) == 0:
|
113 |
+
# no history, so lets reset chat state
|
114 |
+
model.resetState()
|
115 |
+
|
116 |
if model == None:
|
117 |
gc.collect()
|
118 |
if (DEVICE == "cuda"):
|
|
|
217 |
gr.Slider(1, 384, value=20), # max_tokens
|
218 |
gr.Slider(0.0, 1.0, value=0.2), # temperature
|
219 |
gr.Slider(0.0, 1.0, value=0.9), # top_p
|
220 |
+
gr.Textbox(lines=1, value="<|endoftext|>") # stop
|
221 |
],
|
222 |
outputs=[gr.Chatbot(color_map=("green", "pink")),"state"],
|
223 |
).queue()
|