Spaces:
Sleeping
Sleeping
john
commited on
Commit
•
997d27b
1
Parent(s):
098f375
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
import cv2
|
3 |
-
|
4 |
-
def draw(im):
|
5 |
-
cv2.rectangle(im,(50,50), (200,200), (0, 255, 255), 2)
|
6 |
-
return im
|
7 |
-
|
8 |
-
def welcome(name):
|
9 |
-
return f"Hello {name}!"
|
10 |
-
|
11 |
-
def background_task():
|
12 |
-
while True:
|
13 |
-
print("Background task running...")
|
14 |
-
time.sleep(1)
|
15 |
|
16 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
|
|
|
|
25 |
|
26 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
4 |
+
chatbot = gr.Chatbot()
|
5 |
+
msg = gr.Textbox()
|
6 |
+
clear = gr.Button("Clear")
|
7 |
+
|
8 |
+
def respond(message, chat_history):
|
9 |
+
res = generate_text(message)
|
10 |
+
a = (res[0]["generated_text"])
|
11 |
+
b = str(a)
|
12 |
+
bot_message = b
|
13 |
+
chat_history.append((message, bot_message))
|
14 |
+
return "", chat_history
|
15 |
|
16 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
17 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
18 |
|
19 |
demo.launch()
|