Spaces:
Sleeping
Sleeping
fix for The gr.ChatInterface component does not have a visible parameter
Browse filesfix 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.
app.py
CHANGED
|
@@ -129,20 +129,21 @@ with gr.Blocks(title="PDF Chatbot") as demo:
|
|
| 129 |
interactive=True
|
| 130 |
)
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
|
| 142 |
file_upload_input.upload(
|
| 143 |
fn=chatbot.process_pdf,
|
| 144 |
inputs=[file_upload_input],
|
| 145 |
-
outputs=[file_upload_input,
|
| 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()
|