mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 08:03:39 +00:00
## Description This PR adds integration tests to follow up on #24164. By default, the tests use an in-memory instance. To run the full suite of tests, with both in-memory and Qdrant server: ``` $ docker run -p 6333:6333 qdrant/qdrant $ make test $ make integration_test ``` --------- Co-authored-by: Erick Friis <erick@langchain.dev>
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import logging
|
|
import os
|
|
from typing import List
|
|
|
|
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
|