bind() — langchain Function Reference
Architecture documentation for the bind() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 00bd9223_b529_b9b6_8840_dfaa74cdb507["bind()"] 4a62481c_02cb_a5de_1833_50669d5351a6["Runnable"] 00bd9223_b529_b9b6_8840_dfaa74cdb507 -->|defined in| 4a62481c_02cb_a5de_1833_50669d5351a6 b259cdaa_baff_74d1_86dc_2d7da84c4711["bind()"] b259cdaa_baff_74d1_86dc_2d7da84c4711 -->|calls| 00bd9223_b529_b9b6_8840_dfaa74cdb507 65d78490_cc2d_e086_e4c4_bcee7b7af69f["bind()"] 65d78490_cc2d_e086_e4c4_bcee7b7af69f -->|calls| 00bd9223_b529_b9b6_8840_dfaa74cdb507 b259cdaa_baff_74d1_86dc_2d7da84c4711["bind()"] 00bd9223_b529_b9b6_8840_dfaa74cdb507 -->|calls| b259cdaa_baff_74d1_86dc_2d7da84c4711 style 00bd9223_b529_b9b6_8840_dfaa74cdb507 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/base.py lines 1610–1642
def bind(self, **kwargs: Any) -> Runnable[Input, Output]:
"""Bind arguments to a `Runnable`, returning a new `Runnable`.
Useful when a `Runnable` in a chain requires an argument that is not
in the output of the previous `Runnable` or included in the user input.
Args:
**kwargs: The arguments to bind to the `Runnable`.
Returns:
A new `Runnable` with the arguments bound.
Example:
```python
from langchain_ollama import ChatOllama
from langchain_core.output_parsers import StrOutputParser
model = ChatOllama(model="llama3.1")
# Without bind
chain = model | StrOutputParser()
chain.invoke("Repeat quoted words exactly: 'One two three four five.'")
# Output is 'One two three four five.'
# With bind
chain = model.bind(stop=["three"]) | StrOutputParser()
chain.invoke("Repeat quoted words exactly: 'One two three four five.'")
# Output is 'One two'
```
"""
return RunnableBinding(bound=self, kwargs=kwargs, config={})
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does bind() do?
bind() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is bind() defined?
bind() is defined in libs/core/langchain_core/runnables/base.py at line 1610.
What does bind() call?
bind() calls 1 function(s): bind.
What calls bind()?
bind() is called by 2 function(s): bind, bind.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free