Skip to content

Commit

Permalink
fix:unexist collection
Browse files Browse the repository at this point in the history
  • Loading branch information
leoguillaumegouv committed Sep 17, 2024
1 parent 0b8e735 commit b1db503
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/helpers/_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ def get_collection_metadata(self, collection_names: List[str] = [], type: str =
raise HTTPException(status_code=404, detail=f"Collection {collection_name} not found")
metadata.extend(data)

# @TODO: the 2 following checks, they are still needed ?
# remove collection that does not exist
existing_collection_ids = [collection.name for collection in self.vectors.get_collections().collections]
metadata = [collection for collection in metadata if collection.id in existing_collection_ids]

# sort by updated_at and remove duplicates collections with same names (keep the latest version), concerns only public collections
sorted_data = sorted(metadata, key=lambda x: x.payload.get("updated_at", 0), reverse=False)
metadata = list({item.payload["name"]: item for item in sorted_data if "name" in item.payload}.values())
Expand Down

0 comments on commit b1db503

Please sign in to comment.