test_vectorstore.py — langchain Source File
Architecture documentation for test_vectorstore.py, a python file in the langchain codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 547b9326_0fd1_ea2c_f15c_82026f35f74c["test_vectorstore.py"] 02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> 02f66451_d2a9_e7c3_9765_c3a7594721ad feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> feec1ec4_6917_867b_d228_b134d0ff8099 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> f69d6389_263d_68a4_7fbf_f14c0602a9ba f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> f85fae70_1011_eaec_151c_4083140ae9e5 6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> 6a98b0a5_5607_0043_2e22_a46a464c2d62 918b8514_ba55_6df2_7254_4598ec160e33["langchain_core.embeddings"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> 918b8514_ba55_6df2_7254_4598ec160e33 f75e66a0_314a_f961_16d7_464ee959064b["langchain_core.vectorstores"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> f75e66a0_314a_f961_16d7_464ee959064b 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] 547b9326_0fd1_ea2c_f15c_82026f35f74c --> 2bf6d401_816d_d011_3b05_a6114f55ff58 style 547b9326_0fd1_ea2c_f15c_82026f35f74c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Set of tests that complement the standard tests for vectorstore.
These tests verify that the base abstraction does appropriate delegation to
the relevant methods.
"""
from __future__ import annotations
import uuid
from typing import TYPE_CHECKING, Any
import pytest
from typing_extensions import override
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings, FakeEmbeddings
from langchain_core.vectorstores import VectorStore
if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
class CustomAddTextsVectorstore(VectorStore):
"""A VectorStore that only implements add texts."""
def __init__(self) -> None:
self.store: dict[str, Document] = {}
@override
def add_texts(
self,
texts: Iterable[str],
metadatas: list[dict] | None = None,
ids: list[str] | None = None,
**kwargs: Any,
) -> list[str]:
if not isinstance(texts, list):
texts = list(texts)
ids_iter = iter(ids or [])
ids_ = []
metadatas_ = metadatas or [{} for _ in texts]
for text, metadata in zip(texts, metadatas_ or [], strict=False):
next_id = next(ids_iter, None)
id_ = next_id or str(uuid.uuid4())
self.store[id_] = Document(page_content=text, metadata=metadata, id=id_)
ids_.append(id_)
return ids_
def get_by_ids(self, ids: Sequence[str], /) -> list[Document]:
return [self.store[id_] for id_ in ids if id_ in self.store]
@classmethod
@override
def from_texts(
cls,
texts: list[str],
embedding: Embeddings,
// ... (235 more lines)
Domain
Subdomains
Functions
Dependencies
- collections.abc
- langchain_core.documents
- langchain_core.embeddings
- langchain_core.vectorstores
- pytest
- typing
- typing_extensions
- uuid
Source
Frequently Asked Questions
What does test_vectorstore.py do?
test_vectorstore.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What functions are defined in test_vectorstore.py?
test_vectorstore.py defines 7 function(s): collections, test_default_aadd_documents, test_default_aadd_texts, test_default_add_documents, test_default_add_texts, test_default_afrom_documents, test_default_from_documents.
What does test_vectorstore.py depend on?
test_vectorstore.py imports 8 module(s): collections.abc, langchain_core.documents, langchain_core.embeddings, langchain_core.vectorstores, pytest, typing, typing_extensions, uuid.
Where is test_vectorstore.py in the architecture?
test_vectorstore.py is located at libs/core/tests/unit_tests/vectorstores/test_vectorstore.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/core/tests/unit_tests/vectorstores).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free