Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ import accelerate
|
|
22 |
|
23 |
def load_doc(list_file_path, chunk_size, chunk_overlap):
|
24 |
# Processing for one document only
|
25 |
-
# loader =
|
26 |
# pages = loader.load()
|
27 |
loaders = [PyPDFLoader(x) for x in list_file_path]
|
28 |
pages = []
|
@@ -167,21 +167,41 @@ def demo():
|
|
167 |
qa_chain = gr.State()
|
168 |
collection_name = gr.State()
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
with gr.
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
with gr.Row():
|
183 |
msg = gr.Textbox(placeholder="Type message", container=True)
|
184 |
with gr.Row():
|
185 |
submit_btn = gr.Button("Submit")
|
186 |
clear_btn = gr.ClearButton([msg, chatbot])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
|
|
22 |
|
23 |
def load_doc(list_file_path, chunk_size, chunk_overlap):
|
24 |
# Processing for one document only
|
25 |
+
# loader = Py PDFLoader(file_path)
|
26 |
# pages = loader.load()
|
27 |
loaders = [PyPDFLoader(x) for x in list_file_path]
|
28 |
pages = []
|
|
|
167 |
qa_chain = gr.State()
|
168 |
collection_name = gr.State()
|
169 |
|
170 |
+
gr.Markdown("""RAG USING MIXTRAL""")
|
171 |
+
|
172 |
+
with gr.Row():
|
173 |
+
chatbot = gr.Chatbot(height=300)
|
174 |
+
with gr.Accordion("Advanced - Document references", open=False):
|
175 |
+
with gr.Row():
|
176 |
+
doc_source1 = gr.Textbox(label="Reference 1", lines=2, container=True, scale=20)
|
177 |
+
source1_page = gr.Number(label="Page", scale=1)
|
178 |
+
with gr.Row():
|
179 |
+
doc_source2 = gr.Textbox(label="Reference 2", lines=2, container=True, scale=20)
|
180 |
+
source2_page = gr.Number(label="Page", scale=1)
|
181 |
+
with gr.Row():
|
182 |
+
doc_source3 = gr.Textbox(label="Reference 3", lines=2, container=True, scale=20)
|
183 |
+
source3_page = gr.Number(label="Page", scale=1)
|
184 |
with gr.Row():
|
185 |
msg = gr.Textbox(placeholder="Type message", container=True)
|
186 |
with gr.Row():
|
187 |
submit_btn = gr.Button("Submit")
|
188 |
clear_btn = gr.ClearButton([msg, chatbot])
|
189 |
+
|
190 |
+
# Chatbot events
|
191 |
+
submit_btn.click(conversation, \
|
192 |
+
inputs=[qa_chain, msg, chatbot], \
|
193 |
+
outputs=[qa_chain, msg, chatbot, doc_source1, source1_page, doc_source2, source2_page, doc_source3, source3_page], \
|
194 |
+
queue=False)
|
195 |
+
clear_btn.click(lambda:[None,"",0,"",0,"",0], \
|
196 |
+
inputs=None, \
|
197 |
+
outputs=[chatbot, doc_source1, source1_page, doc_source2, source2_page, doc_source3, source3_page], \
|
198 |
+
queue=False)
|
199 |
+
demo.queue().launch(debug=True)
|
200 |
+
|
201 |
+
# Replace the placeholders with your actual functions
|
202 |
+
def conversation(*args, **kwargs):
|
203 |
+
pass
|
204 |
+
|
205 |
+
|
206 |
+
|
207 |
|