fix: update entities collection name in cognee_demo notebook

This commit is contained in:
Boris Arzentar 2024-11-11 17:54:00 +01:00 committed by Leon Luithlen
parent 27057d3a29
commit c0d1aa1216
2 changed files with 16 additions and 9 deletions

View file

@ -179,6 +179,8 @@ class PGVectorAdapter(SQLAlchemyAdapter, VectorDBInterface):
# Get PGVectorDataPoint Table from database # Get PGVectorDataPoint Table from database
PGVectorDataPoint = await self.get_table(collection_name) PGVectorDataPoint = await self.get_table(collection_name)
closest_items = []
# Use async session to connect to the database # Use async session to connect to the database
async with self.get_async_session() as session: async with self.get_async_session() as session:
# Find closest vectors to query_vector # Find closest vectors to query_vector
@ -195,14 +197,19 @@ class PGVectorAdapter(SQLAlchemyAdapter, VectorDBInterface):
vector_list = [] vector_list = []
# Create and return ScoredResult objects # Extract distances and find min/max for normalization
return [ for vector in closest_items:
ScoredResult( # TODO: Add normalization of similarity score
id = UUID(str(row.id)), vector_list.append(vector)
payload = row.payload,
score = row.similarity # Create and return ScoredResult objects
) for row in vector_list return [
] ScoredResult(
id = UUID(str(row.id)),
payload = row.payload,
score = row.similarity
) for row in vector_list
]
async def batch_search( async def batch_search(
self, self,

View file

@ -758,7 +758,7 @@
"from cognee.infrastructure.databases.vector import get_vector_engine\n", "from cognee.infrastructure.databases.vector import get_vector_engine\n",
"\n", "\n",
"vector_engine = get_vector_engine()\n", "vector_engine = get_vector_engine()\n",
"results = await search(vector_engine, \"entities\", \"sarah.nguyen@example.com\")\n", "results = await search(vector_engine, \"Entity_name\", \"sarah.nguyen@example.com\")\n",
"for result in results:\n", "for result in results:\n",
" print(result)" " print(result)"
] ]