about summary refs log tree commit diff
path: root/gn3/api
diff options
context:
space:
mode:
authorAlexander_Kabui2025-07-04 16:31:51 +0300
committerBonfaceKilz2025-07-07 07:56:57 +0300
commit717f1e36b67b44522eedec246c7bfc5b66a8c5c1 (patch)
treeee11ecae3a592805732021e4dec62149a656cd3d /gn3/api
parentdc1412bd61932f3b5b61b7b2639aaf2577643d33 (diff)
downloadgenenetwork3-717f1e36b67b44522eedec246c7bfc5b66a8c5c1.tar.gz
refactor: Pylint and mypy fixes.
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/llm.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/gn3/api/llm.py b/gn3/api/llm.py
index e654188..7f6d49d 100644
--- a/gn3/api/llm.py
+++ b/gn3/api/llm.py
@@ -32,6 +32,7 @@ CREATE TABLE IF NOT EXISTS history(
     ) WITHOUT ROWID
 """
 
+
 RATING_TABLE_CREATE_QUERY = """
 CREATE TABLE IF NOT EXISTS Rating(
     user_id TEXT NOT NULL,
@@ -64,11 +65,12 @@ def clean_query(query:str) -> str:
     return str_query
 
 
-def is_verified_anonymous_user(request):
+def is_verified_anonymous_user(request_metadata):
     """This function should verify autheniticity of metadate from gn2 """
-    anony_id = request.headers.get("Anonymous-Id") #should verify this + metadata signature
-    user_status = request.headers.get("Anonymous-Status", "")
-    _user_signed_metadata = request.headers.get("Anony-Metadata", "") # verify this for integrity
+    anony_id = request_metadata.headers.get("Anonymous-Id") #should verify this + metadata signature
+    user_status = request_metadata.headers.get("Anonymous-Status", "")
+    _user_signed_metadata = (
+        request_metadata.headers.get("Anony-Metadata", "")) # TODO~ verify this for integrity
     return bool(anony_id) and user_status.lower() == "verified"
 
 
@@ -83,7 +85,7 @@ def with_gnqna_fallback(view_func):
                 len(response) == 2 and
                 response[1] == 400
             )
-            if is_bad_token_response and is_valid_anonymous_user(request):
+            if is_bad_token_response and is_verified_anonymous_user(request):
                 return view_func(*args, **{**kwargs, "auth_token": None, "valid_anony": True})
             return response
         except DecodeError: