diff --git a/smartassist/requirements_dev.txt b/smartassist/requirements_dev.txt index ead727b..6ec60b2 100644 --- a/smartassist/requirements_dev.txt +++ b/smartassist/requirements_dev.txt @@ -1,6 +1,8 @@ -# A requirements file for the project. This file specifies -# the development environment: -# - Python 3.8+ -# - pipenv +# A requirements file for the project. +# +# Run 'pip install -r requirements.txt' to install all required packages. + + ollama -Flask \ No newline at end of file +Flask +requests \ No newline at end of file diff --git a/smartassist/src/ollama_interact.py b/smartassist/src/ollama_interact.py index 2d942f8..d3d2e08 100644 --- a/smartassist/src/ollama_interact.py +++ b/smartassist/src/ollama_interact.py @@ -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) +