Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
·
7c0ecdf
1
Parent(s):
dba1dfa
block.load every=1, running clock)
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
# pylint: disable=invalid-name, line-too-long,broad-exception-caught, protected-access
|
| 3 |
import os
|
| 4 |
import time
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
import gradio as gr
|
|
@@ -65,6 +66,8 @@ if model_cache_path:
|
|
| 65 |
model_size_gb = model_cache_path[0].stat().st_size / 2**30
|
| 66 |
logger.info(f"{model_name=} {model_size_gb=:.2f} GB")
|
| 67 |
|
|
|
|
|
|
|
| 68 |
|
| 69 |
def respond(message, chat_history):
|
| 70 |
"""Gen a response."""
|
|
@@ -89,10 +92,11 @@ with gr.Blocks(theme=theme) as block:
|
|
| 89 |
with gr.Column(scale=12):
|
| 90 |
msg = gr.Textbox()
|
| 91 |
with gr.Column(scale=1, min_width=16):
|
| 92 |
-
|
| 93 |
with gr.Column(scale=1, min_width=8):
|
| 94 |
-
|
| 95 |
-
|
|
|
|
| 96 |
# do not clear prompt
|
| 97 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 98 |
|
|
@@ -132,5 +136,5 @@ with gr.Blocks(theme=theme) as block:
|
|
| 132 |
inputs=[msg],
|
| 133 |
examples_per_page=60,
|
| 134 |
)
|
| 135 |
-
|
| 136 |
block.queue().launch()
|
|
|
|
| 2 |
# pylint: disable=invalid-name, line-too-long,broad-exception-caught, protected-access
|
| 3 |
import os
|
| 4 |
import time
|
| 5 |
+
from datetime import datetime
|
| 6 |
from pathlib import Path
|
| 7 |
|
| 8 |
import gradio as gr
|
|
|
|
| 66 |
model_size_gb = model_cache_path[0].stat().st_size / 2**30
|
| 67 |
logger.info(f"{model_name=} {model_size_gb=:.2f} GB")
|
| 68 |
|
| 69 |
+
def get_time():
|
| 70 |
+
return datetime.now().time()
|
| 71 |
|
| 72 |
def respond(message, chat_history):
|
| 73 |
"""Gen a response."""
|
|
|
|
| 92 |
with gr.Column(scale=12):
|
| 93 |
msg = gr.Textbox()
|
| 94 |
with gr.Column(scale=1, min_width=16):
|
| 95 |
+
btn = gr.Button("Send")
|
| 96 |
with gr.Column(scale=1, min_width=8):
|
| 97 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 98 |
+
with gr.Column(scale=1, min_width=8):
|
| 99 |
+
dt = gr.Textbox(label="Current time")
|
| 100 |
# do not clear prompt
|
| 101 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 102 |
|
|
|
|
| 136 |
inputs=[msg],
|
| 137 |
examples_per_page=60,
|
| 138 |
)
|
| 139 |
+
block.load(get_time, inputs=[], outputs=dt, every=1)
|
| 140 |
block.queue().launch()
|