Spaces:
Sleeping
Sleeping
attempt to fix UI issue
Browse filesfix info: create a row containing the chat interface and initially makes it invisible. When a PDF file is uploaded, the row becomes visible, showing the chat interface.
app.py
CHANGED
|
@@ -114,15 +114,15 @@ with gr.Blocks(title="PDF Chatbot") as demo:
|
|
| 114 |
interactive=True
|
| 115 |
)
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
|
| 127 |
def process_and_show_chat(file):
|
| 128 |
chatbot.process_pdf(file)
|
|
@@ -131,7 +131,7 @@ with gr.Blocks(title="PDF Chatbot") as demo:
|
|
| 131 |
file_upload_input.upload(
|
| 132 |
fn=process_and_show_chat,
|
| 133 |
inputs=[file_upload_input],
|
| 134 |
-
outputs=[
|
| 135 |
)
|
| 136 |
|
| 137 |
demo.launch()
|
|
|
|
| 114 |
interactive=True
|
| 115 |
)
|
| 116 |
|
| 117 |
+
with gr.Row(visible=False) as chat_row:
|
| 118 |
+
chat_interface = gr.ChatInterface(
|
| 119 |
+
fn=chatbot.chat_with_pdf,
|
| 120 |
+
chatbot=gr.Chatbot(type="messages"),
|
| 121 |
+
textbox=gr.Textbox(placeholder="Type your question here...", scale=7),
|
| 122 |
+
examples=[["What is the main topic of the document?"], ["Summarize the key findings."], ["Who are the authors?"]],
|
| 123 |
+
title="Chat Interface",
|
| 124 |
+
theme="soft"
|
| 125 |
+
)
|
| 126 |
|
| 127 |
def process_and_show_chat(file):
|
| 128 |
chatbot.process_pdf(file)
|
|
|
|
| 131 |
file_upload_input.upload(
|
| 132 |
fn=process_and_show_chat,
|
| 133 |
inputs=[file_upload_input],
|
| 134 |
+
outputs=[chat_row, file_upload_input]
|
| 135 |
)
|
| 136 |
|
| 137 |
demo.launch()
|