vectorstores.py — langchain Source File
Architecture documentation for vectorstores.py, a python file in the langchain codebase. 16 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d4a05de9_1f0f_3b21_8171_181bb47227ef["vectorstores.py"] 66c6348c_7716_027c_42d7_71449bc64eeb["base64"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> 66c6348c_7716_027c_42d7_71449bc64eeb 2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169 8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5 cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 d98e8b62_bf78_a37b_60df_6acbcc3d5521["chromadb"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> d98e8b62_bf78_a37b_60df_6acbcc3d5521 d533015f_a415_cc9a_d461_50b1acd925d0["chromadb.config"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> d533015f_a415_cc9a_d461_50b1acd925d0 cd17727f_b882_7f06_aadc_71fbf75bebb0["numpy"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> cd17727f_b882_7f06_aadc_71fbf75bebb0 c45be9d8_4862_0a1e_47f1_1abb2540ba7f["chromadb.api"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> c45be9d8_4862_0a1e_47f1_1abb2540ba7f c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> c554676d_b731_47b2_a98f_c1c2d537c0aa bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3 f4d905c6_a2b2_eb8f_be9b_7808b72f6a16["langchain_core.utils"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> f4d905c6_a2b2_eb8f_be9b_7808b72f6a16 d55af636_303c_0eb6_faee_20d89bd952d5["langchain_core.vectorstores"] d4a05de9_1f0f_3b21_8171_181bb47227ef --> d55af636_303c_0eb6_faee_20d89bd952d5 style d4a05de9_1f0f_3b21_8171_181bb47227ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""This is the langchain_chroma.vectorstores module.
It contains the Chroma class which is a vector store for handling various tasks.
"""
from __future__ import annotations
import base64
import logging
import uuid
from collections.abc import Callable, Iterable, Sequence
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
)
import chromadb
import chromadb.config
import numpy as np
from chromadb import Search, Settings
from chromadb.api import CreateCollectionConfiguration
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.utils import xor_args
from langchain_core.vectorstores import VectorStore
if TYPE_CHECKING:
from chromadb.api.types import Where, WhereDocument
logger = logging.getLogger()
DEFAULT_K = 4 # Number of Documents to return.
def _results_to_docs(results: Any) -> list[Document]:
return [doc for doc, _ in _results_to_docs_and_scores(results)]
def _results_to_docs_and_scores(results: Any) -> list[tuple[Document, float]]:
return [
# TODO: Chroma can do batch querying,
# we shouldn't hard code to the 1st result
(
Document(page_content=result[0], metadata=result[1] or {}, id=result[2]),
result[3],
)
for result in zip(
results["documents"][0],
results["metadatas"][0],
results["ids"][0],
results["distances"][0],
strict=False,
)
if result[0] is not None
]
def _results_to_docs_and_vectors(results: Any) -> list[tuple[Document, np.ndarray]]:
"""Convert ChromaDB results to documents and vectors, filtering out None content."""
return [
// ... (1400 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- base64
- chromadb
- chromadb.api
- chromadb.api.types
- chromadb.config
- chromadb.utils.batch_utils
- collections.abc
- langchain_core.documents
- langchain_core.embeddings
- langchain_core.utils
- langchain_core.vectorstores
- logging
- numpy
- pathlib
- typing
- uuid
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 CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in vectorstores.py?
vectorstores.py defines 6 function(s): _results_to_docs, _results_to_docs_and_scores, _results_to_docs_and_vectors, chromadb, cosine_similarity, maximal_marginal_relevance.
What does vectorstores.py depend on?
vectorstores.py imports 16 module(s): base64, chromadb, chromadb.api, chromadb.api.types, chromadb.config, chromadb.utils.batch_utils, collections.abc, langchain_core.documents, and 8 more.
Where is vectorstores.py in the architecture?
vectorstores.py is located at libs/partners/chroma/langchain_chroma/vectorstores.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/chroma/langchain_chroma).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free