nikhmr1235 commited on
Commit
f6f31a0
·
verified ·
1 Parent(s): 79ff6ae

fix for The gr.ChatInterface component does not have a visible parameter

Browse files

fix info: the gr.ChatInterface is wrapped in a gr.Group component named chat_group. The visible parameter is applied to the chat_group instead of the chat_interface. The file_upload_input.upload event now updates the visibility of the chat_group instead of the chat_interface.

Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -129,20 +129,21 @@ with gr.Blocks(title="PDF Chatbot") as demo:
129
  interactive=True
130
  )
131
 
132
- chat_interface = gr.ChatInterface(
133
- fn=chatbot.chat_with_pdf,
134
- chatbot=gr.Chatbot(type="messages"),
135
- textbox=gr.Textbox(placeholder="Type your question here...", scale=7),
136
- examples=[["What is the main topic of the document?"], ["Summarize the key findings."], ["Who are the authors?"]],
137
- title="Chat Interface",
138
- theme="soft",
139
- visible=False
140
- )
 
141
 
142
  file_upload_input.upload(
143
  fn=chatbot.process_pdf,
144
  inputs=[file_upload_input],
145
- outputs=[file_upload_input, chat_interface]
146
  )
147
 
148
  demo.launch()
 
129
  interactive=True
130
  )
131
 
132
+ chat_group = gr.Group(visible=False)
133
+ with chat_group:
134
+ chat_interface = gr.ChatInterface(
135
+ fn=chatbot.chat_with_pdf,
136
+ chatbot=gr.Chatbot(type="messages"),
137
+ textbox=gr.Textbox(placeholder="Type your question here...", scale=7),
138
+ examples=[["What is the main topic of the document?"], ["Summarize the key findings."], ["Who are the authors?"]],
139
+ title="Chat Interface",
140
+ theme="soft"
141
+ )
142
 
143
  file_upload_input.upload(
144
  fn=chatbot.process_pdf,
145
  inputs=[file_upload_input],
146
+ outputs=[file_upload_input, chat_group]
147
  )
148
 
149
  demo.launch()