test_add_documents_by_id_with_mutation_async() — langchain Function Reference
Architecture documentation for the test_add_documents_by_id_with_mutation_async() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 43db5da6_bb97_e5f6_aa87_38177d93721c["test_add_documents_by_id_with_mutation_async()"] dd52cc1a_cb37_0117_3b1e_0889a7228307["VectorStoreIntegrationTests"] 43db5da6_bb97_e5f6_aa87_38177d93721c -->|defined in| dd52cc1a_cb37_0117_3b1e_0889a7228307 style 43db5da6_bb97_e5f6_aa87_38177d93721c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/vectorstores.py lines 642–681
async def test_add_documents_by_id_with_mutation_async(
self, vectorstore: VectorStore
) -> None:
"""Test that we can overwrite by ID using `add_documents`.
??? note "Troubleshooting"
If this test fails, check that when `aadd_documents` is called with an
ID that already exists in the vector store, the content is updated
rather than duplicated.
"""
if not self.has_async:
pytest.skip("Async tests not supported.")
documents = [
Document(page_content="foo", metadata={"id": 1}),
Document(page_content="bar", metadata={"id": 2}),
]
await vectorstore.aadd_documents(documents=documents, ids=["1", "2"])
# Now over-write content of ID 1
new_documents = [
Document(
page_content="new foo", metadata={"id": 1, "some_other_field": "foo"}
),
]
await vectorstore.aadd_documents(documents=new_documents, ids=["1"])
# Check that the content has been updated
documents = await vectorstore.asimilarity_search("new foo", k=2)
assert documents == [
Document(
id="1",
page_content="new foo",
metadata={"id": 1, "some_other_field": "foo"},
),
Document(id="2", page_content="bar", metadata={"id": 2}),
]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_add_documents_by_id_with_mutation_async() do?
test_add_documents_by_id_with_mutation_async() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py.
Where is test_add_documents_by_id_with_mutation_async() defined?
test_add_documents_by_id_with_mutation_async() is defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py at line 642.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free