Spaces:
Runtime error
Runtime error
| """Shared async Qdrant client (singleton) for search + semantic cache.""" | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| from app.config import settings | |
| if TYPE_CHECKING: | |
| from qdrant_client import AsyncQdrantClient | |
| _async_client: AsyncQdrantClient | None = None | |
| def get_async_qdrant_client() -> AsyncQdrantClient: | |
| """Return a process-wide ``AsyncQdrantClient`` (avoids per-request connection churn).""" | |
| global _async_client | |
| if _async_client is None: | |
| from qdrant_client import AsyncQdrantClient | |
| _async_client = AsyncQdrantClient( | |
| url=settings.qdrant_url, | |
| api_key=settings.qdrant_api_key or None, | |
| ) | |
| return _async_client | |
| def reset_async_qdrant_client() -> None: | |
| """Drop the shared client (tests / vectorstore factory reset).""" | |
| global _async_client | |
| _async_client = None | |