Ashendilantha commited on
Commit
d6c75dc
Β·
verified Β·
1 Parent(s): 5f72ec8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -16
app.py CHANGED
@@ -73,30 +73,16 @@ def classify_csv(file):
73
  return None, f"Error: {str(e)}"
74
 
75
  def chatbot_response(history, user_input, source):
 
76
  user_input = user_input.lower()
77
  context = context_storage["context"] if source == "Single Article" else context_storage["bulk_context"]
78
- num_articles = context_storage["num_articles"]
79
-
80
- if "number of articles" in user_input or "how many articles" in user_input:
81
- answer = f"There are {num_articles} articles in the uploaded CSV."
82
- history.append([user_input, answer])
83
- return history, ""
84
 
 
85
  if context:
86
  result = qa_pipeline(question=user_input, context=context)
87
  answer = result["answer"]
88
  history.append([user_input, answer])
89
- return history, ""
90
 
91
- responses = {
92
- "hello": "πŸ‘‹ Hello! How can I assist you with news today?",
93
- "hi": "😊 Hi there! What do you want to know about news?",
94
- "how are you": "πŸ€– I'm just a bot, but I'm here to help!",
95
- "thank you": "πŸ™ You're welcome! Let me know if you need anything else.",
96
- "news": "πŸ“° I can classify news into Business, Sports, Politics, and more!",
97
- }
98
- response = responses.get(user_input, "πŸ€” I'm here to help with news classification and general info. Ask me about news topics!")
99
- history.append([user_input, response])
100
  return history, ""
101
 
102
  # Streamlit App Layout
 
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
 
88
  # Streamlit App Layout