Updated the backen and the requirements to allow chat interaction
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# A requirements file for the project. This file specifies
|
# A requirements file for the project.
|
||||||
# the development environment:
|
#
|
||||||
# - Python 3.8+
|
# Run 'pip install -r requirements.txt' to install all required packages.
|
||||||
# - pipenv
|
|
||||||
|
|
||||||
ollama
|
ollama
|
||||||
Flask
|
Flask
|
||||||
|
requests
|
||||||
@@ -14,6 +14,7 @@ def get_response(user_query):
|
|||||||
|
|
||||||
# Flask endpoint for user interaction
|
# Flask endpoint for user interaction
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
|
import requests
|
||||||
|
|
||||||
# Initialize a Flask application
|
# Initialize a Flask application
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -30,6 +31,16 @@ def smartassist():
|
|||||||
# Return the response as a JSON object in the HTTP response
|
# Return the response as a JSON object in the HTTP response
|
||||||
return jsonify({"response": 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__':
|
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