Home / Function/ __query_collection() — langchain Function Reference

__query_collection() — langchain Function Reference

Architecture documentation for the __query_collection() function in vectorstores.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  180f6c1b_bb48_bf57_69cd_8e866f8993df["__query_collection()"]
  d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"]
  180f6c1b_bb48_bf57_69cd_8e866f8993df -->|defined in| d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab
  style 180f6c1b_bb48_bf57_69cd_8e866f8993df fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/chroma/langchain_chroma/vectorstores.py lines 450–484

    def __query_collection(
        self,
        query_texts: list[str] | None = None,
        query_embeddings: list[list[float]] | None = None,
        n_results: int = 4,
        where: dict[str, str] | None = None,
        where_document: dict[str, str] | None = None,
        **kwargs: Any,
    ) -> list[Document] | chromadb.QueryResult:
        """Query the chroma collection.

        Args:
            query_texts: List of query texts.
            query_embeddings: List of query embeddings.
            n_results: Number of results to return.
            where: dict used to filter results by metadata.
                    E.g. {"color" : "red"}.
            where_document: dict used to filter by the document contents.
                    E.g. {"$contains": "hello"}.
            kwargs: Additional keyword arguments to pass to Chroma collection query.

        Returns:
            List of `n_results` nearest neighbor embeddings for provided
            query_embeddings or query_texts.

        See more: https://docs.trychroma.com/reference/py-collection#query
        """
        return self._collection.query(
            query_texts=query_texts,
            query_embeddings=query_embeddings,  # type: ignore[arg-type]
            n_results=n_results,
            where=where,  # type: ignore[arg-type]
            where_document=where_document,  # type: ignore[arg-type]
            **kwargs,
        )

Subdomains

Frequently Asked Questions

What does __query_collection() do?
__query_collection() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is __query_collection() defined?
__query_collection() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 450.

Analyze Your Own Codebase

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

Try Supermodel Free