Spaces:
Sleeping
Sleeping
Commit
·
d1b244e
1
Parent(s):
e1c27aa
introduced gradio/app_fileupload_chatbot.py, removed gradio/app_fileupload_chatbot.py
Browse files
gradio/{app_iterative_file_upload.py → app_fileupload_chatbot.py}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def upload_files(files, filepaths):
|
| 4 |
verbose = False
|
|
@@ -9,6 +10,16 @@ def upload_files(files, filepaths):
|
|
| 9 |
filepaths = filepaths + filepaths_new
|
| 10 |
return filepaths, filepaths
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
with gr.Blocks() as demo:
|
| 13 |
gr.Markdown("Define References")
|
| 14 |
filepaths = gr.State([])
|
|
@@ -18,6 +29,17 @@ with gr.Blocks() as demo:
|
|
| 18 |
fn=upload_files,
|
| 19 |
inputs=[upload_button, filepaths],
|
| 20 |
outputs=[file_output, filepaths])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
| 23 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import time
|
| 3 |
|
| 4 |
def upload_files(files, filepaths):
|
| 5 |
verbose = False
|
|
|
|
| 10 |
filepaths = filepaths + filepaths_new
|
| 11 |
return filepaths, filepaths
|
| 12 |
|
| 13 |
+
def echo(message, history, system_prompt, filepaths):
|
| 14 |
+
filepaths_str = '\n'.join(filepaths)
|
| 15 |
+
response = f"""
|
| 16 |
+
System prompt: {system_prompt}
|
| 17 |
+
Message: {message}
|
| 18 |
+
Uploaded Files:
|
| 19 |
+
{filepaths_str}
|
| 20 |
+
"""
|
| 21 |
+
return response
|
| 22 |
+
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
gr.Markdown("Define References")
|
| 25 |
filepaths = gr.State([])
|
|
|
|
| 29 |
fn=upload_files,
|
| 30 |
inputs=[upload_button, filepaths],
|
| 31 |
outputs=[file_output, filepaths])
|
| 32 |
+
system_prompt = gr.Textbox("You are helpful AI.", label="System Prompt")
|
| 33 |
+
gr.ChatInterface(
|
| 34 |
+
fn=echo,
|
| 35 |
+
additional_inputs=[system_prompt, filepaths],
|
| 36 |
+
type="messages"
|
| 37 |
+
)
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
demo.launch()
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|