Home / Function/ test_default_afrom_documents() — langchain Function Reference

test_default_afrom_documents() — langchain Function Reference

Architecture documentation for the test_default_afrom_documents() function in test_vectorstore.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  73191915_a219_fc45_e2f6_90b83e2844d7["test_default_afrom_documents()"]
  547b9326_0fd1_ea2c_f15c_82026f35f74c["test_vectorstore.py"]
  73191915_a219_fc45_e2f6_90b83e2844d7 -->|defined in| 547b9326_0fd1_ea2c_f15c_82026f35f74c
  style 73191915_a219_fc45_e2f6_90b83e2844d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/vectorstores/test_vectorstore.py lines 271–294

async def test_default_afrom_documents(vs_class: type[VectorStore]) -> None:
    embeddings = FakeEmbeddings(size=1)
    store = await vs_class.afrom_documents(
        [Document(id="1", page_content="hello", metadata={"foo": "bar"})], embeddings
    )

    assert await store.aget_by_ids(["1"]) == [
        Document(id="1", page_content="hello", metadata={"foo": "bar"})
    ]

    # from_documents with IDs in args
    store = await vs_class.afrom_documents(
        [Document(page_content="hello", metadata={"foo": "bar"})], embeddings, ids=["1"]
    )

    assert await store.aget_by_ids(["1"]) == [
        Document(id="1", page_content="hello", metadata={"foo": "bar"})
    ]

    # Test afrom_documents with id specified in both document and IDs
    original_document = Document(id="7", page_content="baz")
    store = await vs_class.afrom_documents([original_document], embeddings, ids=["6"])
    assert original_document.id == "7"  # original document should not be modified
    assert await store.aget_by_ids(["6"]) == [Document(id="6", page_content="baz")]

Domain

Subdomains

Frequently Asked Questions

What does test_default_afrom_documents() do?
test_default_afrom_documents() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/vectorstores/test_vectorstore.py.
Where is test_default_afrom_documents() defined?
test_default_afrom_documents() is defined in libs/core/tests/unit_tests/vectorstores/test_vectorstore.py at line 271.

Analyze Your Own Codebase

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

Try Supermodel Free