Home / Function/ _acall() — langchain Function Reference

_acall() — langchain Function Reference

Architecture documentation for the _acall() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4fd54b1e_8669_046f_0b16_546d9b49f766["_acall()"]
  1cb458d9_f8c6_d78d_c1e3_79a8b3106c08["BaseRetrievalQA"]
  4fd54b1e_8669_046f_0b16_546d9b49f766 -->|defined in| 1cb458d9_f8c6_d78d_c1e3_79a8b3106c08
  08db5c6e_396d_588e_3be8_0331b0e2994a["_aget_docs()"]
  4fd54b1e_8669_046f_0b16_546d9b49f766 -->|calls| 08db5c6e_396d_588e_3be8_0331b0e2994a
  8912697d_f7bb_3415_ef27_42f5e5025460["_aget_docs()"]
  4fd54b1e_8669_046f_0b16_546d9b49f766 -->|calls| 8912697d_f7bb_3415_ef27_42f5e5025460
  style 4fd54b1e_8669_046f_0b16_546d9b49f766 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/retrieval_qa/base.py lines 173–206

    async def _acall(
        self,
        inputs: dict[str, Any],
        run_manager: AsyncCallbackManagerForChainRun | None = None,
    ) -> dict[str, Any]:
        """Run get_relevant_text and llm on input query.

        If chain has 'return_source_documents' as 'True', returns
        the retrieved documents as well under the key 'source_documents'.

        Example:
        ```python
        res = indexqa({"query": "This is my query"})
        answer, docs = res["result"], res["source_documents"]
        ```
        """
        _run_manager = run_manager or AsyncCallbackManagerForChainRun.get_noop_manager()
        question = inputs[self.input_key]
        accepts_run_manager = (
            "run_manager" in inspect.signature(self._aget_docs).parameters
        )
        if accepts_run_manager:
            docs = await self._aget_docs(question, run_manager=_run_manager)
        else:
            docs = await self._aget_docs(question)  # type: ignore[call-arg]
        answer = await self.combine_documents_chain.arun(
            input_documents=docs,
            question=question,
            callbacks=_run_manager.get_child(),
        )

        if self.return_source_documents:
            return {self.output_key: answer, "source_documents": docs}
        return {self.output_key: answer}

Subdomains

Frequently Asked Questions

What does _acall() do?
_acall() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/retrieval_qa/base.py.
Where is _acall() defined?
_acall() is defined in libs/langchain/langchain_classic/chains/retrieval_qa/base.py at line 173.
What does _acall() call?
_acall() calls 2 function(s): _aget_docs, _aget_docs.

Analyze Your Own Codebase

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

Try Supermodel Free