diff options
| author | Frederick Muriuki Muriithi | 2024-10-15 14:00:58 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2024-10-15 14:00:58 -0500 |
| commit | 0820295202c2fe747c05b93ce0f1c5a604442f69 (patch) | |
| tree | 212d4a333537063d21e1b243aab8bcc2a59e3bb8 /gn3/api/llm.py | |
| parent | e0cba992881413669d27fee54209c8125093a0f4 (diff) | |
| download | genenetwork3-0820295202c2fe747c05b93ce0f1c5a604442f69.tar.gz | |
Lint: Fix linting errors.
Diffstat (limited to 'gn3/api/llm.py')
| -rw-r--r-- | gn3/api/llm.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gn3/api/llm.py b/gn3/api/llm.py index 93ffc78..9a44440 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -102,10 +102,9 @@ def rate_queries(task_id, auth_token=None): user_id = get_user_id(auth_token) with db.connection(current_app.config["LLM_DB_PATH"]) as conn: results = request.json - user_id, query, answer, weight = (user_id, - results.get("query"), - results.get("answer"), - results.get("weight", 0)) + query, answer, weight = (results.get("query"), + results.get("answer"), + results.get("weight", 0)) cursor = conn.cursor() cursor.execute("""INSERT INTO Rating(user_id, query, answer, weight, task_id) @@ -170,12 +169,15 @@ def delete_records(auth_token=None): with db.connection(current_app.config["LLM_DB_PATH"]) as conn: task_ids = list(request.json.values()) cursor = conn.cursor() - query = f""" DELETE FROM history WHERE task_id IN ({', '.join('?' * len(task_ids))}) AND user_id=? """ + query = ("DELETE FROM history WHERE task_id IN " + f"({', '.join('?' * len(task_ids))}) " + "AND user_id=?") cursor.execute(query, (*task_ids, get_user_id(auth_token),)) return jsonify({}) def get_user_id(auth_token: Optional[dict] = None): + """Retrieve the user ID from the JWT token.""" if auth_token is None or auth_token.get("jwt", {}).get("sub") is None: raise LLMError("Invalid auth token encountered") user_id = auth_token["jwt"]["sub"] |
