# Alternatively, can provide both synd and sync implementations
async def add_one_async(x: int) -> int:
    return x + 1
runnable = RunnableLambda(add_one, afunc=add_one_async)
runnable.invoke(1) # Uses add_one
await runnable.ainvoke(1) # Uses add_one_async
Create a RunnableLambda from a callable, and async callable or both.
Accepts both sync and async variants to allow providing efficient
implementations for sync and async execution.
Parameters
func – Either sync or async callable
afunc – An async callable that takes an input and returns an output.
Attributes
InputType
The type of the input to this runnable.
OutputType
The type of the output of this runnable as a type annotation.
config_specs
List configurable fields for this runnable.
input_schema
The type of input this runnable accepts specified as a pydantic model.
output_schema
The type of output this runnable produces specified as a pydantic model.
Methods
__init__(func[, afunc])
Create a RunnableLambda from a callable, and async callable or both.
abatch(inputs[, config, return_exceptions])
Default implementation runs ainvoke in parallel using asyncio.gather.
ainvoke(input[, config])
Invoke this runnable asynchronously.
astream(input[, config])
Default implementation of astream, which calls ainvoke.
astream_log(input[, config, diff, ...])
Stream all output from a runnable, as reported to the callback system.
atransform(input[, config])
Default implementation of atransform, which buffers input and calls astream.
batch(inputs[, config, return_exceptions])
Default implementation runs invoke in parallel using a thread pool executor.
bind(**kwargs)
Bind arguments to a Runnable, returning a new Runnable.