LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    Standard Tests
    Text Splitters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    โŒ˜I

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    MCP Adapters
    Standard Tests
    Text Splitters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Language
    Theme
    Pythonlangchain-classicchainscombine_documentsstuffStuffDocumentsChainprompt_length
    Methodโ—Since v1.5

    prompt_length

    Copy
    prompt_length(
      self,
      docs: list[Document],
      kwargs: Any = {}
    ) ->
    View source on GitHub
    int
    |
    None

    Parameters

    NameTypeDescription
    docs*list[Document]
    **kwargsAny
    Default:{}

    Return the prompt length given the documents passed in.

    This can be used by a caller to determine whether passing in a list of documents would exceed a certain prompt length. This useful when trying to ensure that the size of a prompt remains below a certain context limit.

    a list of documents to use to calculate the total prompt length.

    additional parameters to use to get inputs to LLMChain.