Testar med fjärrserver för ollama. Endast tillfällig lösning.
This commit is contained in:
+13
-11
@@ -58,15 +58,15 @@ def set_session():
|
|||||||
resp.set_cookie('session', 'some-value', samesite='None', secure=True) # Add SameSite attribute here
|
resp.set_cookie('session', 'some-value', samesite='None', secure=True) # Add SameSite attribute here
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@app.route('/profile')
|
# @app.route('/profile')
|
||||||
def profile():
|
# def profile():
|
||||||
# Retrieve data from the session
|
# # Retrieve data from the session
|
||||||
user_id = session.get('user_id')
|
# user_id = session.get('user_id')
|
||||||
|
|
||||||
if user_id:
|
# if user_id:
|
||||||
return f'User ID: {user_id}'
|
# return f'User ID: {user_id}'
|
||||||
else:
|
# else:
|
||||||
return 'No user ID found'
|
# return 'No user ID found'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<path:filename>')
|
@app.route('/<path:filename>')
|
||||||
@@ -89,7 +89,8 @@ CORS(app, resources={
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/api/chat', methods=['POST'])
|
@app.route('/api/chat', methods=['POST'])
|
||||||
def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"):
|
def chat(model = "phi3:mini"):
|
||||||
|
# def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"):
|
||||||
"""
|
"""
|
||||||
This function handles the chat. The frontend client (web browser) calls the
|
This function handles the chat. The frontend client (web browser) calls the
|
||||||
backend server through this endpoint (/api/chat) that manage queries
|
backend server through this endpoint (/api/chat) that manage queries
|
||||||
@@ -99,7 +100,7 @@ def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"
|
|||||||
# Get the message from the JSON in the request body
|
# Get the message from the JSON in the request body
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
message = data.get('query')
|
message = data.get('query')
|
||||||
url_server = data.get('url_server', url_server) # Use provided URL or default
|
url_server = data.get('url_server', "https://ollama-test.wara-ops.org/api/generate") # Use provided URL or default
|
||||||
model = data.get('model', model) # Use provided model or default
|
model = data.get('model', model) # Use provided model or default
|
||||||
|
|
||||||
# Get chat history from session storage (e.g., a dictionary)
|
# Get chat history from session storage (e.g., a dictionary)
|
||||||
@@ -122,8 +123,9 @@ def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"
|
|||||||
url = url_server
|
url = url_server
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Basic ZWNzanBlcjoxM2JjMTU4ZDhmNmY5YTU4YTkzZDNmY2I="
|
||||||
}
|
}
|
||||||
|
logger.debug(f"url: {url} headers: {headers}")
|
||||||
response = requests.post(url,
|
response = requests.post(url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=json.dumps(data_to_send))
|
data=json.dumps(data_to_send))
|
||||||
|
|||||||
Reference in New Issue
Block a user