Home / File/ vectorstores.py — langchain Source File

vectorstores.py — langchain Source File

Architecture documentation for vectorstores.py, a python file in the langchain codebase. 18 imports, 0 dependents.

File python CoreAbstractions Serialization 18 imports 2 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544["vectorstores.py"]
  c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6
  9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  0c635125_6987_b8b3_7ff7_d60249aecde7["warnings"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 0c635125_6987_b8b3_7ff7_d60249aecde7
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  436f77bc_653d_0edb_555c_c2679d5a59ac["itertools"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 436f77bc_653d_0edb_555c_c2679d5a59ac
  7aaf52d4_ee88_411e_980e_bc4beeeb30ad["operator"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 7aaf52d4_ee88_411e_980e_bc4beeeb30ad
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  cd17727f_b882_7f06_aadc_71fbf75bebb0["numpy"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> cd17727f_b882_7f06_aadc_71fbf75bebb0
  2d1edd36_20be_d887_f834_7b58c1b5a50f["langchain_core._api.deprecation"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 2d1edd36_20be_d887_f834_7b58c1b5a50f
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3
  2971f9da_6393_a3e3_610e_ace3d35ee978["langchain_core.runnables.config"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> 2971f9da_6393_a3e3_610e_ace3d35ee978
  d55af636_303c_0eb6_faee_20d89bd952d5["langchain_core.vectorstores"]
  cf5060bb_3c9f_3c4e_d3a7_03999abcf544 --> d55af636_303c_0eb6_faee_20d89bd952d5
  style cf5060bb_3c9f_3c4e_d3a7_03999abcf544 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import functools
import os
import uuid
import warnings
from collections.abc import Callable
from itertools import islice
from operator import itemgetter
from typing import TYPE_CHECKING, Any

import numpy as np
from langchain_core._api.deprecation import deprecated
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.runnables.config import run_in_executor
from langchain_core.vectorstores import VectorStore
from qdrant_client import AsyncQdrantClient, QdrantClient
from qdrant_client.http import models
from qdrant_client.local.async_qdrant_local import AsyncQdrantLocal

from langchain_qdrant._utils import maximal_marginal_relevance

if TYPE_CHECKING:
    from collections.abc import AsyncGenerator, Generator, Iterable, Sequence

    DictFilter = dict[str, str | int | bool | dict | list]
    MetadataFilter = DictFilter | models.Filter


class QdrantException(Exception):  # noqa: N818
    """`Qdrant` related exceptions."""


def sync_call_fallback(method: Callable) -> Callable:
    """Call the synchronous method if the async method is not implemented.

    This decorator should only be used for methods that are defined as async in the
    class.

    """

    @functools.wraps(method)
    async def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
        try:
            return await method(self, *args, **kwargs)
        except NotImplementedError:
            # If the async method is not implemented, call the synchronous method
            # by removing the first letter from the method name. For example,
            # if the async method is called `aadd_texts`, the synchronous method
            # will be called `aad_texts`.
            return await run_in_executor(
                None, getattr(self, method.__name__[1:]), *args, **kwargs
            )

    return wrapper


@deprecated(since="0.1.2", alternative="QdrantVectorStore", removal="0.5.0")
class Qdrant(VectorStore):
// ... (2273 more lines)

Subdomains

Dependencies

  • collections.abc
  • functools
  • itertools
  • langchain_core._api.deprecation
  • langchain_core.documents
  • langchain_core.embeddings
  • langchain_core.runnables.config
  • langchain_core.vectorstores
  • langchain_qdrant._utils
  • numpy
  • operator
  • os
  • qdrant_client
  • qdrant_client.http
  • qdrant_client.local.async_qdrant_local
  • typing
  • uuid
  • warnings

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, Serialization subdomain.
What functions are defined in vectorstores.py?
vectorstores.py defines 2 function(s): collections, sync_call_fallback.
What does vectorstores.py depend on?
vectorstores.py imports 18 module(s): collections.abc, functools, itertools, langchain_core._api.deprecation, langchain_core.documents, langchain_core.embeddings, langchain_core.runnables.config, langchain_core.vectorstores, and 10 more.
Where is vectorstores.py in the architecture?
vectorstores.py is located at libs/partners/qdrant/langchain_qdrant/vectorstores.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/partners/qdrant/langchain_qdrant).

Analyze Your Own Codebase

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

Try Supermodel Free