Mer parametrisering från konfguration och rensning av utkommenterad kod
This commit is contained in:
@@ -17,13 +17,8 @@ CORS(app, resources={
|
||||
}
|
||||
})
|
||||
|
||||
# @app.route('/api/chat', methods=['POST'])
|
||||
# @cross_origin(origin='http://localhost:8000', headers=['Content-Type']) # Allow cross-origin requests from localhost:8000
|
||||
# @cross_origin(origin='*', headers=['Content-Type']) # Enable CORS for this route. Probably not necessary.
|
||||
# @cross_origin(origin='*', headers=['Content-Type', 'Accept'])
|
||||
|
||||
@app.route('/api/chat', methods=['POST'])
|
||||
def chat():
|
||||
def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"):
|
||||
# Get the message from the JSON in the request body
|
||||
data = request.get_json()
|
||||
message = data.get('query')
|
||||
@@ -32,8 +27,8 @@ def chat():
|
||||
|
||||
try:
|
||||
# Alternative LLM: "model": "mannix/llama3-8b-ablitered-v3:latest",
|
||||
url = "http://localhost:11434/api/generate"
|
||||
model_to_use = "phi3:mini"
|
||||
url = url_server
|
||||
model_to_use = model
|
||||
data = {
|
||||
"model": model_to_use,
|
||||
'prompt': message,
|
||||
@@ -85,22 +80,12 @@ def get_response(user_query):
|
||||
# Return the generated response
|
||||
return response
|
||||
|
||||
def run_flask():
|
||||
def run_flask(fport = 5005):
|
||||
# Flask endpoint for user interaction
|
||||
app.run(port=5005, debug=True)
|
||||
app.run(str(fport), debug=True)
|
||||
# app.run(port=5000, debug=True, use_reloader=False)
|
||||
|
||||
|
||||
# @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})
|
||||
# response = requests.post('localhost::11434', json={"model": "llama3",'prompt': query})
|
||||
# return jsonify({'response': response.json().get('result')})
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Run the Flask application
|
||||
run_flask()
|
||||
|
||||
Reference in New Issue
Block a user