Home / Function/ aquery() — langchain Function Reference

aquery() — langchain Function Reference

Architecture documentation for the aquery() function in vectorstore.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  991d81b1_2790_e8dc_f275_63ca3de5436b["aquery()"]
  25510f58_8b5d_fdd1_6cd7_3afc1a3d7a49["VectorStoreIndexWrapper"]
  991d81b1_2790_e8dc_f275_63ca3de5436b -->|defined in| 25510f58_8b5d_fdd1_6cd7_3afc1a3d7a49
  style 991d81b1_2790_e8dc_f275_63ca3de5436b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/indexes/vectorstore.py lines 69–102

    async def aquery(
        self,
        question: str,
        llm: BaseLanguageModel | None = None,
        retriever_kwargs: dict[str, Any] | None = None,
        **kwargs: Any,
    ) -> str:
        """Asynchronously query the `VectorStore` using the provided LLM.

        Args:
            question: The question or prompt to query.
            llm: The language model to use. Must not be `None`.
            retriever_kwargs: Optional keyword arguments for the retriever.
            **kwargs: Additional keyword arguments forwarded to the chain.

        Returns:
            The asynchronous result string from the RetrievalQA chain.
        """
        if llm is None:
            msg = (
                "This API has been changed to require an LLM. "
                "Please provide an llm to use for querying the vectorstore.\n"
                "For example,\n"
                "from langchain_openai import OpenAI\n"
                "model = OpenAI(temperature=0)"
            )
            raise NotImplementedError(msg)
        retriever_kwargs = retriever_kwargs or {}
        chain = RetrievalQA.from_chain_type(
            llm,
            retriever=self.vectorstore.as_retriever(**retriever_kwargs),
            **kwargs,
        )
        return (await chain.ainvoke({chain.input_key: question}))[chain.output_key]

Domain

Subdomains

Frequently Asked Questions

What does aquery() do?
aquery() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/indexes/vectorstore.py.
Where is aquery() defined?
aquery() is defined in libs/langchain/langchain_classic/indexes/vectorstore.py at line 69.

Analyze Your Own Codebase

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

Try Supermodel Free