Spaces:
Runtime error
Runtime error
Update web.py
Browse files
web.py
CHANGED
@@ -1,33 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import asyncio
|
4 |
|
5 |
-
def
|
6 |
-
|
7 |
-
|
8 |
-
return f"{current_time} - live"
|
9 |
-
|
10 |
-
async def periodic_update(interface, interval=60):
|
11 |
-
""" μ£Όμ΄μ§ μΈν°νμ΄μ€μ 1λΆ κ°κ²©μΌλ‘ μ
λ°μ΄νΈλ₯Ό μ€νν©λλ€. """
|
12 |
-
while True:
|
13 |
-
live_message = update_live_message()
|
14 |
-
interface.update(live_message)
|
15 |
-
await asyncio.sleep(interval)
|
16 |
|
17 |
def run_gradio():
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
-
run_gradio()
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
|
|
3 |
|
4 |
+
def chatbot(message):
|
5 |
+
# μ¬κΈ°μ μ±λ΄ λ‘μ§μ ꡬννμΈμ
|
6 |
+
return f"μμ½: {message}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def run_gradio():
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
chatbot = gr.Chatbot()
|
11 |
+
msg = gr.Textbox()
|
12 |
+
clear = gr.Button("Clear")
|
13 |
+
|
14 |
+
def respond(message, chat_history):
|
15 |
+
bot_message = chatbot(message)
|
16 |
+
chat_history.append((message, bot_message))
|
17 |
+
return "", chat_history
|
18 |
+
|
19 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
20 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
21 |
|
22 |
+
port = int(os.getenv('GRADIO_SERVER_PORT', 7860))
|
23 |
+
demo.launch(server_name="0.0.0.0", server_port=port, inbrowser=True)
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
+
run_gradio()
|