Configure particular Runnable fields at runtime.
The name of the Runnable. Used for debugging and tracing.
The type of input this Runnable accepts specified as a Pydantic model.
Output schema.
List configurable fields for this Runnable.
Get the name of the Runnable.
Get a Pydantic model that can be used to validate input to the Runnable.
Get a JSON schema that represents the input to the Runnable.
Get a Pydantic model that can be used to validate output to the Runnable.
| Name | Type | Description |
|---|---|---|
func | Callable[[Other], None] | Callable[[Other, RunnableConfig], None] | Callable[[Other], Awaitable[None]] | Callable[[Other, RunnableConfig], Awaitable[None]] | None | Default: None |
afunc | Callable[[Other], Awaitable[None]] | Callable[[Other, RunnableConfig], Awaitable[None]] | None | Default: None |
input_type | type[Other] | None | Default: None |
| Name | Type |
|---|---|
| func | Callable[[Other], None] | Callable[[Other, RunnableConfig], None] | Callable[[Other], Awaitable[None]] | Callable[[Other, RunnableConfig], Awaitable[None]] | None |
| afunc | Callable[[Other], Awaitable[None]] | Callable[[Other, RunnableConfig], Awaitable[None]] | None |
| input_type | type[Other] | None |
Runnable to passthrough inputs unchanged or with additional keys.
This Runnable behaves almost like the identity function, except that it
can be configured to add additional keys to the output, if the input is a
dict.
The examples below demonstrate this Runnable works using a few simple
chains. The chains rely on simple lambdas to make the examples easy to execute
and experiment with.
In some cases, it may be useful to pass the input through while adding some
keys to the output. In this case, you can use the assign method:
from langchain_core.runnables import RunnablePassthrough
def fake_llm(prompt: str) -> str: # Fake LLM for the example
return "completion"
runnable = {
"llm1": fake_llm,
"llm2": fake_llm,
} | RunnablePassthrough.assign(
total_chars=lambda inputs: len(inputs["llm1"] + inputs["llm2"])
)
runnable.invoke("hello")
# {'llm1': 'completion', 'llm2': 'completion', 'total_chars': 20}Get a JSON schema that represents the output of the Runnable.
Function to be called with the input.
Async function to be called with the input.
Type of the input.