michaelmc1618 commited on
Commit
cdda72d
·
verified ·
1 Parent(s): 3ebfdcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -15
app.py CHANGED
@@ -48,21 +48,43 @@ def respond(
48
  """
49
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
50
  """
51
- demo = gr.ChatInterface(
52
- respond,
53
- additional_inputs=[
54
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
55
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
56
- gr.Slider(minimum=0.1, maximum 4.0, value=0.7, step=0.1, label="Temperature"),
57
- gr.Slider(
58
- minimum=0.1,
59
- maximum=1.0,
60
- value=0.95,
61
- step=0.05,
62
- label="Top-p (nucleus sampling)",
63
- ),
64
- ],
65
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  if __name__ == "__main__":
68
  demo.launch()
 
48
  """
49
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
50
  """
51
+
52
+ def process_video(video):
53
+ return f"Processing video: {video.name}"
54
+
55
+ def process_pdf(pdf):
56
+ return f"Processing PDF: {pdf.name}"
57
+
58
+ def process_image(image):
59
+ return f"Processing image: {image.name}"
60
+
61
+ video_upload = gr.Interface(fn=process_video, inputs=gr.Video(), outputs="text", title="Upload a Video")
62
+ pdf_upload = gr.Interface(fn=process_pdf, inputs=gr.File(file_types=['.pdf']), outputs="text", title="Upload a PDF")
63
+ image_upload = gr.Interface(fn=process_image, inputs=gr.Image(), outputs="text", title="Upload an Image")
64
+
65
+ tabbed_interface = gr.TabbedInterface([video_upload, pdf_upload, image_upload], ["Video", "PDF", "Image"])
66
+
67
+ demo = gr.Blocks()
68
+
69
+ with demo:
70
+ with gr.Tab("Chat Interface"):
71
+ gr.ChatInterface(
72
+ respond,
73
+ additional_inputs=[
74
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
75
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
76
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"), # Corrected syntax error here
77
+ gr.Slider(
78
+ minimum=0.1,
79
+ maximum=1.0,
80
+ value=0.95,
81
+ step=0.05,
82
+ label="Top-p (nucleus sampling)",
83
+ ),
84
+ ],
85
+ )
86
+ with gr.Tab("Upload Files"):
87
+ tabbed_interface
88
 
89
  if __name__ == "__main__":
90
  demo.launch()