# StuffDocumentsChain

> **Class** in `langchain_classic`

📖 [View in docs](https://reference.langchain.com/python/langchain-classic/chains/combine_documents/stuff/StuffDocumentsChain)

Chain that combines documents by stuffing into context.

This chain takes a list of documents and first combines them into a single string.
It does this by formatting each document into a string with the `document_prompt`
and then joining them together with `document_separator`. It then adds that new
string to the inputs with the variable name set by `document_variable_name`.
Those inputs are then passed to the `llm_chain`.

## Signature

```python
StuffDocumentsChain()
```

## Description

**Example:**

```python
from langchain_classic.chains import StuffDocumentsChain, LLMChain
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI

# This controls how each document will be formatted. Specifically,
# it will be passed to `format_document` - see that function for more
# details.
document_prompt = PromptTemplate(
    input_variables=["page_content"], template="{page_content}"
)
document_variable_name = "context"
model = OpenAI()
# The prompt here should take as an input variable the
# `document_variable_name`
prompt = PromptTemplate.from_template("Summarize this content: {context}")
llm_chain = LLMChain(llm=model, prompt=prompt)
chain = StuffDocumentsChain(
    llm_chain=llm_chain,
    document_prompt=document_prompt,
    document_variable_name=document_variable_name,
)
```

## Extends

- `BaseCombineDocumentsChain`

## Properties

- `llm_chain`
- `document_prompt`
- `document_variable_name`
- `document_separator`
- `model_config`
- `input_keys`

## Methods

- [`get_default_document_variable_name()`](https://reference.langchain.com/python/langchain-classic/chains/combine_documents/stuff/StuffDocumentsChain/get_default_document_variable_name)
- [`prompt_length()`](https://reference.langchain.com/python/langchain-classic/chains/combine_documents/stuff/StuffDocumentsChain/prompt_length)
- [`combine_docs()`](https://reference.langchain.com/python/langchain-classic/chains/combine_documents/stuff/StuffDocumentsChain/combine_docs)
- [`acombine_docs()`](https://reference.langchain.com/python/langchain-classic/chains/combine_documents/stuff/StuffDocumentsChain/acombine_docs)

## ⚠️ Deprecated

Deprecated since version 0.2.13.

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/9f232caa7a8fe1ca042a401942d5d90d54ceb1a6/libs/langchain/langchain_classic/chains/combine_documents/stuff.py#L104)