anasmkh commited on
Commit
c444cc4
·
verified ·
1 Parent(s): 29c811a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
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
- with gr.Blocks() as demo:
118
- gr.Markdown("# Chat Interface for LlamaIndex with File Upload")
119
-
120
- with gr.Tab("Chat"):
121
- chatbot = gr.Chatbot(label="LlamaIndex Chatbot")
122
- user_input = gr.Textbox(
123
- placeholder="Ask a question...", label="Enter your question"
124
- )
125
- submit_button = gr.Button("Send")
126
- btn_clear = gr.Button("Delete Context")
127
- chat_history = gr.State([])
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
- btn_clear.click(fn=clear_history, outputs=[chatbot, user_input])
133
-
134
- with gr.Tab("Upload"):
135
- gr.Markdown("### Upload a file to add its content to the index")
136
- file_upload = gr.File(label="Choose a file")
137
- upload_button = gr.Button("Upload and Process")
138
- upload_status = gr.Textbox(label="Upload Status")
139
- upload_button.click(process_uploaded_file, inputs=[file_upload], outputs=[upload_status])
 
 
 
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