Spaces:
Running
Running
vidyasharma17
commited on
Delete app.py
Browse files
app.py
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
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 |
-
|
9 |
-
with open("vectorizer.pkl", "rb") as vectorizer_file:
|
10 |
-
vectorizer = pickle.load(vectorizer_file)
|
11 |
-
|
12 |
-
# Define responses dictionary
|
13 |
-
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
|
37 |
-
def chatbot_response(user_input):
|
38 |
-
vectorized_input = vectorizer.transform([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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|