vectorstores.py — langchain Source File
Architecture documentation for vectorstores.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6["vectorstores.py"] 50e20440_a135_6be3_a5a5_67791be5a2a6["abc"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> 50e20440_a135_6be3_a5a5_67791be5a2a6 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> 6a98b0a5_5607_0043_2e22_a46a464c2d62 918b8514_ba55_6df2_7254_4598ec160e33["langchain_core.embeddings"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> 918b8514_ba55_6df2_7254_4598ec160e33 f75e66a0_314a_f961_16d7_464ee959064b["langchain_core.vectorstores"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> f75e66a0_314a_f961_16d7_464ee959064b 6acb5c26_ca82_2e59_7635_f6897caf5d55["langchain_tests.base"] 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 --> 6acb5c26_ca82_2e59_7635_f6897caf5d55 style 81c98c2c_87c1_2d7d_3c86_1d94665e8bc6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test suite to test `VectorStore` integrations."""
from abc import abstractmethod
import pytest
from langchain_core.documents import Document
from langchain_core.embeddings import DeterministicFakeEmbedding, Embeddings
from langchain_core.vectorstores import VectorStore
from langchain_tests.base import BaseStandardTests
# Arbitrarily chosen. Using a small embedding size
# so tests are faster and easier to debug.
EMBEDDING_SIZE = 6
def _sort_by_id(documents: list[Document]) -> list[Document]:
return sorted(documents, key=lambda doc: doc.id or "")
class VectorStoreIntegrationTests(BaseStandardTests):
"""Base class for vector store integration tests.
Implementers should subclass this test suite and provide a fixture
that returns an empty vector store for each test.
The fixture should use the `get_embeddings` method to get a pre-defined
embeddings model that should be used for this test suite.
Here is a template:
```python
from typing import Generator
import pytest
from langchain_core.vectorstores import VectorStore
from langchain_parrot_link.vectorstores import ParrotVectorStore
from langchain_tests.integration_tests.vectorstores import VectorStoreIntegrationTests
class TestParrotVectorStore(VectorStoreIntegrationTests):
@pytest.fixture()
def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore
\"\"\"Get an empty vectorstore.\"\"\"
store = ParrotVectorStore(self.get_embeddings())
# note: store should be EMPTY at this point
# if you need to delete data, you may do so here
try:
yield store
finally:
# cleanup operations, or deleting data
pass
```
In the fixture, before the `yield` we instantiate an empty vector store. In the
`finally` block, we call whatever logic is necessary to bring the vector store
to a clean state.
```python
from typing import Generator
// ... (783 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- abc
- langchain_core.documents
- langchain_core.embeddings
- langchain_core.vectorstores
- langchain_tests.base
- pytest
Source
Frequently Asked Questions
What does vectorstores.py do?
vectorstores.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 vectorstores.py?
vectorstores.py defines 1 function(s): _sort_by_id.
What does vectorstores.py depend on?
vectorstores.py imports 6 module(s): abc, langchain_core.documents, langchain_core.embeddings, langchain_core.vectorstores, langchain_tests.base, pytest.
Where is vectorstores.py in the architecture?
vectorstores.py is located at libs/standard-tests/langchain_tests/integration_tests/vectorstores.py (domain: LangChainCore, subdomain: Runnables, directory: libs/standard-tests/langchain_tests/integration_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free