test_similarity_search.py — langchain Source File
Architecture documentation for test_similarity_search.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR a356375e_89ff_e5ee_93df_81a44a9a62cd["test_similarity_search.py"] cd17727f_b882_7f06_aadc_71fbf75bebb0["numpy"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> cd17727f_b882_7f06_aadc_71fbf75bebb0 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> 120e2591_3e15_b895_72b6_cb26195e40a6 c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> c554676d_b731_47b2_a98f_c1c2d537c0aa da77c41d_c17b_8187_a5db_d7d2c445d3ab["qdrant_client.http"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> da77c41d_c17b_8187_a5db_d7d2c445d3ab 77801658_6b3a_bc26_7e54_388e5c04807d["langchain_qdrant"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> 77801658_6b3a_bc26_7e54_388e5c04807d a50ef027_f19e_86a8_94ef_895b4566f94e["tests.integration_tests.common"] a356375e_89ff_e5ee_93df_81a44a9a62cd --> a50ef027_f19e_86a8_94ef_895b4566f94e style a356375e_89ff_e5ee_93df_81a44a9a62cd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import numpy as np
import pytest # type: ignore[import-not-found]
from langchain_core.documents import Document
from qdrant_client.http import models as rest
from langchain_qdrant import Qdrant
from tests.integration_tests.common import (
ConsistentFakeEmbeddings,
assert_documents_equals,
)
@pytest.mark.parametrize("batch_size", [1, 64])
@pytest.mark.parametrize("content_payload_key", [Qdrant.CONTENT_KEY, "foo"])
@pytest.mark.parametrize("metadata_payload_key", [Qdrant.METADATA_KEY, "bar"])
@pytest.mark.parametrize("vector_name", [None, "my-vector"])
def test_qdrant_similarity_search(
batch_size: int,
content_payload_key: str,
metadata_payload_key: str,
vector_name: str | None,
) -> None:
"""Test end to end construction and search."""
texts = ["foo", "bar", "baz"]
docsearch = Qdrant.from_texts(
texts,
ConsistentFakeEmbeddings(),
location=":memory:",
content_payload_key=content_payload_key,
metadata_payload_key=metadata_payload_key,
batch_size=batch_size,
vector_name=vector_name,
)
output = docsearch.similarity_search("foo", k=1)
assert_documents_equals(actual=output, expected=[Document(page_content="foo")])
@pytest.mark.parametrize("batch_size", [1, 64])
@pytest.mark.parametrize("content_payload_key", [Qdrant.CONTENT_KEY, "foo"])
@pytest.mark.parametrize("metadata_payload_key", [Qdrant.METADATA_KEY, "bar"])
@pytest.mark.parametrize("vector_name", [None, "my-vector"])
def test_qdrant_similarity_search_by_vector(
batch_size: int,
content_payload_key: str,
metadata_payload_key: str,
vector_name: str | None,
) -> None:
"""Test end to end construction and search."""
texts = ["foo", "bar", "baz"]
docsearch = Qdrant.from_texts(
texts,
ConsistentFakeEmbeddings(),
location=":memory:",
content_payload_key=content_payload_key,
metadata_payload_key=metadata_payload_key,
batch_size=batch_size,
vector_name=vector_name,
)
// ... (224 more lines)
Domain
Subdomains
Functions
- test_qdrant_similarity_search()
- test_qdrant_similarity_search_by_vector()
- test_qdrant_similarity_search_filters()
- test_qdrant_similarity_search_filters_with_qdrant_filters()
- test_qdrant_similarity_search_with_relevance_score_no_threshold()
- test_qdrant_similarity_search_with_relevance_score_with_threshold()
- test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter()
- test_qdrant_similarity_search_with_relevance_scores()
- test_qdrant_similarity_search_with_score_by_vector()
Dependencies
- langchain_core.documents
- langchain_qdrant
- numpy
- pytest
- qdrant_client.http
- tests.integration_tests.common
Source
Frequently Asked Questions
What does test_similarity_search.py do?
test_similarity_search.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_similarity_search.py?
test_similarity_search.py defines 9 function(s): test_qdrant_similarity_search, test_qdrant_similarity_search_by_vector, test_qdrant_similarity_search_filters, test_qdrant_similarity_search_filters_with_qdrant_filters, test_qdrant_similarity_search_with_relevance_score_no_threshold, test_qdrant_similarity_search_with_relevance_score_with_threshold, test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter, test_qdrant_similarity_search_with_relevance_scores, test_qdrant_similarity_search_with_score_by_vector.
What does test_similarity_search.py depend on?
test_similarity_search.py imports 6 module(s): langchain_core.documents, langchain_qdrant, numpy, pytest, qdrant_client.http, tests.integration_tests.common.
Where is test_similarity_search.py in the architecture?
test_similarity_search.py is located at libs/partners/qdrant/tests/integration_tests/test_similarity_search.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/partners/qdrant/tests/integration_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free