Update app.py
Browse files
app.py
CHANGED
|
@@ -71,14 +71,15 @@ with gr.Blocks() as demo:
|
|
| 71 |
go_btn = gr.Button("Go", variant="primary")
|
| 72 |
clear_btn = gr.Button("Clear", variant="secondary")
|
| 73 |
|
| 74 |
-
def go(*
|
| 75 |
time.sleep(3)
|
| 76 |
-
return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.
|
| 77 |
|
| 78 |
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
| 79 |
|
| 80 |
def clear():
|
| 81 |
time.sleep(0.2)
|
|
|
|
| 82 |
|
| 83 |
clear_btn.click(clear, None, img)
|
| 84 |
|
|
@@ -117,13 +118,24 @@ with gr.Blocks() as demo:
|
|
| 117 |
|
| 118 |
with gr.Row():
|
| 119 |
with gr.Column(scale=2):
|
| 120 |
-
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
chat_btn = gr.Button("Add messages")
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
chat_btn.click(
|
| 124 |
-
|
| 125 |
-
+ [["How are you?", "I am good."]]
|
| 126 |
-
+ (time.sleep(2) or []),
|
| 127 |
chatbot,
|
| 128 |
chatbot,
|
| 129 |
)
|
|
|
|
| 71 |
go_btn = gr.Button("Go", variant="primary")
|
| 72 |
clear_btn = gr.Button("Clear", variant="secondary")
|
| 73 |
|
| 74 |
+
def go(*args):
|
| 75 |
time.sleep(3)
|
| 76 |
+
return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpgjpg"
|
| 77 |
|
| 78 |
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
| 79 |
|
| 80 |
def clear():
|
| 81 |
time.sleep(0.2)
|
| 82 |
+
return None
|
| 83 |
|
| 84 |
clear_btn.click(clear, None, img)
|
| 85 |
|
|
|
|
| 118 |
|
| 119 |
with gr.Row():
|
| 120 |
with gr.Column(scale=2):
|
| 121 |
+
chatbot = gr.Chatbot(
|
| 122 |
+
value=[
|
| 123 |
+
{"role": "user", "content": "Hello"},
|
| 124 |
+
{"role": "assistant", "content": "Hi"}
|
| 125 |
+
],
|
| 126 |
+
label="Chatbot"
|
| 127 |
+
)
|
| 128 |
chat_btn = gr.Button("Add messages")
|
| 129 |
|
| 130 |
+
def chat(history):
|
| 131 |
+
time.sleep(2)
|
| 132 |
+
return history + [
|
| 133 |
+
{"role": "user", "content": "How are you?"},
|
| 134 |
+
{"role": "assistant", "content": "I am good."}
|
| 135 |
+
]
|
| 136 |
+
|
| 137 |
chat_btn.click(
|
| 138 |
+
chat,
|
|
|
|
|
|
|
| 139 |
chatbot,
|
| 140 |
chatbot,
|
| 141 |
)
|