Spaces:
Sleeping
Sleeping
app13
Browse files
app.py
CHANGED
|
@@ -104,11 +104,18 @@ qa_chain = ConversationalRetrievalChain.from_llm(
|
|
| 104 |
get_chat_history = lambda h : h
|
| 105 |
)
|
| 106 |
|
| 107 |
-
def qa_response(
|
| 108 |
-
|
| 109 |
-
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
# Combine both interfaces into a single app
|
| 114 |
gr.TabbedInterface(
|
|
|
|
| 104 |
get_chat_history = lambda h : h
|
| 105 |
)
|
| 106 |
|
| 107 |
+
def qa_response(question, chat_history):
|
| 108 |
+
# Add user's question to chat history
|
| 109 |
+
chat_history.append(("User", question))
|
| 110 |
|
| 111 |
+
# Get response from the conversational retrieval chain
|
| 112 |
+
response = qa_chain.invoke(chat_history)
|
| 113 |
+
|
| 114 |
+
# Extract and return the assistant's answer from the response
|
| 115 |
+
assistant_answer = response.get("answer", "I don't know.")
|
| 116 |
+
return assistant_answer + " thanks for asking!"
|
| 117 |
+
|
| 118 |
+
chatbot_gradio_app = gr.ChatInterface(fn=qa_response, live=True)
|
| 119 |
|
| 120 |
# Combine both interfaces into a single app
|
| 121 |
gr.TabbedInterface(
|