fix: RAG vector search SQL syntax error breaking assistant chat

- Use CAST(:embedding AS vector) instead of :embedding::vector to avoid
  SQLAlchemy named param conflict with PostgreSQL :: cast syntax
- Add db.rollback() before recording AI usage on failure to prevent
  InFailedSQLTransactionError cascade

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-03-05 11:41:22 -05:00
parent 199cf315c6
commit 125d7e7d61
2 changed files with 3 additions and 2 deletions

View File

@@ -155,6 +155,7 @@ async def post_message(
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e))
except Exception as e:
logger.exception("Assistant chat message failed: %s", e)
await db.rollback()
await record_ai_usage(
user_id=current_user.id,
account_id=current_user.account_id,