Home / Function/ from_texts() — langchain Function Reference

from_texts() — langchain Function Reference

Architecture documentation for the from_texts() function in qdrant.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  88421693_b7b6_8b4b_b6ab_bf2897b37dfe["from_texts()"]
  671b47a0_cdd3_a89d_e90f_0631a4bd67d3["QdrantVectorStore"]
  88421693_b7b6_8b4b_b6ab_bf2897b37dfe -->|defined in| 671b47a0_cdd3_a89d_e90f_0631a4bd67d3
  0eee8f8f_565a_e169_7071_de903da2cbd3["construct_instance()"]
  88421693_b7b6_8b4b_b6ab_bf2897b37dfe -->|calls| 0eee8f8f_565a_e169_7071_de903da2cbd3
  c81b5f54_4d7b_ff69_0cd1_397bf595fdc2["add_texts()"]
  88421693_b7b6_8b4b_b6ab_bf2897b37dfe -->|calls| c81b5f54_4d7b_ff69_0cd1_397bf595fdc2
  style 88421693_b7b6_8b4b_b6ab_bf2897b37dfe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/qdrant/langchain_qdrant/qdrant.py lines 339–431

    def from_texts(
        cls: type[QdrantVectorStore],
        texts: list[str],
        embedding: Embeddings | None = None,
        metadatas: list[dict] | None = None,
        ids: Sequence[str | int] | 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,  # noqa: FBT001, FBT002
        https: bool | None = None,  # noqa: FBT001
        api_key: str | None = None,
        prefix: str | None = None,
        timeout: int | None = None,
        host: str | None = None,
        path: str | None = None,
        distance: models.Distance = models.Distance.COSINE,
        content_payload_key: str = CONTENT_KEY,
        metadata_payload_key: str = METADATA_KEY,
        vector_name: str = VECTOR_NAME,
        retrieval_mode: RetrievalMode = RetrievalMode.DENSE,
        sparse_embedding: SparseEmbeddings | None = None,
        sparse_vector_name: str = SPARSE_VECTOR_NAME,
        collection_create_options: dict[str, Any] | None = None,
        vector_params: dict[str, Any] | None = None,
        sparse_vector_params: dict[str, Any] | None = None,
        batch_size: int = 64,
        force_recreate: bool = False,  # noqa: FBT001, FBT002
        validate_embeddings: bool = True,  # noqa: FBT001, FBT002
        validate_collection_config: bool = True,  # noqa: FBT001, FBT002
        **kwargs: Any,
    ) -> QdrantVectorStore:
        """Construct an instance of `QdrantVectorStore` from a list of texts.

        This is a user-friendly interface that:

        1. Creates embeddings, one for each text
        2. Creates a Qdrant collection if it doesn't exist.
        3. Adds the text embeddings to the Qdrant database

        This is intended to be a quick way to get started.

        ```python
        from langchain_qdrant import Qdrant
        from langchain_openai import OpenAIEmbeddings

        embeddings = OpenAIEmbeddings()
        qdrant = Qdrant.from_texts(texts, embeddings, url="http://localhost:6333")
        ```
        """
        if sparse_vector_params is None:
            sparse_vector_params = {}
        if vector_params is None:
            vector_params = {}
        if collection_create_options is None:
            collection_create_options = {}
        client_options = {
            "location": location,
            "url": url,
            "port": port,
            "grpc_port": grpc_port,
            "prefer_grpc": prefer_grpc,
            "https": https,
            "api_key": api_key,
            "prefix": prefix,
            "timeout": timeout,
            "host": host,
            "path": path,
            **kwargs,
        }

        qdrant = cls.construct_instance(
            embedding,
            retrieval_mode,
            sparse_embedding,
            client_options,
            collection_name,
            distance,
            content_payload_key,

Domain

Subdomains

Frequently Asked Questions

What does from_texts() do?
from_texts() is a function in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/qdrant.py.
Where is from_texts() defined?
from_texts() is defined in libs/partners/qdrant/langchain_qdrant/qdrant.py at line 339.
What does from_texts() call?
from_texts() calls 2 function(s): add_texts, construct_instance.

Analyze Your Own Codebase

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

Try Supermodel Free