Home / Function/ acombine_docs() — langchain Function Reference

acombine_docs() — langchain Function Reference

Architecture documentation for the acombine_docs() function in refine.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1["acombine_docs()"]
  d0a9b180_8f2a_0a58_5392_0a04880a6b38["RefineDocumentsChain"]
  b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1 -->|defined in| d0a9b180_8f2a_0a58_5392_0a04880a6b38
  37a82994_6ed9_4853_ba28_ec381055abd1["_construct_initial_inputs()"]
  b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1 -->|calls| 37a82994_6ed9_4853_ba28_ec381055abd1
  546e08a8_7a35_4f89_2107_54e2c8bffe5f["_construct_refine_inputs()"]
  b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1 -->|calls| 546e08a8_7a35_4f89_2107_54e2c8bffe5f
  04688adf_0639_ab43_5c3d_32ac51e84466["_construct_result()"]
  b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1 -->|calls| 04688adf_0639_ab43_5c3d_32ac51e84466
  style b8ccc423_c361_3ff8_e8ee_a7fc228a1cb1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/combine_documents/refine.py lines 173–199

    async def acombine_docs(
        self,
        docs: list[Document],
        callbacks: Callbacks = None,
        **kwargs: Any,
    ) -> tuple[str, dict]:
        """Combine by mapping a first chain over all, then stuffing into a final chain.

        Args:
            docs: List of documents to combine
            callbacks: Callbacks to be passed through
            **kwargs: additional parameters to be passed to LLM calls (like other
                input variables besides the documents)

        Returns:
            The first element returned is the single string output. The second
            element returned is a dictionary of other keys to return.
        """
        inputs = self._construct_initial_inputs(docs, **kwargs)
        res = await self.initial_llm_chain.apredict(callbacks=callbacks, **inputs)
        refine_steps = [res]
        for doc in docs[1:]:
            base_inputs = self._construct_refine_inputs(doc, res)
            inputs = {**base_inputs, **kwargs}
            res = await self.refine_llm_chain.apredict(callbacks=callbacks, **inputs)
            refine_steps.append(res)
        return self._construct_result(refine_steps, res)

Subdomains

Frequently Asked Questions

What does acombine_docs() do?
acombine_docs() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/combine_documents/refine.py.
Where is acombine_docs() defined?
acombine_docs() is defined in libs/langchain/langchain_classic/chains/combine_documents/refine.py at line 173.
What does acombine_docs() call?
acombine_docs() calls 3 function(s): _construct_initial_inputs, _construct_refine_inputs, _construct_result.

Analyze Your Own Codebase

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

Try Supermodel Free