Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
·
de87da8
1
Parent(s):
1681f8a
app.py
CHANGED
|
@@ -176,6 +176,12 @@ def user(user_message, history):
|
|
| 176 |
return user_message, history
|
| 177 |
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
def bot_(history):
|
| 180 |
user_message = history[-1][0]
|
| 181 |
resp = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
|
@@ -210,7 +216,9 @@ def bot(history):
|
|
| 210 |
prefix = f"({time.time() - then:.2f}s) "
|
| 211 |
flag = 0
|
| 212 |
print(prefix, end="", flush=True)
|
|
|
|
| 213 |
print(elm, end="", flush=True)
|
|
|
|
| 214 |
|
| 215 |
response.append(elm)
|
| 216 |
history[-1][1] = prefix + "".join(response)
|
|
@@ -398,7 +406,8 @@ with gr.Blocks(
|
|
| 398 |
api_name=None,
|
| 399 |
).then(bot, chatbot, chatbot, queue=False)
|
| 400 |
submit.click(
|
| 401 |
-
fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
|
|
|
|
| 402 |
inputs=[msg, chatbot],
|
| 403 |
outputs=[msg, chatbot],
|
| 404 |
queue=True,
|
|
|
|
| 176 |
return user_message, history
|
| 177 |
|
| 178 |
|
| 179 |
+
def user1(user_message, history):
|
| 180 |
+
# return user_message, history + [[user_message, None]]
|
| 181 |
+
history.append([user_message, None])
|
| 182 |
+
return "", history
|
| 183 |
+
|
| 184 |
+
|
| 185 |
def bot_(history):
|
| 186 |
user_message = history[-1][0]
|
| 187 |
resp = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
|
|
|
| 216 |
prefix = f"({time.time() - then:.2f}s) "
|
| 217 |
flag = 0
|
| 218 |
print(prefix, end="", flush=True)
|
| 219 |
+
logger.debug(f"{prefix=}")
|
| 220 |
print(elm, end="", flush=True)
|
| 221 |
+
logger.debug(f"{elm=}")
|
| 222 |
|
| 223 |
response.append(elm)
|
| 224 |
history[-1][1] = prefix + "".join(response)
|
|
|
|
| 406 |
api_name=None,
|
| 407 |
).then(bot, chatbot, chatbot, queue=False)
|
| 408 |
submit.click(
|
| 409 |
+
# fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
|
| 410 |
+
fn=user1, # clear msg
|
| 411 |
inputs=[msg, chatbot],
|
| 412 |
outputs=[msg, chatbot],
|
| 413 |
queue=True,
|