### Qdrant Initialization from Existing Collection Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Gets an instance of an existing Qdrant collection without inserting new embeddings. ```APIDOC ## GET /from_existing_collection ### Description Gets an instance of an existing Qdrant collection without inserting new embeddings. ### Method GET ### Endpoint `/from_existing_collection` ### Parameters #### Query Parameters - **embedding** (Embeddings) - Required - **path** (str | None) - Optional - **collection_name** (str | None) - Optional - **location** (str | None) - Optional - **url** (str | None) - Optional - **port** (int | None) - Optional - Defaults to 6333 - **grpc_port** (int) - Optional - Defaults to 6334 - **prefer_grpc** (bool) - Optional - Defaults to False - **https** (bool | None) - Optional - **api_key** (str | None) - Optional - **prefix** (str | None) - Optional - **timeout** (int | None) - Optional - **host** (str | None) - Optional - **content_payload_key** (str) - Optional - Defaults to 'page_content' - **metadata_payload_key** (str) - Optional - Defaults to 'metadata' - **distance_strategy** (str) - Optional - Defaults to 'COSINE' - **vector_name** (str | None) - Optional - **kwargs** (Any) - Other keyword arguments. ### Response #### Success Response (200) - **response** (Qdrant) - Instance of the Qdrant vector store. #### Response Example ```json { "response": "" } ``` ``` -------------------------------- ### Configure Qdrant Retriever with MMR Fetch Count Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores This example demonstrates configuring the Qdrant retriever for MMR search, focusing on increasing the number of documents fetched for consideration by the MMR algorithm while limiting the final returned documents. This can improve MMR results by providing a larger pool of candidates. ```python docsearch.as_retriever( search_type="mmr", search_kwargs={"k": 5, "fetch_k": 50} ) ``` -------------------------------- ### Async Get Documents by IDs Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Provides the functionality to asynchronously retrieve documents from the Qdrant store based on their unique IDs. ```APIDOC ## Async Get Documents by IDs ### Description Asynchronously retrieves documents from the Qdrant vector store using a list of document IDs. It handles cases where some IDs might not be found, and the order of returned documents is not guaranteed to match the input order. ### Method `_async_aget_by_ids(_ids : Sequence[str]_)` ### Endpoint `/service/v1/{qdrant-endpoint}` (Implied) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Assuming 'qdrant' is an initialized Qdrant instance and 'ids_to_retrieve' is a list of strings # retrieved_docs = await qdrant._async_aget_by_ids(ids_to_retrieve) ``` ### Response #### Success Response (200) - **List[Document]** - A list of Document objects corresponding to the provided IDs. Fewer documents may be returned if IDs are not found or duplicated. #### Response Example ```json [ { "page_content": "Document content here...", "metadata": { "source": "doc1.txt" }, "id": "doc_id_1" } ] ``` ### Notes - Added in version 0.2.11. - Does not raise exceptions if no documents are found for some IDs. ``` -------------------------------- ### Qdrant Initialization Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Initializes the Qdrant client with various configuration options. ```APIDOC ## __init__ ### Description Initializes the Qdrant client with necessary components. ### Method __init__ ### Parameters #### Path Parameters - **client** (Any) - The Qdrant client instance. - **collection_name** (str) - The name of the collection. - **embeddings** (Embeddings | None) - The embeddings model to use. - **content_payload_key** (str) - The key for content in the payload. Defaults to 'page_content'. - **metadata_payload_key** (str) - The key for metadata in the payload. Defaults to 'metadata'. - **distance_strategy** (str) - The distance strategy for similarity search. Defaults to 'COSINE'. - **vector_name** (str | None) - The name of the vector. - **async_client** (Any | None) - The asynchronous client instance. - **embedding_function** (Callable | None) - The embedding function to use. ### Return type None ``` -------------------------------- ### GET /get_by_ids Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Retrieves documents from the Qdrant vector store based on their unique IDs. ```APIDOC ## GET /get_by_ids ### Description Retrieves documents by their IDs. The returned documents will have the ID field set to the ID of the document in the vector store. Fewer documents may be returned than requested if some IDs are not found or if there are duplicated IDs. ### Method GET ### Endpoint `/get_by_ids` ### Parameters #### Path Parameters None #### Query Parameters - **_ids** (Sequence[str]) - Required - A sequence of document IDs to retrieve. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **list[Document]** - A list of Document objects matching the provided IDs. #### Response Example ```json [ { "page_content": "content of the first document", "metadata": { "source": "doc1.txt" }, "type": "Document" }, { "page_content": "content of the second document", "metadata": { "source": "doc2.txt" }, "type": "Document" } ] ``` ``` -------------------------------- ### Qdrant Initialization from Texts Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Constructs a Qdrant wrapper from a list of texts, embeddings, and optional configurations. ```APIDOC ## POST /from_texts ### Description Constructs a Qdrant wrapper from a list of texts, embeddings, and optional configurations. ### Method POST ### Endpoint `/from_texts` ### Parameters #### Request Body - **texts** (list[str]) - Required - A list of texts to be indexed in Qdrant. - **embedding** (Embeddings) - Required - A subclass of Embeddings, responsible for text vectorization. - **metadatas** (list[dict] | None) - Optional - An optional list of metadata. If provided it has to be of the same length as a list of texts. - **ids** (Sequence[str] | None) - Optional - **location** (str | None) - Optional - **url** (str | None) - Optional - **port** (int | None) - Optional - Defaults to 6333 - **grpc_port** (int) - Optional - Defaults to 6334 - **prefer_grpc** (bool) - Optional - Defaults to False - **https** (bool | None) - Optional - **api_key** (str | None) - Optional - **prefix** (str | None) - Optional - **timeout** (int | None) - Optional - **host** (str | None) - Optional - **path** (str | None) - Optional - **collection_name** (str | None) - Optional - **distance_func** (str) - Optional - Defaults to 'Cosine' - **content_payload_key** (str) - Optional - Defaults to 'page_content' - **metadata_payload_key** (str) - Optional - Defaults to 'metadata' - **vector_name** (str | None) - Optional - **batch_size** (int) - Optional - Defaults to 64 - **shard_number** (int | None) - Optional - **replication_factor** (int | None) - Optional - **write_consistency_factor** (int | None) - Optional - **on_disk_payload** (bool | None) - Optional - **hnsw_config** (HnswConfigDiff | None) - Optional - **optimizers_config** (OptimizersConfigDiff | None) - Optional - **wal_config** (WalConfigDiff | None) - Optional - **quantization_config** (ScalarQuantization | ProductQuantization | BinaryQuantization | None) - Optional - **init_from** (InitFrom | None) - Optional - **on_disk** (bool | None) - Optional - **force_recreate** (bool) - Optional - Defaults to False - **kwargs** (Any) - Other keyword arguments. ### Response #### Success Response (200) - **response** (Qdrant) - Instance of the Qdrant vector store initialized from texts. #### Response Example ```json { "response": "" } ``` ``` -------------------------------- ### Qdrant Initialization and Basic Usage Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Demonstrates how to initialize the Qdrant vector store using embeddings and texts, with options for local or remote storage. ```APIDOC ## Qdrant Initialization ### Description Initializes the Qdrant vector store, which can act as an in-memory or remote document store. It handles embedding texts and storing them in Qdrant. ### Method `Qdrant.afrom_texts()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from langchain_qdrant import Qdrant from langchain_openai import OpenAIEmbeddings # Assuming 'texts' is a list of strings and 'embeddings' is an initialized embedding model # qdrant = await Qdrant.afrom_texts(texts, embeddings, "localhost") ``` ### Response #### Success Response (200) Returns an initialized Qdrant vector store instance. #### Response Example ```json { "type": "Qdrant" } ``` ``` -------------------------------- ### Retrieve Single Most Similar Document with Qdrant Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores This example shows how to configure the Qdrant retriever to fetch only the single most similar document from the dataset. This is a common use case when you need the absolute closest match to a query. ```python docsearch.as_retriever(search_kwargs={"k": 1}) ``` -------------------------------- ### Qdrant Initialization and `from_texts` Method Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Demonstrates how to initialize the Qdrant client and use the `from_texts` method to create embeddings and store them in the Qdrant database. ```APIDOC ## Qdrant Initialization and `from_texts` Method ### Description Initializes the Qdrant database, optionally as an in-memory docstore, and adds text embeddings to it. This provides a quick start for using Qdrant. ### Method `Qdrant.from_texts(texts: list[str], embeddings: Embeddings, location: str | QdrantBase, **kwargs)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **texts** (list[str]) - The list of texts to embed and store. - **embeddings** (Embeddings) - An instance of an embeddings model (e.g., OpenAIEmbeddings). - **location** (str | QdrantBase) - Specifies the Qdrant instance. Can be ':memory:' for in-memory, a URL string, or a QdrantBase instance. - **kwargs** (Any) - Additional arguments passed directly into REST client initialization. - **ids** (_Optional_ _[__Sequence_ _[__str_ _]__]_) – Optional list of ids to associate with the texts. Ids have to be uuid-like strings. - **url** (_Optional_ _[__str_ _]_) – either host or str of “Optional[scheme], host, Optional[port], Optional[prefix]”. Default: None - **port** (_Optional_ _[__int_ _]_) – Port of the REST API interface. Default: 6333 - **grpc_port** (_int_) – Port of the gRPC interface. Default: 6334 - **prefer_grpc** (_bool_) – If true - use gPRC interface whenever possible in custom methods. Default: False - **https** (_Optional_ _[__bool_ _]_) – If true - use HTTPS(SSL) protocol. Default: None - **api_key** (_Optional_ _[__str_ _]_) – API key for authentication in Qdrant Cloud. Default: None Can also be set via environment variable QDRANT_API_KEY. - **prefix** (_Optional_ _[__str_ _]_) – If not None - add prefix to the REST URL path. Example: service/v1 will result in `http://localhost:6333/service/v1/{qdrant-endpoint}` for REST API. Default: None - **timeout** (_Optional_ _[__int_ _]_) – Timeout for REST and gRPC API requests. Default: 5.0 seconds for REST and unlimited for gRPC - **host** (_Optional_ _[__str_ _]_) – Host name of Qdrant service. If url and host are None, set to ‘localhost’. Default: None - **path** (_Optional_ _[__str_ _]_) – Path in which the vectors will be stored while using local mode. Default: None - **collection_name** (_Optional_ _[__str_ _]_) – Name of the Qdrant collection to be used. If not provided, it will be created randomly. Default: None - **distance_func** (_str_) – Distance function. One of: “Cosine” / “Euclid” / “Dot”. Default: “Cosine” - **content_payload_key** (_str_) – A payload key used to store the content of the document. Default: “page_content” - **metadata_payload_key** (_str_) – A payload key used to store the metadata of the document. Default: “metadata” - **vector_name** (_Optional_ _[__str_ _]_) – Name of the vector to be used internally in Qdrant. Default: None - **batch_size** (_int_) – How many vectors upload per-request. Default: 64 - **shard_number** (_Optional_ _[__int_ _]_) – Number of shards in collection. Default is 1, minimum is 1. - **replication_factor** (_Optional_ _[__int_ _]_) – Replication factor for collection. Default is 1, minimum is 1. Defines how many copies of each shard will be created. Have effect only in distributed mode. - **write_consistency_factor** (_Optional_ _[__int_ _]_) – Write consistency factor for collection. Default is 1, minimum is 1. Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact. Have effect only in distributed mode. - **on_disk_payload** (_Optional_ _[__bool_ _]_) – If true - point`s payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. - **hnsw_config** (_Optional_ _[__models.HnswConfigDiff_ _]_) – Params for HNSW index - **optimizers_config** (_Optional_ _[__models.OptimizersConfigDiff_ _]_) – Params for optimizer - **wal_config** (_Optional_ _[__models.WalConfigDiff_ _]_) – Params for Write-Ahead-Log - **quantization_config** (_Optional_ _[__models.QuantizationConfig_ _]_) – Params for quantization, if None - quantization will be disabled - **init_from** (_Optional_ _[__models.InitFrom_ _]_) – Use data stored in another collection to initialize this collection - **on_disk** (_Optional_ _[__bool_ _]_) – If true - vectors will be stored on disk, reducing memory usage. - **force_recreate** (_bool_) – Force recreating the collection. ### Request Example ```python from langchain_qdrant import Qdrant from langchain_openai import OpenAIEmbeddings texts = ["text1", "text2", "text3"] embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_texts(texts, embeddings, "localhost") ``` ### Response #### Success Response (200) Returns an initialized Qdrant instance. #### Response Example ```json { "message": "Qdrant client initialized successfully." } ``` ``` -------------------------------- ### Construct Qdrant Instance Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Constructs an instance of the Qdrant client with specified configuration. ```APIDOC ## POST /construct_instance ### Description Constructs an instance of the Qdrant client. ### Method POST ### Endpoint /construct_instance ### Parameters #### Query Parameters - **location** (str | None) - Optional - **url** (str | None) - Optional - **port** (int | None) - Optional - Defaults to 6333. - **grpc_port** (int) - Optional - Defaults to 6334. - **prefer_grpc** (bool) - Optional - Defaults to False. - **https** (bool | None) - Optional - **api_key** (str | None) - Optional - **prefix** (str | None) - Optional - **timeout** (int | None) - Optional - **host** (str | None) - Optional - **path** (str | None) - Optional - **collection_name** (str | None) - Optional - **distance_func** (str) - Optional - Defaults to 'Cosine'. - **content_payload_key** (str) - Optional - Defaults to 'page_content'. - **metadata_payload_key** (str) - Optional - Defaults to 'metadata'. - **vector_name** (str | None) - Optional - **shard_number** (int | None) - Optional - **replication_factor** (int | None) - Optional - **write_consistency_factor** (int | None) - Optional - **on_disk_payload** (bool | None) - Optional - **hnsw_config** (HnswConfigDiff | None) - Optional - **optimizers_config** (OptimizersConfigDiff | None) - Optional - **wal_config** (WalConfigDiff | None) - Optional - **quantization_config** (ScalarQuantization | ProductQuantization | BinaryQuantization | None) - Optional - **init_from** (InitFrom | None) - Optional - **on_disk** (bool | None) - Optional - **force_recreate** (bool) - Optional - Defaults to False. - **kwargs** (Any) - Optional - Any other named arguments to pass through. #### Request Body - **texts** (list[str]) - Required - **embedding** (Embeddings) - Required ### Request Example { "texts": ["text1", "text2"], "embedding": { "model_name": "all-MiniLM-L6-v2" } } ### Response #### Success Response (200) - **Qdrant** - An instance of the Qdrant client. #### Response Example (An instance of the Qdrant client object, not directly representable as JSON) ``` -------------------------------- ### Async Get Documents by IDs from Qdrant Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Retrieves documents from the Qdrant vector store asynchronously using a list of document IDs. It returns a list of Document objects, where each document has its ID field set. Fewer documents than requested may be returned if IDs are not found or duplicated. The order of returned documents is not guaranteed to match the input order. ```python from typing import Sequence from langchain_core.documents import Document # Assuming 'qdrant' is an initialized Qdrant instance # Assuming 'ids' is a Sequence of strings representing document IDs # Example of async retrieval by IDs # retrieved_docs: list[Document] = await qdrant.aget_by_ids(ids) ``` -------------------------------- ### Initialize Qdrant Client (Python) Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Initializes the Qdrant client with necessary components for interacting with the vector store. It supports various configuration options including connection details, embedding models, and payload keys. ```python def __init__( self, _client: Any, _collection_name: str, _embeddings: Embeddings | None = None, _content_payload_key: str = 'page_content', _metadata_payload_key: str = 'metadata', _distance_strategy: str = 'COSINE', _vector_name: str | None = None, _async_client: Any | None = None, _embedding_function: Callable | None = None, ) -> None: ``` -------------------------------- ### Qdrant Vector Store Initialization Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Initializes the Qdrant vector store with client, collection name, and optional embeddings, content/metadata keys, distance strategy, vector name, async client, and embedding function. ```APIDOC ## Qdrant Vector Store Initialization ### Description Initializes the Qdrant vector store with necessary components. This class is deprecated and `QdrantVectorStore` should be used instead. ### Method `__init__` ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **client** (Any) - The Qdrant client instance. - **collection_name** (str) - The name of the Qdrant collection. - **embeddings** (Embeddings | None, optional) - The embeddings object. Defaults to None. - **content_payload_key** (str, optional) - The key for the content payload. Defaults to 'page_content'. - **metadata_payload_key** (str, optional) - The key for the metadata payload. Defaults to 'metadata'. - **distance_strategy** (str, optional) - The distance strategy to use (e.g., 'COSINE'). Defaults to 'COSINE'. - **vector_name** (str | None, optional) - The name of the vector. Defaults to None. - **async_client** (Any | None, optional) - The async Qdrant client instance. Defaults to None. - **embedding_function** (Callable | None, optional) - The embedding function to use. Defaults to None. ### Request Example ```python from qdrant_client import QdrantClient from langchain_qdrant import Qdrant client = QdrantClient() collection_name = "MyCollection" # Assuming you have an embeddings object or function # embedding_function = ... qdrant = Qdrant(client, collection_name, embedding_function) ``` ### Response #### Success Response (200) N/A (Constructor does not return a response in the traditional sense) #### Response Example N/A ``` -------------------------------- ### Construct Qdrant Instance (Python) Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Class method to construct a Qdrant client instance. Allows configuration of connection details, collection parameters, and various Qdrant-specific settings like HNSW, optimizers, and WAL configurations. ```python @classmethod def construct_instance( cls, texts: list[str], embedding: Embeddings, location: str | None = None, url: str | None = None, port: int | None = 6333, grpc_port: int = 6334, prefer_grpc: bool = False, https: bool | None = None, api_key: str | None = None, prefix: str | None = None, timeout: int | None = None, host: str | None = None, path: str | None = None, collection_name: str | None = None, distance_func: str = 'Cosine', content_payload_key: str = 'page_content', metadata_payload_key: str = 'metadata', vector_name: str | None = None, shard_number: int | None = None, replication_factor: int | None = None, write_consistency_factor: int | None = None, on_disk_payload: bool | None = None, hnsw_config: HnswConfigDiff | None = None, optimizers_config: OptimizersConfigDiff | None = None, wal_config: WalConfigDiff | None = None, quantization_config: ScalarQuantization | ProductQuantization | BinaryQuantization | None = None, init_from: InitFrom | None = None, on_disk: bool | None = None, force_recreate: bool = False, **kwargs: Any, ) -> 'Qdrant': """ Parameters: texts (list[str]): embedding (Embeddings): location (str | None): url (str | None): port (int | None): grpc_port (int): prefer_grpc (bool): https (bool | None): api_key (str | None): prefix (str | None): timeout (int | None): host (str | None): path (str | None): collection_name (str | None): distance_func (str): """ pass ``` -------------------------------- ### Async Construct Instance Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Asynchronously constructs a Qdrant instance from a list of texts and embedding information. ```APIDOC ## _aconstruct_instance ### Description Asynchronously constructs a Qdrant instance. ### Method _async classmethod _aconstruct_instance ### Endpoint N/A (Class method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **texts** (list[str]) - List of texts to initialize the instance with. - **embedding** (Embeddings) - The embedding model to use. - **location** (str | None) - The location of the Qdrant instance. - **url** (str | None) - The URL of the Qdrant instance. - **port** (int | None) - The port of the Qdrant instance. Defaults to 6333. - **grpc_port** (int) - The gRPC port of the Qdrant instance. Defaults to 6334. - **prefer_grpc** (bool) - Whether to prefer gRPC. Defaults to False. - **https** (bool | None) - Whether to use HTTPS. - **api_key** (str | None) - The API key for authentication. - **prefix** (str | None) - The URL prefix. - **timeout** (int | None) - The request timeout in seconds. - **host** (str | None) - The host of the Qdrant instance. - **path** (str | None) - The path for the Qdrant instance. - **collection_name** (str | None) - The name of the collection. - **distance_func** (str) - The distance function to use. Defaults to 'Cosine'. - **content_payload_key** (str) - The key for content in the payload. Defaults to 'page_content'. - **metadata_payload_key** (str) - The key for metadata in the payload. Defaults to 'metadata'. - **vector_name** (str | None) - The name of the vector. - **shard_number** (int | None) - The number of shards. - **replication_factor** (int | None) - The replication factor. - **write_consistency_factor** (int | None) - The write consistency factor. - **on_disk_payload** (bool | None) - Whether to store payload on disk. - **hnsw_config** (HnswConfigDiff | None) - HNSW configuration. - **optimizers_config** (OptimizersConfigDiff | None) - Optimizers configuration. - **wal_config** (WalConfigDiff | None) - WAL configuration. - **quantization_config** (ScalarQuantization | ProductQuantization | BinaryQuantization | None) - Quantization configuration. - **init_from** (InitFrom | None) - Configuration for initializing from an existing instance. - **on_disk** (bool | None) - Whether to use on-disk storage. - **force_recreate** (bool) - Whether to force recreation of the collection. Defaults to False. - **kwargs** (Any) - Additional keyword arguments. ### Return type Qdrant ``` -------------------------------- ### Qdrant Initialization from Documents Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Initializes a Qdrant vector store from a list of documents and an embedding function. ```APIDOC ## POST /from_documents ### Description Initializes a Qdrant vector store from a list of documents and an embedding function. ### Method POST ### Endpoint `/from_documents` ### Parameters #### Request Body - **documents** (list[Document]) - Required - List of Documents to add to the vectorstore. - **embedding** (Embeddings) - Required - Embedding function to use. - **kwargs** (Any) - Additional keyword arguments. ### Response #### Success Response (200) - **response** (VectorStore) - VectorStore initialized from documents and embeddings. #### Response Example ```json { "response": "" } ``` ``` -------------------------------- ### afrom_documents Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Asynchronously initializes a Qdrant vector store from a list of documents and an embedding function. ```APIDOC ## POST /afrom_documents ### Description Asynchronously initializes a Qdrant vector store from a list of documents and an embedding function. ### Method POST ### Endpoint /afrom_documents ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **documents** (list[Document]) - Required - List of Documents to add to the vectorstore. - **embedding** (Embeddings) - Required - Embedding function to use. - **kwargs** (Any) - Optional - Additional keyword arguments. ### Request Example ```json { "documents": [{"page_content": "doc1 content", "metadata": {"source": "file1"}}], "embedding": {"model_name": "all-MiniLM-L6-v2"} } ``` ### Response #### Success Response (200) - **result** (VectorStore) - VectorStore initialized from documents and embeddings. #### Response Example ```json { "result": {"type": "Qdrant", "config": {...}} } ``` ``` -------------------------------- ### Initialize Qdrant from Documents (Python) Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Asynchronously initializes a Qdrant vector store from a list of Document objects and an embedding function. Additional keyword arguments can be passed for configuration. This method returns the initialized VectorStore instance. ```python _async classmethod _afrom_documents( _documents : list[Document]_, _embedding : Embeddings_, _** kwargs: Any_, ) → Self ``` -------------------------------- ### Initialize Qdrant from Texts Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Constructs a Qdrant vector store from a list of raw texts, embeddings, and optional metadata. Supports batch processing and various configuration options for collection creation. ```python _classmethod _from_texts( _texts : list[str]_, _embedding : Embeddings_, _metadatas : list[dict] | None = None_, _ids : Sequence[str] | None = None_, _location : str | None = None_, _url : str | None = None_, _port : int | None = 6333_, _grpc_port : int = 6334_, _prefer_grpc : bool = False_, _https : bool | None = None_, _api_key : str | None = None_, _prefix : str | None = None_, _timeout : int | None = None_, _host : str | None = None_, _path : str | None = None_, _collection_name : str | None = None_, _distance_func : str = 'Cosine'_, _content_payload_key : str = 'page_content'_, _metadata_payload_key : str = 'metadata'_, _vector_name : str | None = None_, _batch_size : int = 64_, _shard_number : int | None = None_, _replication_factor : int | None = None_, _write_consistency_factor : int | None = None_, _on_disk_payload : bool | None = None_, _hnsw_config : models.HnswConfigDiff | None = None_, _optimizers_config : models.OptimizersConfigDiff | None = None_, _wal_config : models.WalConfigDiff | None = None_, _quantization_config : models.QuantizationConfig | None = None_, _init_from : models.InitFrom | None = None_, _on_disk : bool | None = None_, _force_recreate : bool = False_, _** kwargs: Any_, ) → Qdrant[source]# ``` -------------------------------- ### Initialize Qdrant from Texts (Python) Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Asynchronously constructs and initializes a Qdrant vector store from a list of texts. This method requires an embedding function and allows for extensive configuration, including metadata, IDs, connection details (URL, port, gRPC port, HTTPS), API key, batch size, and various Qdrant-specific settings like collection configuration and storage options. It returns a Qdrant instance. ```python _async classmethod _afrom_texts( _texts : list[str]_, _embedding : Embeddings_, _metadatas : list[dict] | None = None_, _ids : Sequence[str] | None = None_, _location : str | None = None_, _url : str | None = None_, _port : int | None = 6333_, _grpc_port : int = 6334_, _prefer_grpc : bool = False_, _https : bool | None = None_, _api_key : str | None = None_, _prefix : str | None = None_, _timeout : int | None = None_, _host : str | None = None_, _path : str | None = None_, _collection_name : str | None = None_, _distance_func : str = 'Cosine'_, _content_payload_key : str = 'page_content'_, _metadata_payload_key : str = 'metadata'_, _vector_name : str | None = None_, _batch_size : int = 64_, _shard_number : int | None = None_, _replication_factor : int | None = None_, _write_consistency_factor : int | None = None_, _on_disk_payload : bool | None = None_, _hnsw_config : models.HnswConfigDiff | None = None_, _optimizers_config : models.OptimizersConfigDiff | None = None_, _wal_config : models.WalConfigDiff | None = None_, _quantization_config : models.QuantizationConfig | None = None_, _init_from : models.InitFrom | None = None_, _on_disk : bool | None = None_, _force_recreate : bool = False_, _** kwargs: Any_, ) → Qdrant ``` -------------------------------- ### Qdrant Vector Store Class Source: https://python.langchain.com/api_reference/qdrant/vectorstores Documentation for the Qdrant vector store class, used for interacting with Qdrant databases. ```APIDOC ## Qdrant Vector Store ### Description Provides a class for interacting with Qdrant vector databases. ### Method N/A ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **client** (object) - Required - The Qdrant client instance. - **collection_name** (str) - Required - The name of the Qdrant collection. ### Request Example ```json { "client": "", "collection_name": "my_collection" } ``` ### Response #### Success Response (200) This class is used for initialization and interaction, not for direct response data. #### Response Example N/A ``` -------------------------------- ### afrom_texts Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Asynchronously constructs a Qdrant vector store wrapper from a list of texts, embeddings, and connection details. ```APIDOC ## POST /afrom_texts ### Description Asynchronously constructs a Qdrant vector store wrapper from a list of texts, embeddings, and connection details. ### Method POST ### Endpoint /afrom_texts ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **texts** (list[str]) - Required - A list of texts to be indexed in Qdrant. - **embedding** (Embeddings) - Required - A subclass of Embeddings, responsible for text vectorization. - **metadatas** (Optional[list[dict]]) - Optional - An optional list of metadata. If provided, it must have the same length as the list of texts. - **ids** (Optional[Sequence[str]]) - Optional - Optional list of IDs to associate with the texts. IDs must be UUID-like strings. - **location** (Optional[str]) - Optional - If ‘:memory:’ - use in-memory Qdrant instance. If str - use it as a URL parameter. If None - fallback to relying on host and port parameters. - **url** (Optional[str]) - Optional - Either host or string of “Optional[scheme], host, Optional[port], Optional[prefix]”. - **port** (Optional[int]) - Optional - Port of the REST API interface. Defaults to 6333. - **grpc_port** (int) - Optional - Port of the gRPC interface. Defaults to 6334. - **prefer_grpc** (bool) - Optional - If true, use gRPC interface whenever possible in custom methods. Defaults to False. - **https** (Optional[bool]) - Optional - If true, use HTTPS (SSL) protocol. - **api_key** (Optional[str]) - Optional - API key for authentication in Qdrant Cloud. Can also be set via environment variable QDRANT_API_KEY. - **prefix** (Optional[str]) - Optional - If not None, add prefix to the REST URL path. - **timeout** (Optional[int]) - Optional - Connection timeout in seconds. - **host** (Optional[str]) - Optional - Hostname of the Qdrant instance. - **path** (Optional[str]) - Optional - Path to the Qdrant instance. - **collection_name** (Optional[str]) - Optional - Name of the collection to use. - **distance_func** (str) - Optional - Distance function to use. Defaults to 'Cosine'. - **content_payload_key** (str) - Optional - Key for content in the payload. Defaults to 'page_content'. - **metadata_payload_key** (str) - Optional - Key for metadata in the payload. Defaults to 'metadata'. - **vector_name** (Optional[str]) - Optional - Name of the vector to use. - **batch_size** (int) - Optional - Number of vectors to upload per request. Defaults to 64. - **shard_number** (Optional[int]) - Optional - Number of shards for the collection. - **replication_factor** (Optional[int]) - Optional - Replication factor for the collection. - **write_consistency_factor** (Optional[int]) - Optional - Write consistency factor for the collection. - **on_disk_payload** (Optional[bool]) - Optional - Whether to store payload on disk. - **hnsw_config** (Optional[models.HnswConfigDiff]) - Optional - HNSW configuration. - **optimizers_config** (Optional[models.OptimizersConfigDiff]) - Optional - Optimizers configuration. - **wal_config** (Optional[models.WalConfigDiff]) - Optional - Write-Ahead Log configuration. - **quantization_config** (Optional[models.QuantizationConfig]) - Optional - Quantization configuration. - **init_from** (Optional[models.InitFrom]) - Optional - Configuration for initializing from an existing instance. - **on_disk** (Optional[bool]) - Optional - Whether to use disk storage for the collection. - **force_recreate** (bool) - Optional - Whether to force recreation of the collection if it exists. Defaults to False. - **kwargs** (Any) - Optional - Additional keyword arguments. ### Request Example ```json { "texts": ["text1", "text2"], "embedding": {"model_name": "all-MiniLM-L6-v2"}, "collection_name": "my_collection", "url": "http://localhost:6333" } ``` ### Response #### Success Response (200) - **result** (Qdrant) - The constructed Qdrant vector store instance. #### Response Example ```json { "result": {"type": "Qdrant", "config": {...}} } ``` ``` -------------------------------- ### Qdrant Utilities Source: https://python.langchain.com/api_reference/qdrant/index Includes utility functions and exception classes for Qdrant integration. ```APIDOC ## Qdrant Utilities ### Description Provides utility functions like `sync_call_fallback` and exception classes for Qdrant. ### Functions - `langchain_qdrant.vectorstores.sync_call_fallback(method)`: Call the synchronous method if the async method is not implemented. ### Exceptions - `langchain_qdrant.vectorstores.QdrantException`: Qdrant related exceptions. ``` -------------------------------- ### Initialize Qdrant from Existing Collection Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Retrieves an instance of an existing Qdrant collection without inserting new embeddings. Allows configuration of connection parameters and collection details. ```python _classmethod _from_existing_collection( _embedding : Embeddings_, _path : str | None = None_, _collection_name : str | None = None_, _location : str | None = None_, _url : str | None = None_, _port : int | None = 6333_, _grpc_port : int = 6334_, _prefer_grpc : bool = False_, _https : bool | None = None_, _api_key : str | None = None_, _prefix : str | None = None_, _timeout : int | None = None_, _host : str | None = None_, _content_payload_key : str = 'page_content'_, _metadata_payload_key : str = 'metadata'_, _distance_strategy : str = 'COSINE'_, _vector_name : str | None = None_, _** kwargs: Any_, ) → Qdrant[source]# ``` -------------------------------- ### Initialize Qdrant Vector Store Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores This snippet demonstrates how to initialize the Qdrant vector store with a client and collection name. It requires the qdrant_client and langchain_qdrant libraries. The `embedding_function` is a required parameter for initializing the store. ```python from qdrant_client import QdrantClient from langchain_qdrant import Qdrant client = QdrantClient() collection_name = "MyCollection" # Assume embedding_function is defined elsewhere # embedding_function = ... qdrant = Qdrant(client, collection_name, embedding_function) ``` -------------------------------- ### Initialize Qdrant from Documents Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Creates a Qdrant vector store instance initialized with a list of Document objects and an embedding function. This is useful for populating a new Qdrant collection. ```python _classmethod _from_documents( _documents : list[Document]_, _embedding : Embeddings_, _** kwargs: Any_, ) → Self# ``` -------------------------------- ### Initialize Qdrant with Texts (Async) Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Initializes the Qdrant database with provided texts and embeddings. It can create embeddings for each text and add them to an in-memory or remote Qdrant instance. The collection name can be specified or will be generated randomly. ```python from langchain_qdrant import Qdrant from langchain_openai import OpenAIEmbeddings # Assuming 'texts' is a list of strings # Assuming 'embeddings' is an initialized embedding model like OpenAIEmbeddings # Example of initializing Qdrant with texts and embeddings # qdrant = await Qdrant.afrom_texts(texts, embeddings, "localhost") ``` -------------------------------- ### FastEmbedSparse Initialization Source: https://python.langchain.com/api_reference/qdrant/fastembed_sparse/langchain_qdrant.fastembed_sparse Initializes the FastEmbedSparse class for sparse text embeddings using FastEmbed. You can specify the model name, batch size, cache directory, and other ONNX runtime options. ```APIDOC ## FastEmbedSparse ### Description Sparse encoder implementation using FastEmbed. Uses FastEmbed for sparse text embeddings. For a list of available models, see the Qdrant docs. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "model_name": "Qdrant/bm25", "batch_size": 256, "cache_dir": null, "threads": null, "providers": null, "parallel": null } ``` ### Response #### Success Response (200) None #### Response Example None ### Raises **ValueError** – If the model_name is not supported in SparseTextEmbedding. ``` -------------------------------- ### Initialize Qdrant with Text Embeddings Source: https://python.langchain.com/api_reference/qdrant/vectorstores/langchain_qdrant.vectorstores Creates a Qdrant instance from a list of texts, generating embeddings using a specified embedding model and configuring the Qdrant connection. It defaults to an in-memory store but can be configured for remote connections. ```python from langchain_qdrant import Qdrant from langchain_openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_texts(texts, embeddings, "localhost") ```