Ashendilantha commited on
Commit
3a5f15a
·
verified ·
1 Parent(s): d6c75dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
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 run the QA pipeline with the context
77
- user_input = user_input.lower()
 
 
78
  context = context_storage["context"] if source == "Single Article" else context_storage["bulk_context"]
79
 
80
- # Run the QA pipeline and get the answer
81
  if context:
82
- result = qa_pipeline(question=user_input, context=context)
83
- answer = result["answer"]
84
- history.append([user_input, answer])
 
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