PromptTemplate.from_template('Tell me a joke about {topic}')
    | model
    | StrOutputParser()
).with_fallbacks([RunnableLambda(when_all_is_lost)])
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,)¶
The exceptions on which fallbacks should be tried.
Any exception that is not a subclass of these exceptions will be raised immediately.
param fallbacks: Sequence[langchain_core.runnables.base.Runnable[langchain_core.runnables.utils.Input, langchain_core.runnables.utils.Output]] [Required]¶
A sequence of fallbacks to try.
param runnable: langchain_core.runnables.base.Runnable[langchain_core.runnables.utils.Input, langchain_core.runnables.utils.Output] [Required]¶
The runnable to run first.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output][source]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
async ainvoke(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Output[source]¶
Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not implement a native async version of invoke.