Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,7 +88,15 @@ def chat(message, history):
|
|
| 88 |
history.append([message, full])
|
| 89 |
return history, ""
|
| 90 |
#============starting extract_docx_text
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
def extract_docx_text(file_path):
|
| 93 |
doc = Document(file_path)
|
| 94 |
final_data = []
|
|
@@ -318,12 +326,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 318 |
🚧 Coming Soon 🚧
|
| 319 |
</div>"""
|
| 320 |
)
|
| 321 |
-
with gr.TabItem("
|
| 322 |
-
gr.
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
demo.queue().launch()
|
|
|
|
| 88 |
history.append([message, full])
|
| 89 |
return history, ""
|
| 90 |
#============starting extract_docx_text
|
| 91 |
+
def respond(message, history):
|
| 92 |
+
answer = qa_chain.invoke(message)
|
| 93 |
+
docs = retriever.invoke(message) # Global or pass as state
|
| 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 |
+
history.append([message, full_answer])
|
| 98 |
+
return history, ""
|
| 99 |
+
#====================
|
| 100 |
def extract_docx_text(file_path):
|
| 101 |
doc = Document(file_path)
|
| 102 |
final_data = []
|
|
|
|
| 326 |
🚧 Coming Soon 🚧
|
| 327 |
</div>"""
|
| 328 |
)
|
| 329 |
+
with gr.TabItem("ChatBot-NRL manual-goods"):
|
| 330 |
+
gr.Markdown("# RAG Chatbot - procurement manual of Goods")
|
| 331 |
+
chatbot = gr.Chatbot(height=500, type="tuples") # Explicit tuples format
|
| 332 |
+
msg = gr.Textbox(placeholder="Ask about GeM...", scale=4)
|
| 333 |
+
clear = gr.Button("Clear")
|
| 334 |
+
|
| 335 |
+
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
| 336 |
+
clear.click(lambda: ([], ""), None, chatbot)
|
| 337 |
demo.queue().launch()
|