Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,11 +38,9 @@ qa = ConversationalRetrievalChain.from_llm(
|
|
| 38 |
retriever=retriever
|
| 39 |
)
|
| 40 |
|
| 41 |
-
chat_history = []
|
| 42 |
-
|
| 43 |
# --- 5️⃣ Respond function ---
|
| 44 |
def respond(message, chat_history):
|
| 45 |
-
|
| 46 |
chat_history = chat_history[-6:] # keep last 3 exchanges
|
| 47 |
result = qa({"question": message, "chat_history": chat_history})
|
| 48 |
chat_history.append((message, result["answer"]))
|
|
@@ -86,7 +84,7 @@ with gr.Blocks() as demo:
|
|
| 86 |
|
| 87 |
def exit_case():
|
| 88 |
return (
|
| 89 |
-
gr.update(value="<h2>Session ended. You exited the simulation.</h2>"), # hide warning
|
| 90 |
gr.update(visible=False), # chatbot
|
| 91 |
gr.update(visible=False), # user_input
|
| 92 |
gr.update(visible=False), # submit_btn
|
|
@@ -115,3 +113,4 @@ with gr.Blocks() as demo:
|
|
| 115 |
# --- 7️⃣ Launch ---
|
| 116 |
if __name__ == "__main__":
|
| 117 |
demo.launch(share=True, enable_queue=True)
|
|
|
|
|
|
| 38 |
retriever=retriever
|
| 39 |
)
|
| 40 |
|
|
|
|
|
|
|
| 41 |
# --- 5️⃣ Respond function ---
|
| 42 |
def respond(message, chat_history):
|
| 43 |
+
chat_history = chat_history or []
|
| 44 |
chat_history = chat_history[-6:] # keep last 3 exchanges
|
| 45 |
result = qa({"question": message, "chat_history": chat_history})
|
| 46 |
chat_history.append((message, result["answer"]))
|
|
|
|
| 84 |
|
| 85 |
def exit_case():
|
| 86 |
return (
|
| 87 |
+
gr.update(value="<h2>Session ended. You exited the simulation.</h2>"), # hide warning
|
| 88 |
gr.update(visible=False), # chatbot
|
| 89 |
gr.update(visible=False), # user_input
|
| 90 |
gr.update(visible=False), # submit_btn
|
|
|
|
| 113 |
# --- 7️⃣ Launch ---
|
| 114 |
if __name__ == "__main__":
|
| 115 |
demo.launch(share=True, enable_queue=True)
|
| 116 |
+
|