From 7b6f91c1170a293fb9a8ff7a22a81fdb72ee8fb5 Mon Sep 17 00:00:00 2001 From: Patrick_Pluto Date: Fri, 20 Sep 2024 15:46:02 +0200 Subject: [PATCH] fixed stuff with the backend and the pesky cpython cache --- .gitignore | 1 + py/ai.py | 4 ---- py/api.py | 15 ++++++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ea5d9c5..93a7e59 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ next-env.d.ts .idea/ venv/ +__pycache__/ key.pem cert.pem diff --git a/py/ai.py b/py/ai.py index c51f2d2..0a57b57 100644 --- a/py/ai.py +++ b/py/ai.py @@ -12,13 +12,9 @@ class AI: options={"temperature": 0.5}, ) - for i in messages: - print(i) - return_class.ai_response[access_token] = "" for chunk in stream: - print(chunk['message']['content']) return_class.ai_response[access_token] += chunk['message']['content'] @staticmethod diff --git a/py/api.py b/py/api.py index 7b09e1d..646af55 100644 --- a/py/api.py +++ b/py/api.py @@ -26,11 +26,16 @@ class API: def send_ai(): data = request.get_json() messages = data.get('messages') + model_type = data.get('model_type') ai_model = data.get('ai_model') access_token = data.get('access_token') if access_token not in self.ai_response: return jsonify({'status': 401, 'error': 'Invalid access token'}) - self.ai.process_local(ai_model, messages, self, access_token) + + if model_type == "local": + self.ai.process_local(ai_model, messages, self, access_token) + if model_type == "mistral": + self.ai.process_mistralai(ai_model, messages, self, access_token) return jsonify({'status': 200}) @self.app.route('/interstellar/api/ai_get', methods=['GET']) @@ -46,13 +51,13 @@ class API: data = request.args.get('data') if action == "create_account": self.db.add_user(data) - if action == "change_password": + elif action == "change_password": self.db.update_password(data) - if action == "get_data": + elif action == "get_data": self.db.get_data(data) - if action == "change_data": + elif action == "change_data": self.db.change_data(data) - if action == "check_credentials": + elif action == "check_credentials": self.db.check_credentials(data) email_address = "emailAddress"