Spaces:
Sleeping
Sleeping
Download src/qdrant_client_manager.py from atlas-chatbot/acb: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/atlas-chatbot/acb/resolve/main/src/qdrant_client_manager.py
- Command line
-
hf download hf://spaces/atlas-chatbot/acb/src/qdrant_client_manager.py
-
curl -L -o qdrant_client_manager.py https://huggingface.co/spaces/atlas-chatbot/acb/resolve/main/src/qdrant_client_manager.py
1 kB
| # Shared Qdrant client manager to prevent multiple instance conflicts | |
| import logging | |
| from typing import Optional | |
| from qdrant_client import QdrantClient | |
| from config import QDRANT_PATH, USE_MEMORY_MODE | |
| logger = logging.getLogger(__name__) | |
| _shared_client: Optional[QdrantClient] = None | |
| def get_qdrant_client() -> QdrantClient: | |
| """Return shared Qdrant client instance.""" | |
| global _shared_client | |
| if _shared_client is None: | |
| if USE_MEMORY_MODE: | |
| logger.info("Creating in-memory Qdrant client") | |
| _shared_client = QdrantClient(":memory:") | |
| else: | |
| logger.info(f"Creating Qdrant client with path: {QDRANT_PATH}") | |
| _shared_client = QdrantClient(path=QDRANT_PATH) | |
| return _shared_client | |
| def reset_qdrant_client(): | |
| """Reset shared client for testing.""" | |
| global _shared_client | |
| if _shared_client is not None: | |
| try: | |
| _shared_client.close() | |
| except Exception: | |
| pass | |
| _shared_client = None | |