Home / File/ test_add_texts.py — langchain Source File

test_add_texts.py — langchain Source File

Architecture documentation for test_add_texts.py, a python file in the langchain codebase. 7 imports, 0 dependents.

File python LangChainCore Runnables 7 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  cfb482fe_7880_43f9_b1d4_600dadb066ca["test_add_texts.py"]
  02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> 02f66451_d2a9_e7c3_9765_c3a7594721ad
  f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> f69d6389_263d_68a4_7fbf_f14c0602a9ba
  6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> 6a98b0a5_5607_0043_2e22_a46a464c2d62
  a2826e40_d594_f57c_31ca_7071620aefc6["qdrant_client"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> a2826e40_d594_f57c_31ca_7071620aefc6
  67883832_8f96_6ce0_6b88_0267f86654f8["langchain_qdrant"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> 67883832_8f96_6ce0_6b88_0267f86654f8
  b499c7a8_2fb9_cfc0_4cf2_8686096d49bc["tests.integration_tests.common"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> b499c7a8_2fb9_cfc0_4cf2_8686096d49bc
  85cb53ff_3599_0e5f_1446_bc1cd58ba408["tests.integration_tests.fixtures"]
  cfb482fe_7880_43f9_b1d4_600dadb066ca --> 85cb53ff_3599_0e5f_1446_bc1cd58ba408
  style cfb482fe_7880_43f9_b1d4_600dadb066ca fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import uuid

import pytest
from langchain_core.documents import Document
from qdrant_client import QdrantClient, models

from langchain_qdrant import QdrantVectorStore, RetrievalMode
from tests.integration_tests.common import (
    ConsistentFakeEmbeddings,
    ConsistentFakeSparseEmbeddings,
    assert_documents_equals,
)
from tests.integration_tests.fixtures import qdrant_locations, retrieval_modes


@pytest.mark.parametrize("location", qdrant_locations())
@pytest.mark.parametrize("vector_name", ["", "my-vector"])
@pytest.mark.parametrize("retrieval_mode", retrieval_modes())
@pytest.mark.parametrize(
    "sparse_vector_name", ["my-sparse-vector", "another-sparse-vector"]
)
def test_qdrant_add_documents_extends_existing_collection(
    location: str,
    vector_name: str,
    retrieval_mode: RetrievalMode,
    sparse_vector_name: str,
) -> None:
    """Test end to end construction and search."""
    texts = ["foo", "bar", "baz"]
    docsearch = QdrantVectorStore.from_texts(
        texts,
        ConsistentFakeEmbeddings(),
        location=location,
        vector_name=vector_name,
        retrieval_mode=retrieval_mode,
        sparse_vector_name=sparse_vector_name,
        sparse_embedding=ConsistentFakeSparseEmbeddings(),
    )

    new_texts = ["foobar", "foobaz"]
    docsearch.add_documents([Document(page_content=content) for content in new_texts])
    output = docsearch.similarity_search("foobar", k=1)
    assert_documents_equals(output, [Document(page_content="foobar")])


@pytest.mark.parametrize("location", qdrant_locations())
@pytest.mark.parametrize("vector_name", ["", "my-vector"])
@pytest.mark.parametrize("retrieval_mode", retrieval_modes())
@pytest.mark.parametrize(
    "sparse_vector_name", ["my-sparse-vector", "another-sparse-vector"]
)
@pytest.mark.parametrize("batch_size", [1, 64])
def test_qdrant_add_texts_returns_all_ids(
    location: str,
    vector_name: str,
    retrieval_mode: RetrievalMode,
    sparse_vector_name: str,
    batch_size: int,
// ... (84 more lines)

Domain

Subdomains

Dependencies

  • langchain_core.documents
  • langchain_qdrant
  • pytest
  • qdrant_client
  • tests.integration_tests.common
  • tests.integration_tests.fixtures
  • uuid

Frequently Asked Questions

What does test_add_texts.py do?
test_add_texts.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in test_add_texts.py?
test_add_texts.py defines 4 function(s): test_qdrant_add_documents_extends_existing_collection, test_qdrant_add_texts_returns_all_ids, test_qdrant_add_texts_stores_duplicated_texts, test_qdrant_add_texts_stores_ids.
What does test_add_texts.py depend on?
test_add_texts.py imports 7 module(s): langchain_core.documents, langchain_qdrant, pytest, qdrant_client, tests.integration_tests.common, tests.integration_tests.fixtures, uuid.
Where is test_add_texts.py in the architecture?
test_add_texts.py is located at libs/partners/qdrant/tests/integration_tests/qdrant_vector_store/test_add_texts.py (domain: LangChainCore, subdomain: Runnables, directory: libs/partners/qdrant/tests/integration_tests/qdrant_vector_store).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free