Home / Function/ _do_retrieval() — langchain Function Reference

_do_retrieval() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  275efbc2_764c_f1ab_5418_e3b25379ab50["_do_retrieval()"]
  c827daf0_9d8e_4865_a678_af8144586d0e["FlareChain"]
  275efbc2_764c_f1ab_5418_e3b25379ab50 -->|defined in| c827daf0_9d8e_4865_a678_af8144586d0e
  193d32b1_2740_febf_5c97_eebfa1726864["_call()"]
  193d32b1_2740_febf_5c97_eebfa1726864 -->|calls| 275efbc2_764c_f1ab_5418_e3b25379ab50
  00bfeba3_6a6a_fdf0_f606_e42b68be827d["_do_generation()"]
  275efbc2_764c_f1ab_5418_e3b25379ab50 -->|calls| 00bfeba3_6a6a_fdf0_f606_e42b68be827d
  style 275efbc2_764c_f1ab_5418_e3b25379ab50 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/flare/base.py lines 160–196

    def _do_retrieval(
        self,
        low_confidence_spans: list[str],
        _run_manager: CallbackManagerForChainRun,
        user_input: str,
        response: str,
        initial_response: str,
    ) -> tuple[str, bool]:
        question_gen_inputs = [
            {
                "user_input": user_input,
                "current_response": initial_response,
                "uncertain_span": span,
            }
            for span in low_confidence_spans
        ]
        callbacks = _run_manager.get_child()
        if isinstance(self.question_generator_chain, LLMChain):
            question_gen_outputs = self.question_generator_chain.apply(
                question_gen_inputs,
                callbacks=callbacks,
            )
            questions = [
                output[self.question_generator_chain.output_keys[0]]
                for output in question_gen_outputs
            ]
        else:
            questions = self.question_generator_chain.batch(
                question_gen_inputs,
                config={"callbacks": callbacks},
            )
        _run_manager.on_text(
            f"Generated Questions: {questions}",
            color="yellow",
            end="\n",
        )
        return self._do_generation(questions, user_input, response, _run_manager)

Subdomains

Called By

Frequently Asked Questions

What does _do_retrieval() do?
_do_retrieval() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/flare/base.py.
Where is _do_retrieval() defined?
_do_retrieval() is defined in libs/langchain/langchain_classic/chains/flare/base.py at line 160.
What does _do_retrieval() call?
_do_retrieval() calls 1 function(s): _do_generation.
What calls _do_retrieval()?
_do_retrieval() is called by 1 function(s): _call.

Analyze Your Own Codebase

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

Try Supermodel Free