Skip to content

Commit

Permalink
Merge pull request #48 from Vero-Ventures/Michelle_chatbot_frontend
Browse files Browse the repository at this point in the history
Michelle chatbot frontend
  • Loading branch information
kellyhagg authored May 28, 2024
2 parents a0be873 + 6e0bc62 commit 75b4fcf
Show file tree
Hide file tree
Showing 13 changed files with 771 additions and 347 deletions.
29 changes: 26 additions & 3 deletions src/app/api/chat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,48 @@
from flask import Flask, request, jsonify
from flask_cors import CORS
from pathlib import Path
import json
import logging
logging.basicConfig(level=logging.DEBUG)

# Add the parent directory to the system path to import model
sys.path.append(str(Path(__file__).resolve().parents[2] / 'model'))
from model import process_message # Import process_message from model.py

app = Flask(__name__)
CORS(app) # This will enable CORS for all routes
CORS(app, resources={r"/api/*": {
"origins": "http://localhost:3000", # Adjust this as necessary
"methods": ["GET", "POST"],
"allow_headers": ["Content-Type", "Authorization"],
"supports_credentials": True
}})

@app.route('/api/chat', methods=['POST'])
@app.route('/api/chat/send_message', methods=['POST'])
def chat():
app.logger.debug("Received request for /api/chat/send_message")

data = request.json
user_message = data.get('message', '')

if not user_message:
app.logger.error("No message provided in the request")
return jsonify({"error": "No message provided"}), 400

response_message = process_message(user_message)

app.logger.debug("Processed message: %s", response_message)

return jsonify({"answer": response_message})

@app.route('/api/chat/submit_responses', methods=['POST'])
def submit_responses():
data = request.json
responses = data.get('responses', {})

with open('responses.json', 'w') as file:
json.dump(responses, file)

return jsonify({"status": "Success", "message": "Data saved successfully"})

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
app.run(host='0.0.0.0', port=8000, debug=True)
98 changes: 0 additions & 98 deletions src/app/chat/actionProvider.js

This file was deleted.

Loading

0 comments on commit 75b4fcf

Please sign in to comment.