langchain/libs/partners/qdrant/tests/integration_tests/fixtures.py
Sydney Runkle 8c6734325b
partners[lint]: run pyupgrade to get code in line with 3.9 standards (#30781)
Using `pyupgrade` to get all `partners` code up to 3.9 standards
(mostly, fixing old `typing` imports).
2025-04-11 07:18:44 -04:00

43 lines
1.0 KiB
Python

import logging
import os
from langchain_qdrant.qdrant import RetrievalMode
from tests.integration_tests.common import qdrant_running_locally
logger = logging.getLogger(__name__)
def qdrant_locations(use_in_memory: bool = True) -> list[str]:
locations = []
if use_in_memory:
logger.info("Running Qdrant tests with in-memory mode.")
locations.append(":memory:")
if qdrant_running_locally():
logger.info("Running Qdrant tests with local Qdrant instance.")
locations.append("http://localhost:6333")
if qdrant_url := os.getenv("QDRANT_URL"):
logger.info(f"Running Qdrant tests with Qdrant instance at {qdrant_url}.")
locations.append(qdrant_url)
return locations
def retrieval_modes(
*, dense: bool = True, sparse: bool = True, hybrid: bool = True
) -> list[RetrievalMode]:
modes = []
if dense:
modes.append(RetrievalMode.DENSE)
if sparse:
modes.append(RetrievalMode.SPARSE)
if hybrid:
modes.append(RetrievalMode.HYBRID)
return modes