diff options
| -rw-r--r-- | gn3/api/llm.py | 12 | ||||
| -rw-r--r-- | gn3/api/metadata_api/wiki.py | 2 |
2 files changed, 8 insertions, 6 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"] diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py index 7a00786..ba01b19 100644 --- a/gn3/api/metadata_api/wiki.py +++ b/gn3/api/metadata_api/wiki.py @@ -22,7 +22,7 @@ rif_blueprint = Blueprint("rif", __name__, url_prefix="rif") @wiki_blueprint.route("/<int:comment_id>/edit", methods=["POST"]) @require_token -def edit_wiki(comment_id: int, **kwargs): +def edit_wiki(comment_id: int, **kwargs):# pylint: disable=[unused-argument] """Edit wiki comment. This is achieved by adding another entry with a new VersionId""" # FIXME: attempt to check and fix for types here with relevant errors payload: Dict[str, Any] = request.json # type: ignore |
