Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/vector_store/chunk_v2_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ async def query_similar(
)

async with self.get_session_with_retry() as session:
await session.execute(text("SET LOCAL ivfflat.probes = :probes"), {"probes": self.ivfflat_probes})
# PostgreSQL SET doesn't support parameterized values; safe since ivfflat_probes is a validated int
await session.execute(text(f"SET LOCAL ivfflat.probes = {self.ivfflat_probes}"))
result = await session.execute(query)
rows = result.all()

Expand Down
3 changes: 2 additions & 1 deletion core/vector_store/pgvector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ async def query_similar(
"""
try:
async with self.get_session_with_retry() as session:
await session.execute(text("SET LOCAL ivfflat.probes = :probes"), {"probes": self.ivfflat_probes})
# PostgreSQL SET doesn't support parameterized values; safe since ivfflat_probes is a validated int
await session.execute(text(f"SET LOCAL ivfflat.probes = {self.ivfflat_probes}"))
# Build query with cosine distance calculation, which is normalized to [0, 2].
# A distance of 0 is perfect similarity.
distance = VectorEmbedding.embedding.op("<=>")(query_embedding)
Expand Down
Loading