Fix pgvector embedding format in recommender query

profile.embedding was being passed as str(numpy_array) which produces
scientific notation format. pgvector needs [n1,n2,...] format. Now
explicitly formats as comma-separated float list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 11:30:02 -06:00
parent 6a2be93556
commit 2c6ba345b1

View File

@@ -53,9 +53,13 @@ async def get_recommendations(
LIMIT :limit
""")
# Format embedding as pgvector literal: [n1,n2,...]
emb = profile.embedding
emb_str = "[" + ",".join(str(float(x)) for x in emb) + "]"
result = await session.execute(
query,
{"profile_embedding": str(profile.embedding), "limit": limit},
{"profile_embedding": emb_str, "limit": limit},
)
return [