added goal achievment preditions
This commit is contained in:
@@ -119,5 +119,65 @@ def use_bot_predict_assessments():
|
||||
|
||||
return jsonify({"predictions": response}), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": "Internal Server Error", "message": str(e)}), 500
|
||||
|
||||
|
||||
@bot.route('/suggest_assessment_frequencies', methods=['POST'])
|
||||
def use_bot_suggest_frequencies():
|
||||
try:
|
||||
# Retrieve JSON data from the request
|
||||
data = request.get_json()
|
||||
|
||||
# Check if 'sops' is present in the request data
|
||||
sops = data.get('sops')
|
||||
if not sops:
|
||||
return jsonify({"error": "Invalid data", "message": "The 'sops' field is missing or not formatted correctly."}), 400
|
||||
|
||||
# Instantiate the chatbot service
|
||||
chatbot = Chatbot()
|
||||
|
||||
# Call the prediction method
|
||||
response = chatbot.recommend_assessment_frequencies(sops)
|
||||
|
||||
if not response:
|
||||
return jsonify({"error": "Prediction Failed", "message": "The prediction process returned no results."}), 400
|
||||
|
||||
# Return the successful response with predictions
|
||||
return jsonify({"response": response}), 200
|
||||
|
||||
except Exception as e:
|
||||
# Log the error (optional, but helpful for debugging)
|
||||
print(f"Error in /suggest_assessment_frequencies: {e}")
|
||||
|
||||
return jsonify({"error": "Internal Server Error", "message": str(e)}), 500
|
||||
|
||||
|
||||
|
||||
@bot.route('/predict_goal_achievment_proba', methods=['POST'])
|
||||
def predict_goal_achievement():
|
||||
try:
|
||||
# Retrieve JSON data from the request
|
||||
data = request.get_json()
|
||||
company_info = data.get('company_info')
|
||||
companyid = data.get('companyid')
|
||||
|
||||
|
||||
if not company_info or not companyid:
|
||||
return jsonify({"error": "Missing data", "message": "Company info, company ID, or N value not provided."}), 400
|
||||
|
||||
# Instantiate the chatbot service
|
||||
chatbot = Chatbot()
|
||||
|
||||
# Call the prediction method
|
||||
response = chatbot.predict_goal_achievement_probability(
|
||||
company_info=company_info,
|
||||
companyid=companyid
|
||||
)
|
||||
if not response:
|
||||
return jsonify({"error": "No predictions available", "message": "Prediction process failed."}), 400
|
||||
|
||||
return jsonify({"predictions": response}), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": "Internal Server Error", "message": str(e)}), 500
|
||||
Reference in New Issue
Block a user