Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,8 +94,10 @@ def respond(message, history):
|
|
| 94 |
refs = [f"Page {d.metadata.get('page', 'N/A')}" for d in docs]
|
| 95 |
full_answer = f"{answer}\n\n**Refs:** {' | '.join(refs)}"
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
#====================
|
| 100 |
def extract_docx_text(file_path):
|
| 101 |
doc = Document(file_path)
|
|
@@ -327,11 +329,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 327 |
</div>"""
|
| 328 |
)
|
| 329 |
with gr.TabItem("ChatBot-NRL manual-goods"):
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
| 337 |
demo.queue().launch()
|
|
|
|
| 94 |
refs = [f"Page {d.metadata.get('page', 'N/A')}" for d in docs]
|
| 95 |
full_answer = f"{answer}\n\n**Refs:** {' | '.join(refs)}"
|
| 96 |
|
| 97 |
+
# Append in messages format
|
| 98 |
+
history.append({"role": "user", "content": message})
|
| 99 |
+
history.append({"role": "assistant", "content": full_answer})
|
| 100 |
+
return history
|
| 101 |
#====================
|
| 102 |
def extract_docx_text(file_path):
|
| 103 |
doc = Document(file_path)
|
|
|
|
| 329 |
</div>"""
|
| 330 |
)
|
| 331 |
with gr.TabItem("ChatBot-NRL manual-goods"):
|
| 332 |
+
gr.Markdown("# RAG Chatbot with Page References")
|
| 333 |
+
chatbot = gr.Chatbot(height=500) # No 'type' arg!
|
| 334 |
+
msg = gr.Textbox(placeholder="What is GeM?", scale=4)
|
| 335 |
+
submit = gr.Button("Send", scale=1)
|
| 336 |
+
clear = gr.Button("Clear")
|
| 337 |
+
|
| 338 |
+
submit.click(respond, [msg, chatbot], [chatbot, msg])
|
| 339 |
+
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
| 340 |
+
clear.click(lambda: [], None, chatbot, queue=False)
|
| 341 |
demo.queue().launch()
|