Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,15 +73,18 @@ def classify_csv(file):
|
|
| 73 |
return None, f"Error: {str(e)}"
|
| 74 |
|
| 75 |
def chatbot_response(history, user_input, source):
|
| 76 |
-
# Always
|
| 77 |
-
user_input = user_input.lower()
|
|
|
|
|
|
|
| 78 |
context = context_storage["context"] if source == "Single Article" else context_storage["bulk_context"]
|
| 79 |
|
| 80 |
-
#
|
| 81 |
if context:
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
return history, ""
|
| 87 |
|
|
|
|
| 73 |
return None, f"Error: {str(e)}"
|
| 74 |
|
| 75 |
def chatbot_response(history, user_input, source):
|
| 76 |
+
# Always use the user input as a question for the QA pipeline
|
| 77 |
+
user_input = user_input.lower() # Optionally make it lowercase
|
| 78 |
+
|
| 79 |
+
# Get the context (single article or bulk context)
|
| 80 |
context = context_storage["context"] if source == "Single Article" else context_storage["bulk_context"]
|
| 81 |
|
| 82 |
+
# Ensure there's context to query
|
| 83 |
if context:
|
| 84 |
+
with st.spinner("Finding answer..."):
|
| 85 |
+
result = qa_pipeline(question=user_input, context=context)
|
| 86 |
+
answer = result["answer"]
|
| 87 |
+
history.append([user_input, answer])
|
| 88 |
|
| 89 |
return history, ""
|
| 90 |
|