sort local vectors in latest first order

This commit is contained in:
ManishMadan2882 2024-06-20 17:58:59 +05:30
parent ad29d2765f
commit dba3b1c559
2 changed files with 4 additions and 3 deletions

View File

@ -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():

View File

@ -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"],