Home / Function/ _call() — langchain Function Reference

_call() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6e6f6256_b657_b069_4feb_e1aba5c970b7["_call()"]
  be2fab99_c17a_7327_31b8_3526c30ba2b8["BaseConversationalRetrievalChain"]
  6e6f6256_b657_b069_4feb_e1aba5c970b7 -->|defined in| be2fab99_c17a_7327_31b8_3526c30ba2b8
  cc60c9e9_1c90_5c4d_901c_b053eae628ef["_get_docs()"]
  6e6f6256_b657_b069_4feb_e1aba5c970b7 -->|calls| cc60c9e9_1c90_5c4d_901c_b053eae628ef
  8e932862_cc2c_8a91_ae17_87d023efcca7["_get_docs()"]
  6e6f6256_b657_b069_4feb_e1aba5c970b7 -->|calls| 8e932862_cc2c_8a91_ae17_87d023efcca7
  style 6e6f6256_b657_b069_4feb_e1aba5c970b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/conversational_retrieval/base.py lines 143–188

    def _call(
        self,
        inputs: dict[str, Any],
        run_manager: CallbackManagerForChainRun | None = None,
    ) -> dict[str, Any]:
        _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
        question = inputs["question"]
        get_chat_history = self.get_chat_history or _get_chat_history
        chat_history_str = get_chat_history(inputs["chat_history"])

        if chat_history_str:
            callbacks = _run_manager.get_child()
            new_question = self.question_generator.run(
                question=question,
                chat_history=chat_history_str,
                callbacks=callbacks,
            )
        else:
            new_question = question
        accepts_run_manager = (
            "run_manager" in inspect.signature(self._get_docs).parameters
        )
        if accepts_run_manager:
            docs = self._get_docs(new_question, inputs, run_manager=_run_manager)
        else:
            docs = self._get_docs(new_question, inputs)  # type: ignore[call-arg]
        output: dict[str, Any] = {}
        if self.response_if_no_docs_found is not None and len(docs) == 0:
            output[self.output_key] = self.response_if_no_docs_found
        else:
            new_inputs = inputs.copy()
            if self.rephrase_question:
                new_inputs["question"] = new_question
            new_inputs["chat_history"] = chat_history_str
            answer = self.combine_docs_chain.run(
                input_documents=docs,
                callbacks=_run_manager.get_child(),
                **new_inputs,
            )
            output[self.output_key] = answer

        if self.return_source_documents:
            output["source_documents"] = docs
        if self.return_generated_question:
            output["generated_question"] = new_question
        return output

Subdomains

Frequently Asked Questions

What does _call() do?
_call() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/conversational_retrieval/base.py.
Where is _call() defined?
_call() is defined in libs/langchain/langchain_classic/chains/conversational_retrieval/base.py at line 143.
What does _call() call?
_call() calls 2 function(s): _get_docs, _get_docs.

Analyze Your Own Codebase

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

Try Supermodel Free