Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
•
2006331
1
Parent(s):
8759d6a
Update clear
Browse files
app.py
CHANGED
@@ -25,8 +25,6 @@ ns = SimpleNamespace(response="")
|
|
25 |
|
26 |
def predict0(prompt, bot):
|
27 |
# logger.debug(f"{prompt=}, {bot=}, {timeout=}")
|
28 |
-
_ = ("", "")
|
29 |
-
bot.append(_)
|
30 |
logger.debug(f"{prompt=}, {bot=}")
|
31 |
ns.response = ""
|
32 |
with about_time() as atime:
|
@@ -37,16 +35,12 @@ def predict0(prompt, bot):
|
|
37 |
|
38 |
response = ""
|
39 |
buff.update(value="diggin...")
|
40 |
-
|
41 |
-
bot[-1] = [(prompt, "diggin...")]
|
42 |
-
else:
|
43 |
-
bot = [(prompt, "diggin...")]
|
44 |
for word in generator:
|
45 |
print(word, end="", flush=True)
|
46 |
response += word
|
47 |
ns.response = response
|
48 |
buff.update(value=response)
|
49 |
-
bot[-1] = [(prompt, response)]
|
50 |
print("")
|
51 |
logger.debug(f"{response=}")
|
52 |
except Exception as exc:
|
@@ -56,9 +50,9 @@ def predict0(prompt, bot):
|
|
56 |
# bot = {"inputs": [response]}
|
57 |
_ = (
|
58 |
f"(time elapsed: {atime.duration_human}, "
|
59 |
-
f"{atime.duration/(len(prompt) + len(response))}
|
60 |
)
|
61 |
-
bot[
|
62 |
|
63 |
return prompt, bot
|
64 |
|
@@ -354,7 +348,7 @@ with gr.Blocks(
|
|
354 |
with gr.Row():
|
355 |
submit = gr.Button("Submit", elem_classes="xsmall")
|
356 |
stop = gr.Button("Stop", visible=False)
|
357 |
-
clear = gr.Button("Clear", visible=
|
358 |
with gr.Row(visible=False):
|
359 |
with gr.Accordion("Advanced Options:", open=False):
|
360 |
with gr.Row():
|
@@ -488,6 +482,7 @@ with gr.Blocks(
|
|
488 |
queue=True,
|
489 |
show_progress="full",
|
490 |
)
|
|
|
491 |
|
492 |
# update buff Textbox, every: units in seconds)
|
493 |
# https://huggingface.co/spaces/julien-c/nvidia-smi/discussions
|
|
|
25 |
|
26 |
def predict0(prompt, bot):
|
27 |
# logger.debug(f"{prompt=}, {bot=}, {timeout=}")
|
|
|
|
|
28 |
logger.debug(f"{prompt=}, {bot=}")
|
29 |
ns.response = ""
|
30 |
with about_time() as atime:
|
|
|
35 |
|
36 |
response = ""
|
37 |
buff.update(value="diggin...")
|
38 |
+
|
|
|
|
|
|
|
39 |
for word in generator:
|
40 |
print(word, end="", flush=True)
|
41 |
response += word
|
42 |
ns.response = response
|
43 |
buff.update(value=response)
|
|
|
44 |
print("")
|
45 |
logger.debug(f"{response=}")
|
46 |
except Exception as exc:
|
|
|
50 |
# bot = {"inputs": [response]}
|
51 |
_ = (
|
52 |
f"(time elapsed: {atime.duration_human}, "
|
53 |
+
f"{atime.duration/(len(prompt) + len(response)):.1f}s/char)"
|
54 |
)
|
55 |
+
bot.append([prompt, f"{response} {_}"])
|
56 |
|
57 |
return prompt, bot
|
58 |
|
|
|
348 |
with gr.Row():
|
349 |
submit = gr.Button("Submit", elem_classes="xsmall")
|
350 |
stop = gr.Button("Stop", visible=False)
|
351 |
+
clear = gr.Button("Clear", visible=True)
|
352 |
with gr.Row(visible=False):
|
353 |
with gr.Accordion("Advanced Options:", open=False):
|
354 |
with gr.Row():
|
|
|
482 |
queue=True,
|
483 |
show_progress="full",
|
484 |
)
|
485 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
486 |
|
487 |
# update buff Textbox, every: units in seconds)
|
488 |
# https://huggingface.co/spaces/julien-c/nvidia-smi/discussions
|