Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,26 +5,26 @@ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
|
|
| 5 |
|
| 6 |
dropdown, js = create_theme_dropdown()
|
| 7 |
|
| 8 |
-
with gr.Blocks(
|
| 9 |
-
with gr.Row(
|
| 10 |
with gr.Column(scale=10):
|
| 11 |
gr.Markdown(
|
| 12 |
"""
|
| 13 |
-
# Theme preview: `
|
| 14 |
-
To use this theme, set `theme='
|
| 15 |
You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
|
| 16 |
of this theme.
|
| 17 |
"""
|
| 18 |
)
|
| 19 |
with gr.Column(scale=3):
|
| 20 |
-
with gr.
|
| 21 |
dropdown.render()
|
| 22 |
-
toggle_dark = gr.Button(value="Toggle Dark")
|
| 23 |
|
| 24 |
-
dropdown.change(None, dropdown, None,
|
| 25 |
toggle_dark.click(
|
| 26 |
None,
|
| 27 |
-
|
| 28 |
() => {
|
| 29 |
document.body.classList.toggle('dark');
|
| 30 |
}
|
|
@@ -63,17 +63,17 @@ with gr.Blocks(theme='nuttea/Softblue') as demo:
|
|
| 63 |
check = gr.Checkbox(label="Go")
|
| 64 |
with gr.Column(variant="panel", scale=2):
|
| 65 |
img = gr.Image(
|
| 66 |
-
"https://gradio.
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
with gr.Row():
|
| 69 |
-
go_btn = gr.Button("Go",
|
| 70 |
-
clear_btn = gr.Button(
|
| 71 |
-
"Clear", label="Secondary Button", variant="secondary"
|
| 72 |
-
)
|
| 73 |
|
| 74 |
def go(*args):
|
| 75 |
time.sleep(3)
|
| 76 |
-
return "https://gradio.
|
| 77 |
|
| 78 |
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
| 79 |
|
|
@@ -84,11 +84,9 @@ with gr.Blocks(theme='nuttea/Softblue') as demo:
|
|
| 84 |
clear_btn.click(clear, None, img)
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
-
btn1 = gr.Button("Button 1"
|
| 88 |
-
btn2 = gr.UploadButton(
|
| 89 |
-
stop_btn = gr.Button("Stop",
|
| 90 |
-
size="sm"
|
| 91 |
-
)
|
| 92 |
|
| 93 |
with gr.Row():
|
| 94 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
|
@@ -114,22 +112,30 @@ with gr.Blocks(theme='nuttea/Softblue') as demo:
|
|
| 114 |
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
| 115 |
"tower",
|
| 116 |
),
|
| 117 |
-
]
|
| 118 |
-
|
|
|
|
| 119 |
|
| 120 |
with gr.Row():
|
| 121 |
with gr.Column(scale=2):
|
| 122 |
-
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
chat_btn = gr.Button("Add messages")
|
| 124 |
|
| 125 |
def chat(history):
|
| 126 |
time.sleep(2)
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
chat_btn.click(
|
| 130 |
-
|
| 131 |
-
+ [["How are you?", "I am good."]]
|
| 132 |
-
+ (time.sleep(2) or []),
|
| 133 |
chatbot,
|
| 134 |
chatbot,
|
| 135 |
)
|
|
@@ -142,4 +148,4 @@ with gr.Blocks(theme='nuttea/Softblue') as demo:
|
|
| 142 |
|
| 143 |
|
| 144 |
if __name__ == "__main__":
|
| 145 |
-
demo.queue().launch()
|
|
|
|
| 5 |
|
| 6 |
dropdown, js = create_theme_dropdown()
|
| 7 |
|
| 8 |
+
with gr.Blocks() as demo:
|
| 9 |
+
with gr.Row(equal_height=True):
|
| 10 |
with gr.Column(scale=10):
|
| 11 |
gr.Markdown(
|
| 12 |
"""
|
| 13 |
+
# Theme preview: `yellow`
|
| 14 |
+
To use this theme, set `theme='terastudio/yellow'` in `gr.Blocks()` or `gr.Interface()`.
|
| 15 |
You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
|
| 16 |
of this theme.
|
| 17 |
"""
|
| 18 |
)
|
| 19 |
with gr.Column(scale=3):
|
| 20 |
+
with gr.Group():
|
| 21 |
dropdown.render()
|
| 22 |
+
toggle_dark = gr.Button(value="Toggle Dark")
|
| 23 |
|
| 24 |
+
dropdown.change(None, dropdown, None, js=js)
|
| 25 |
toggle_dark.click(
|
| 26 |
None,
|
| 27 |
+
js="""
|
| 28 |
() => {
|
| 29 |
document.body.classList.toggle('dark');
|
| 30 |
}
|
|
|
|
| 63 |
check = gr.Checkbox(label="Go")
|
| 64 |
with gr.Column(variant="panel", scale=2):
|
| 65 |
img = gr.Image(
|
| 66 |
+
"https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg",
|
| 67 |
+
label="Image",
|
| 68 |
+
height=320,
|
| 69 |
+
)
|
| 70 |
with gr.Row():
|
| 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 |
|
|
|
|
| 84 |
clear_btn.click(clear, None, img)
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
+
btn1 = gr.Button("Button 1", size="sm")
|
| 88 |
+
btn2 = gr.UploadButton(size="sm")
|
| 89 |
+
stop_btn = gr.Button("Stop", size="sm", variant="stop")
|
|
|
|
|
|
|
| 90 |
|
| 91 |
with gr.Row():
|
| 92 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
|
|
|
| 112 |
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
| 113 |
"tower",
|
| 114 |
),
|
| 115 |
+
],
|
| 116 |
+
height=200,
|
| 117 |
+
)
|
| 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 |
)
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
+
demo.queue().launch(theme='terastudio/yellow')
|