Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
| 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
|
| 35 |
-
faq_context = "
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Get the answer to the question
|
| 38 |
answer = get_answer(question, faq_context)
|
| 39 |
|
| 40 |
-
# If the answer
|
| 41 |
-
if "
|
| 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})
|