diff --git a/smartassist/src/backend.py b/smartassist/src/backend.py index c7148a2..3e4ab1e 100644 --- a/smartassist/src/backend.py +++ b/smartassist/src/backend.py @@ -8,20 +8,20 @@ import requests # Initialize a Flask application app = Flask(__name__) -@app.route('/api/chat', methods=['POST']) +@app.route('/chat', methods=['POST']) def chat(): # Get the message from the JSON in the request body data = request.get_json() message = data.get('query') if message: - response = requests.post('localhost::11434', json={"model": "llama3",'prompt': message}) + response = requests.post('http://localhost:11434', json={"model": "llama3",'prompt': message}) return jsonify({'response': response.json().get('result')}) else: return jsonify({'error': 'No query provided'}), 400 -@app.route('/smartassist', methods=['POST']) +@app.route('/smartassist', methods=["POST"]) def smartassist(): # Extract the query from the incoming JSON data data = request.json diff --git a/smartassist/src/frontend.js b/smartassist/src/frontend.js index 0b80540..40cad39 100644 --- a/smartassist/src/frontend.js +++ b/smartassist/src/frontend.js @@ -41,7 +41,7 @@ function sendMessage() { const xhr = new XMLHttpRequest(); // Configure the request - xhr.open('POST', '/api/chat'); // Set method to POST and URL + xhr.open('POST', '/chat'); // Set method to POST and URL xhr.setRequestHeader('Content-Type', 'application/json'); // Essential for sending JSON // Handle response data