vidyasharma17 commited on
Commit
854d1fe
1 Parent(s): 74d994f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -22
app.py CHANGED
@@ -2,7 +2,7 @@ import pickle
2
  from sklearn.feature_extraction.text import CountVectorizer
3
  import gradio as gr
4
 
5
- # Load the Naive Bayes model and vectorizer
6
  with open("naive_bayes_model.pkl", "rb") as model_file:
7
  clf = pickle.load(model_file)
8
 
@@ -14,23 +14,7 @@ responses = {
14
  "activate_my_card": "To activate your card, log in to the app and navigate to the 'Activate Card' section.",
15
  "age_limit": "The minimum age to use this service is 18 years.",
16
  "apple_pay_or_google_pay": "Yes, you can use both Apple Pay and Google Pay with your card.",
17
- "atm_support": "Your card is supported by ATMs that display the Visa or Mastercard logo.",
18
- "automatic_top_up": "You can enable automatic top-up in the app under the 'Top-Up Settings' section.",
19
- "balance_not_updated_after_bank_transfer": "If your balance hasn’t updated after a bank transfer, please wait for 24 hours. If the issue persists, contact support.",
20
- "beneficiary_not_allowed": "Ensure that the beneficiary details are correct. Some accounts may have restrictions; check with customer support for clarification.",
21
- "cancel_transfer": "To cancel a transfer, go to the 'Transaction History' section in the app and select the transfer you wish to cancel.",
22
- "card_about_to_expire": "If your card is about to expire, a replacement will be sent automatically. Contact support if you haven’t received it.",
23
- "card_arrival": "New cards usually arrive within 7-10 business days after being issued.",
24
- "card_not_working": "If your card isn't working, ensure it is activated and has sufficient balance. Contact support if the issue persists.",
25
- "change_pin": "You can change your PIN using the app or at any ATM with your card.",
26
- "contactless_not_working": "Ensure your card supports contactless payments and check if the terminal accepts it. If the issue persists, contact support.",
27
- "country_support": "Your card is supported in all countries where Visa/Mastercard is accepted. Check the app for restrictions.",
28
- "declined_card_payment": "Card payments can be declined due to insufficient balance, incorrect PIN, or restrictions on the merchant. Check your app for details.",
29
- "lost_or_stolen_card": "If your card is lost or stolen, block it immediately in the app under the 'Card Management' section and request a replacement.",
30
- "pending_card_payment": "Pending payments are usually resolved within 2-3 business days. Contact support if the status doesn't update.",
31
- "refund_not_showing_up": "Refunds can take up to 7 business days to appear. Check with the merchant or contact support if it takes longer.",
32
- "top_up_failed": "Top-up failures may occur due to incorrect details or insufficient balance in the source account. Check your app for details.",
33
- "transfer_not_received_by_recipient": "If the recipient hasn't received the transfer, ensure the details are correct. Contact support for further assistance.",
34
  }
35
 
36
  # Define chatbot response logic
@@ -39,15 +23,35 @@ def chatbot_response(user_input):
39
  predicted_label = clf.predict(vectorized_input)[0]
40
  return responses.get(predicted_label, "Sorry, I couldn't understand your question.")
41
 
42
- # Define Gradio interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  interface = gr.Interface(
44
  fn=chatbot_response,
45
  inputs=gr.Textbox(lines=2, placeholder="Ask your fintech question here..."),
46
  outputs="text",
47
- title="Banking Chatbot",
48
- description="A chatbot to handle banking-related queries using a Naive Bayes model."
49
  )
50
 
51
  if __name__ == "__main__":
52
  # Launch the Gradio app
53
- interface.launch()
 
2
  from sklearn.feature_extraction.text import CountVectorizer
3
  import gradio as gr
4
 
5
+ # Load Naive Bayes model and vectorizer
6
  with open("naive_bayes_model.pkl", "rb") as model_file:
7
  clf = pickle.load(model_file)
8
 
 
14
  "activate_my_card": "To activate your card, log in to the app and navigate to the 'Activate Card' section.",
15
  "age_limit": "The minimum age to use this service is 18 years.",
16
  "apple_pay_or_google_pay": "Yes, you can use both Apple Pay and Google Pay with your card.",
17
+ # Add remaining responses here...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
  # Define chatbot response logic
 
23
  predicted_label = clf.predict(vectorized_input)[0]
24
  return responses.get(predicted_label, "Sorry, I couldn't understand your question.")
25
 
26
+ # Define UI description with sample questions
27
+ description = """
28
+ ### FinTech Chatbot
29
+
30
+ This chatbot can assist you with a variety of fintech-related queries. Below are some sample questions you can ask:
31
+
32
+ - How do I activate my card?
33
+ - What is the minimum age required to use this service?
34
+ - Can I use Apple Pay with my card?
35
+ - Which ATMs can I use my card with?
36
+ - How can I set up automatic top-up for my account?
37
+ - Why hasn't my balance updated after making a bank transfer?
38
+ - Why can’t I add a beneficiary to my account?
39
+ - Can I cancel a transfer I’ve made?
40
+ - What should I do if my card is about to expire?
41
+ - How long does it take for a new card to arrive?
42
+ - My card has been stolen. What should I do?
43
+ - Why hasn’t the recipient received my transfer?
44
+ """
45
+
46
+ # Define the Gradio interface
47
  interface = gr.Interface(
48
  fn=chatbot_response,
49
  inputs=gr.Textbox(lines=2, placeholder="Ask your fintech question here..."),
50
  outputs="text",
51
+ title="FinTech Chatbot",
52
+ description=description
53
  )
54
 
55
  if __name__ == "__main__":
56
  # Launch the Gradio app
57
+ interface.launch()