Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import gradio as gr
|
|
6 |
import spaces
|
7 |
import torch
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
|
|
9 |
|
10 |
|
11 |
MAX_MAX_NEW_TOKENS = 2048
|
@@ -140,10 +141,26 @@ chat_interface = gr.ChatInterface(
|
|
140 |
|
141 |
with gr.Blocks(css="style.css") as demo:
|
142 |
gr.Markdown(DESCRIPTION)
|
143 |
-
gr.UploadButton(value="Upload a File", elem_id="uploadbutton")
|
144 |
chat_interface.render()
|
145 |
gr.Markdown(LICENSE)
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
if __name__ == "__main__":
|
149 |
demo.queue(max_size=20).launch()
|
|
|
6 |
import spaces
|
7 |
import torch
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
9 |
+
from pathlib import Path
|
10 |
|
11 |
|
12 |
MAX_MAX_NEW_TOKENS = 2048
|
|
|
141 |
|
142 |
with gr.Blocks(css="style.css") as demo:
|
143 |
gr.Markdown(DESCRIPTION)
|
|
|
144 |
chat_interface.render()
|
145 |
gr.Markdown(LICENSE)
|
146 |
|
147 |
+
def upload_file(filepath):
|
148 |
+
name = Path(filepath).name
|
149 |
+
return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
|
150 |
+
|
151 |
+
def download_file():
|
152 |
+
return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|
153 |
+
|
154 |
+
with gr.Blocks() as demo:
|
155 |
+
gr.Markdown("First upload a file and and then you'll be able download it (but only once!)")
|
156 |
+
with gr.Row():
|
157 |
+
u = gr.UploadButton("Upload a file", file_count="single")
|
158 |
+
d = gr.DownloadButton("Download the file", visible=False)
|
159 |
+
|
160 |
+
u.upload(upload_file, u, [u, d])
|
161 |
+
d.click(download_file, None, [u, d])
|
162 |
+
|
163 |
+
|
164 |
|
165 |
if __name__ == "__main__":
|
166 |
demo.queue(max_size=20).launch()
|