Updated the backen and the requirements to allow chat interaction
This commit is contained in:
@@ -14,6 +14,7 @@ def get_response(user_query):
|
||||
|
||||
# Flask endpoint for user interaction
|
||||
from flask import Flask, request, jsonify
|
||||
import requests
|
||||
|
||||
# Initialize a Flask application
|
||||
app = Flask(__name__)
|
||||
@@ -30,6 +31,16 @@ def smartassist():
|
||||
# Return the response as a JSON object in the HTTP response
|
||||
return jsonify({"response": response})
|
||||
|
||||
# Run the Flask application if this script is executed directly
|
||||
|
||||
@app.route('/api/chat', methods=['POST'])
|
||||
def chat():
|
||||
data = request.get_json()
|
||||
query = data['query']
|
||||
response = requests.post('http://ollama-server/api/v1/chat', json={'prompt': query})
|
||||
return jsonify({'response': response.json().get('result')})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
# Run the Flask application on port 5000
|
||||
app.run(port=5000, debug=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user