Tim Seufert commited on
Commit
e204d79
·
1 Parent(s): 56bca49

file upload beta

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -50,15 +50,26 @@ def respond(message, image, chat_history):
50
  except Exception as e:
51
  return "", chat_history.append((message, f"Error: {str(e)}"))
52
 
 
 
 
 
 
53
  # Create Gradio interface
54
  with gr.Blocks() as demo:
55
  chatbot = gr.Chatbot()
56
  msg = gr.Textbox()
57
  #img = gr.Image(type="filepath")
58
  clear = gr.ClearButton([msg, chatbot])
 
 
 
 
59
 
60
  # Set up message submission
61
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
 
 
62
 
63
  # Launch the demo
64
  demo.launch(
 
50
  except Exception as e:
51
  return "", chat_history.append((message, f"Error: {str(e)}"))
52
 
53
+ #Upload file function create
54
+
55
+ def upload_file(files):
56
+ return [file.name for file in files]
57
+
58
  # Create Gradio interface
59
  with gr.Blocks() as demo:
60
  chatbot = gr.Chatbot()
61
  msg = gr.Textbox()
62
  #img = gr.Image(type="filepath")
63
  clear = gr.ClearButton([msg, chatbot])
64
+ file_output = gr.File()
65
+ upload_button = gr.UploadButton("Click to Upload a File", file_types=["image", "video"], file_count="multiple")
66
+ upload_button.upload(upload_file, upload_button, file_output)
67
+
68
 
69
  # Set up message submission
70
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
71
+ upload_button.upload(upload_file, upload_button, file_output)
72
+
73
 
74
  # Launch the demo
75
  demo.launch(