From 1b7142f157d6185569a869ea9b184e395372bf74 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 16 Jul 2024 23:36:59 +0200 Subject: [PATCH] =?UTF-8?q?Mera=20fels=C3=B6kning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/backend.py | 6 +++--- smartassist/src/frontend.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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