jithenderchoudary commited on
Commit
191db0a
·
verified ·
1 Parent(s): 9decea6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -7,7 +7,7 @@ app = Flask(__name__)
7
  # Load the Hugging Face model for Question Answering (FAQ-based)
8
  faq_model = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
9
 
10
- # Connect to Salesforce (replace with your credentials)
11
  sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')
12
 
13
  # Function to get the answer from the model
@@ -31,14 +31,19 @@ def ask_question():
31
  data = request.get_json()
32
  question = data.get('question')
33
 
34
- # Define the FAQ context (static or fetched from a dynamic source)
35
- faq_context = "Here are some frequently asked questions and answers about our service..."
36
-
 
 
 
 
 
37
  # Get the answer to the question
38
  answer = get_answer(question, faq_context)
39
 
40
- # If the answer requires further assistance, create a case in Salesforce
41
- if "need help" in answer or "contact us" in answer:
42
  create_case('Customer Support Needed', answer)
43
 
44
  return jsonify({"answer": answer})
 
7
  # Load the Hugging Face model for Question Answering (FAQ-based)
8
  faq_model = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
9
 
10
+ # Salesforce connection (replace with your credentials)
11
  sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')
12
 
13
  # Function to get the answer from the model
 
31
  data = request.get_json()
32
  question = data.get('question')
33
 
34
+ # Define the FAQ context (static or dynamic data can be used here)
35
+ faq_context = """
36
+ Here are some frequently asked questions and answers about our services.
37
+ 1. How do I contact customer support? - You can email us at support@company.com.
38
+ 2. What are your business hours? - We are open from 9 AM to 6 PM, Monday to Friday.
39
+ 3. How do I reset my password? - Click on 'Forgot Password' on the login page.
40
+ """
41
+
42
  # Get the answer to the question
43
  answer = get_answer(question, faq_context)
44
 
45
+ # If the answer suggests further help, create a case in Salesforce
46
+ if "contact us" in answer or "need help" in answer:
47
  create_case('Customer Support Needed', answer)
48
 
49
  return jsonify({"answer": answer})