File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,22 @@ async def seed_data(engine):
5353 pass
5454
5555 logger .info (f"{ table_name } table seeded successfully." )
56+ # Do a simple query with <=>
57+ # Check cosine distance of every item with the first item
58+ async with async_sessionmaker (engine , expire_on_commit = False )() as session :
59+ first_item = (await session .execute (select (Item ).order_by (Item .id ).limit (1 ))).scalars ().first ()
60+ result = (
61+ await session .execute (
62+ text (
63+ f"SELECT id, { Item .__tablename__ } .embedding_ada002 <=> :embedding AS distance "
64+ f"FROM { Item .__tablename__ } ORDER BY distance LIMIT 2"
65+ ),
66+ {"embedding" : first_item .embedding_ada002 },
67+ )
68+ ).fetchall ()
69+ logger .info ("Test query: cosine distance of first two items with the first item:" )
70+ for row in result :
71+ logger .info (row )
5672
5773
5874async def main ():
You can’t perform that action at this time.
0 commit comments