Home / Function/ get_default_document_variable_name() — langchain Function Reference

get_default_document_variable_name() — langchain Function Reference

Architecture documentation for the get_default_document_variable_name() function in map_reduce.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  9b9cfc34_1b34_4690_de71_2de1276bdf0e["get_default_document_variable_name()"]
  a22a5836_e793_27ca_7ffe_21cb92057ad5["MapReduceDocumentsChain"]
  9b9cfc34_1b34_4690_de71_2de1276bdf0e -->|defined in| a22a5836_e793_27ca_7ffe_21cb92057ad5
  style 9b9cfc34_1b34_4690_de71_2de1276bdf0e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/combine_documents/map_reduce.py lines 174–196

    def get_default_document_variable_name(cls, values: dict) -> Any:
        """Get default document variable name, if not provided."""
        if "llm_chain" not in values:
            msg = "llm_chain must be provided"
            raise ValueError(msg)

        llm_chain_variables = values["llm_chain"].prompt.input_variables
        if "document_variable_name" not in values:
            if len(llm_chain_variables) == 1:
                values["document_variable_name"] = llm_chain_variables[0]
            else:
                msg = (
                    "document_variable_name must be provided if there are "
                    "multiple llm_chain input_variables"
                )
                raise ValueError(msg)
        elif values["document_variable_name"] not in llm_chain_variables:
            msg = (
                f"document_variable_name {values['document_variable_name']} was "
                f"not found in llm_chain input_variables: {llm_chain_variables}"
            )
            raise ValueError(msg)
        return values

Subdomains

Frequently Asked Questions

What does get_default_document_variable_name() do?
get_default_document_variable_name() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/combine_documents/map_reduce.py.
Where is get_default_document_variable_name() defined?
get_default_document_variable_name() is defined in libs/langchain/langchain_classic/chains/combine_documents/map_reduce.py at line 174.

Analyze Your Own Codebase

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

Try Supermodel Free