From 879905edf697a03e6b4c89d55c113e73194d7a24 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 4 Apr 2024 12:38:23 +0100 Subject: [PATCH] Refactor create_api_key function to include prompt_id and chunks in routes.py --- application/api/user/routes.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 239278b9..b1ec69e4 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -351,7 +351,14 @@ def get_api_keys(): keys = api_key_collection.find({"user": user}) list_keys = [] for key in keys: - list_keys.append({"id": str(key["_id"]), "name": key["name"], "key": key["key"][:4] + "..." + key["key"][-4:], "source": key["source"]}) + list_keys.append({ + "id": str(key["_id"]), + "name": key["name"], + "key": key["key"][:4] + "..." + key["key"][-4:], + "source": key["source"], + "prompt_id": key["prompt_id"], + "chunks": key["chunks"] + }) return jsonify(list_keys) @user.route("/api/create_api_key", methods=["POST"]) @@ -359,6 +366,8 @@ def create_api_key(): data = request.get_json() name = data["name"] source = data["source"] + prompt_id = data["prompt_id"] + chunks = data["chunks"] key = str(uuid.uuid4()) user = "local" resp = api_key_collection.insert_one( @@ -367,6 +376,8 @@ def create_api_key(): "key": key, "source": source, "user": user, + "prompt_id": prompt_id, + "chunks": chunks } ) new_id = str(resp.inserted_id)