2 Commits

Author SHA1 Message Date
joakimp cecc2f7520 Fortsatta ändringar för tester och felsökningsändamål 2024-07-17 09:21:34 +02:00
joakimp 1b7142f157 Mera felsökning 2024-07-16 23:36:59 +02:00
+12 -10
View File
@@ -2,7 +2,7 @@
# Import the necessary functions from ollama, Flask, requests, threading # Import the necessary functions from ollama, Flask, requests, threading
from ollama import Client from ollama import Client
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
import requests #import requests
#import threading #import threading
# Initialize a Flask application # Initialize a Flask application
@@ -10,18 +10,20 @@ app = Flask(__name__)
@app.route('/api/chat', methods=['POST']) @app.route('/api/chat', methods=['POST'])
def chat(): def chat():
# Get the message from the JSON in the request body if request.method == 'POST':
data = request.get_json() # Get the message from the JSON in the request body
message = data.get('query') data = request.get_json()
message = data.get('query')
if message: 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')}) response = request.post('http://localhost:11434', json={"model": "llama3",'prompt': message})
else: return jsonify({'response': response.json().get('result')})
return jsonify({'error': 'No query provided'}), 400 else:
return jsonify({'error': 'No query provided'}), 400
@app.route('/smartassist', methods=['POST']) @app.route('/smartassist', methods=["POST"])
def smartassist(): def smartassist():
# Extract the query from the incoming JSON data # Extract the query from the incoming JSON data
data = request.json data = request.json