Skip to content

Commit f34e6c2

Browse files
committed
Move test query to the flow
1 parent 7666b7f commit f34e6c2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/backend/fastapi_app/postgres_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_password_from_azure_credential():
3434

3535
engine = create_async_engine(
3636
DATABASE_URI,
37-
echo=False,
37+
echo=True,
3838
)
3939

4040
@event.listens_for(engine.sync_engine, "connect")

src/backend/fastapi_app/postgres_searcher.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ async def search(
8484
else:
8585
raise ValueError("Both query text and query vector are empty")
8686

87+
first_item = (await self.db_session.execute(select(Item).order_by(Item.id).limit(1))).scalars().first()
88+
# Will it work?
89+
(
90+
await self.db_session.execute(
91+
text(
92+
f"SELECT id, {Item.__tablename__}.embedding_ada002 <=> :embedding AS distance "
93+
f"FROM {Item.__tablename__} ORDER BY distance LIMIT 2"
94+
),
95+
{"embedding": first_item.embedding_ada002},
96+
)
97+
).fetchall()
98+
8799
results = (
88100
await self.db_session.execute(
89101
sql,

0 commit comments

Comments
 (0)