diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index 3e3b5d6b..6c0a23b7 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -76,7 +76,7 @@ def get_data_from_api_key(api_key): # # Raise custom exception if the API key is not found if data is None: - raise Exception("API key is invalid", 401) + raise Exception("Invalid API Key, please generate new key", 401) return data @@ -200,6 +200,7 @@ def complete_stream(question, retriever, conversation_id, user_api_key): except Exception: data = json.dumps({"type": "error","error":"Please try again later. We apologize for any inconvenience."}) yield f"data: {data}\n\n" + return @answer.route("/stream", methods=["POST"]) def stream(): diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 51101492..625b1d6b 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -257,8 +257,8 @@ def combined_json(): } ] # structure: name, language, version, description, fullName, date, docLink - # append data from vectors_collection - for index in vectors_collection.find({"user": user}): + # append data from vectors_collection in sorted order in descending order of date + for index in vectors_collection.find({"user": user}).sort("date", -1): data.append( { "name": index["name"],