diff --git a/core/vector_store/chunk_v2_store.py b/core/vector_store/chunk_v2_store.py index 2f2895fb..2d8990cc 100644 --- a/core/vector_store/chunk_v2_store.py +++ b/core/vector_store/chunk_v2_store.py @@ -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() diff --git a/core/vector_store/pgvector_store.py b/core/vector_store/pgvector_store.py index 34a9e1b6..2f86e4d2 100644 --- a/core/vector_store/pgvector_store.py +++ b/core/vector_store/pgvector_store.py @@ -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)