Files
zeekay 2e295af644 fix(qdrant): health await + query embedder for the Qdrant backend
Two Qdrant-backend gaps surfaced once rag-api booted on hanzoai/vector:

1. health.py: is_health_ok() is awaited by GET /health, but the Qdrant
   branch returned a plain bool (pg/mongo branches return coroutines) ->
   "TypeError: object bool can't be used in 'await' expression", failing
   the readiness probe. Make is_health_ok async and await the async
   backends; return the sync Qdrant bool directly.

2. document_routes.py: get_cached_query_embedding read
   vector_store.embedding_function, which exists on PGVector but NOT on
   langchain QdrantVectorStore (it exposes .embeddings) ->
   "QdrantVector object has no attribute embedding_function" on every
   /query. Use the module-level `embeddings` object directly (backend-
   agnostic).

Proven live: embed(proof-doc-001)->Fireworks 768-dim->Qdrant hanzo_chat,
then query->Qdrant points/search 200 OK retrieves it at score 0.7972.
2026-06-24 05:53:49 -07:00

30 lines
1.1 KiB
Python

# app/utils/health.py
from app.config import VECTOR_DB_TYPE, VectorDBType
from app.services.database import pg_health_check
from app.services.mongo_client import mongo_health_check
def qdrant_health_check() -> bool:
"""Liveness against hanzoai/vector (Qdrant): the shared vector_store client
can list collections."""
try:
from app.config import vector_store
vector_store.client.get_collections()
return True
except Exception: # noqa: BLE001
return False
async def is_health_ok() -> bool:
# The route awaits this. pg/mongo checks are coroutines; the Qdrant check is
# a sync bool. Await the async backends and return the sync one directly so
# the result is a uniform awaitable bool (await on a plain bool raises
# TypeError: "object bool can't be used in 'await' expression").
if VECTOR_DB_TYPE == VectorDBType.PGVECTOR:
return await pg_health_check()
if VECTOR_DB_TYPE == VectorDBType.ATLAS_MONGO:
return await mongo_health_check()
if VECTOR_DB_TYPE == VectorDBType.QDRANT:
return qdrant_health_check()
return True