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.
Entity Profile
Dependency Diagram
graph LR 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50["test_add_texts.py"] 02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> 02f66451_d2a9_e7c3_9765_c3a7594721ad f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> 6a98b0a5_5607_0043_2e22_a46a464c2d62 67883832_8f96_6ce0_6b88_0267f86654f8["langchain_qdrant"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> 67883832_8f96_6ce0_6b88_0267f86654f8 b499c7a8_2fb9_cfc0_4cf2_8686096d49bc["tests.integration_tests.common"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> b499c7a8_2fb9_cfc0_4cf2_8686096d49bc a2826e40_d594_f57c_31ca_7071620aefc6["qdrant_client"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> a2826e40_d594_f57c_31ca_7071620aefc6 5e892d73_52fe_a9b9_7e5f_abb366ac08b8["qdrant_client.http"] 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 --> 5e892d73_52fe_a9b9_7e5f_abb366ac08b8 style 9c6f5a1c_a52c_4c96_0ca9_eedd81e9cd50 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import uuid
import pytest # type: ignore[import-not-found]
from langchain_core.documents import Document
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("vector_name", [None, "my-vector"])
def test_qdrant_add_documents_extends_existing_collection(
batch_size: int, vector_name: str | None
) -> None:
"""Test end to end construction and search."""
texts = ["foo", "bar", "baz"]
docsearch: Qdrant = Qdrant.from_texts(
texts,
ConsistentFakeEmbeddings(),
location=":memory:",
batch_size=batch_size,
vector_name=vector_name,
)
new_texts = ["foobar", "foobaz"]
docsearch.add_documents(
[Document(page_content=content) for content in new_texts], batch_size=batch_size
)
output = docsearch.similarity_search("foobar", k=1)
# ConsistentFakeEmbeddings return the same query embedding as the first document
# embedding computed in `embedding.embed_documents`. Thus, "foo" embedding is the
# same as "foobar" embedding
assert_documents_equals(output, [Document(page_content="foobar")])
@pytest.mark.parametrize("batch_size", [1, 64])
def test_qdrant_add_texts_returns_all_ids(batch_size: int) -> None:
"""Test end to end Qdrant.add_texts returns unique ids."""
docsearch: Qdrant = Qdrant.from_texts(
["foobar"],
ConsistentFakeEmbeddings(),
location=":memory:",
batch_size=batch_size,
)
ids = docsearch.add_texts(["foo", "bar", "baz"])
assert len(ids) == 3
assert len(set(ids)) == 3
@pytest.mark.parametrize("vector_name", [None, "my-vector"])
def test_qdrant_add_texts_stores_duplicated_texts(vector_name: str | None) -> None:
"""Test end to end Qdrant.add_texts stores duplicated texts separately."""
from qdrant_client import QdrantClient
from qdrant_client.http import models as rest
// ... (79 more lines)
Domain
Subdomains
Functions
Dependencies
- langchain_core.documents
- langchain_qdrant
- pytest
- qdrant_client
- qdrant_client.http
- tests.integration_tests.common
- uuid
Source
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 5 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_embeddings_as_named_vectors, 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, qdrant_client.http, tests.integration_tests.common, uuid.
Where is test_add_texts.py in the architecture?
test_add_texts.py is located at libs/partners/qdrant/tests/integration_tests/test_add_texts.py (domain: LangChainCore, subdomain: Runnables, 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