Update app.py
Browse files
app.py
CHANGED
@@ -114,29 +114,29 @@ def gradio_chatbot():
|
|
114 |
- "Chat" for interacting with the chat engine.
|
115 |
- "Upload" for uploading new files to update the index.
|
116 |
"""
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
submit_button.click(chat_with_ai, inputs=[user_input, chat_history],
|
129 |
-
outputs=[chatbot, user_input])
|
130 |
-
user_input.submit(chat_with_ai, inputs=[user_input, chat_history],
|
131 |
outputs=[chatbot, user_input])
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
140 |
|
141 |
return demo
|
142 |
|
|
|
114 |
- "Chat" for interacting with the chat engine.
|
115 |
- "Upload" for uploading new files to update the index.
|
116 |
"""
|
117 |
+
with gr.Blocks() as demo:
|
118 |
+
gr.Markdown("# Chat Interface for LlamaIndex with File Upload")
|
119 |
+
|
120 |
+
with gr.Tab("Chat"):
|
121 |
+
# Chat interface components
|
122 |
+
chatbot = gr.Chatbot(label="LlamaIndex Chatbot")
|
123 |
+
user_input = gr.Textbox(placeholder="Ask a question...", label="Enter your question")
|
124 |
+
submit_button = gr.Button("Send")
|
125 |
+
btn_clear = gr.Button("Delete Context")
|
126 |
+
chat_history = gr.State([])
|
127 |
+
submit_button.click(chat_with_ai, inputs=[user_input, chat_history],
|
|
|
|
|
|
|
128 |
outputs=[chatbot, user_input])
|
129 |
+
user_input.submit(chat_with_ai, inputs=[user_input, chat_history],
|
130 |
+
outputs=[chatbot, user_input])
|
131 |
+
btn_clear.click(fn=clear_history, outputs=[chatbot, user_input])
|
132 |
+
|
133 |
+
with gr.Tab("Upload"):
|
134 |
+
gr.Markdown("### Upload a file to add its content to the index")
|
135 |
+
file_upload = gr.File(label="Choose a file")
|
136 |
+
upload_button = gr.Button("Upload and Process")
|
137 |
+
upload_status = gr.Textbox(label="Upload Status")
|
138 |
+
upload_button.click(process_uploaded_file, inputs=[file_upload], outputs=[upload_status])
|
139 |
+
|
140 |
|
141 |
return demo
|
142 |
|