Repository: langchain
Issue: Upgraded to v0.3. Encountering Exception: RunnableSequence' object has no attribute 'get' when instatiating ReduceDocumentsChain
Labels: 🤖:bug,investigate,Ɑ:  core

### Discussed in https://github.com/langchain-ai/langchain/discussions/26785

<div type='discussions-op-text'>

<sup>Originally posted by **dubbl-d** September 23, 2024</sup>
### Checked other resources

- [X] I added a very descriptive title to this question.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Commit to Help

- [X] I commit to help with one of those options 👆

### Example Code

```python
python         reduce_prompt = PromptTemplate.from_template(template=topic_summary_reduce_prompt,
                                                     partial_variables={
                                                         "format_instructions": transcript_summary_parser.get_format_instructions()})

        combine_documents_chain = create_stuff_documents_chain(self.llm, reduce_prompt,
                                                               document_variable_name="topic_summaries")
        reduce_documents_chain = ReduceDocumentsChain(combine_documents_chain=combine_documents_chain,
                                                      collapse_documents_chain=combine_documents_chain,
                                                      token_max=4000, verbose=True
                                                      )
```


### Description

I am trying to get rid of deprecation warnings and one of the things I have to do is replace the StuffDocumentsChain with the preferred `create_stuff_documents_chain(...)` method. In the code above, I am getting an exception in pydantic validation code that is looking for a `get` attribute on the `RunnableSequence` object. I have checked with the 0.3 langchain docs to make sure my dependencies are correct and I don't reference any Pydantic v1 objects anywhere. This exception happens in the `ReduceDocumentsChain` constructor/__init__ method when it calls pydantic to validate attributes. It isn't clear where or why it is looking to validate a `get` attribute.

My dependencies and system info are in the section below. Here is the stack trace that I am getting from LangSmith traces:

 AttributeError("'RunnableSequence' object has no attribute 'get'") Traceback (most recent call last): File "/Users/dubbled/eng/inference/llm/llm_inferences.py", line 108, in infer_transcript_topic_summary reduce_documents_chain = ReduceDocumentsChain(combine_documents_chain=combine_documents_chain, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dubbled/.pyenv/versions/3.11.7/lib/python3.11/site-packages/langchain_core/load/serializable.py", line 112, in __init__ super().__init__(*args, **kwargs) File "/Users/dubbled/.pyenv/versions/3.11.7/lib/python3.11/site-packages/pydantic/main.py", line 212, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dubbled/.pyenv/versions/3.11.7/lib/python3.11/site-packages/langchain/chains/base.py", line 236, in raise_callback_manager_deprecation if values.get("callback_manager") is not None: ^^^^^^^^^^ File "/Users/dubbled/.pyenv/versions/3.11.7/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 5704, in __getattr__ attr = getattr(self.bound, name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dubbled/.pyenv/versions/3.11.7/lib/python3.11/site-packages/pydantic/main.py", line 856, in __getattr__ raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') AttributeError: 'RunnableSequence' object has no attribute 'get'


### System Info

$ python -m langchain_core.sys_info

System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 23.1.0: Mon Oct  9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030
> Python Version:  3.11.7 (main, Jan 10 2024, 14:29:12) [Clang 15.0.0 (clang-1500.1.0.2.5)]

Package Information
-------------------
> langchain_core: 0.3.1
> langchain: 0.3.0
> langsmith: 0.1.122
> langchain_cli: 0.0.21
> langchain_openai: 0.2.0
> langchain_text_splitters: 0.3.0
> langchainhub: 0.1.14
> langserve: 0.0.41

Optional packages not installed
-------------------------------
> langgraph

Other Dependencies
------------------
> aiohttp: 3.9.2
> async-timeout: 4.0.3
> fastapi: 0.109.2
> gitpython: 3.1.43
> httpx: 0.26.0
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> langserve[all]: Installed. No version info available.
> numpy: 1.26.4
> openai: 1.46.0
> orjson: 3.9.14
> packaging: 23.2
> pydantic: 2.9.2
> PyYAML: 6.0.1
> requests: 2.32.3
> SQLAlchemy: 2.0.27
> sse-starlette: 1.8.2
> tenacity: 8.2.3
> tiktoken: 0.7.0
> tomlkit: 0.12.4
> typer[all]: Installed. No version info available.
> types-requests: 2.31.0.20240125
> typing-extensions: 4.12.2
> uvicorn: 0.23.2</div>