langchain_core.runnables.configurable.RunnableConfigurableAlternatives¶
class langchain_core.runnables.configurable.RunnableConfigurableAlternatives[source]¶
Bases: DynamicRunnable[Input, Output]
A Runnable that can be dynamically configured.
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 alternatives: Dict[str, Union[langchain_core.runnables.base.Runnable[langchain_core.runnables.utils.Input, langchain_core.runnables.utils.Output], Callable[[], langchain_core.runnables.base.Runnable[langchain_core.runnables.utils.Input, langchain_core.runnables.utils.Output]]]] [Required]¶
param default: langchain_core.runnables.base.RunnableSerializable[langchain_core.runnables.utils.Input, langchain_core.runnables.utils.Output] [Required]¶
param default_key: str = 'default'¶
The enum value to use for the default option. Defaults to “default”.
param prefix_keys: bool [Required]¶
Whether to prefix configurable fields of each alternative with a namespace
of the form <which.id>==<alternative_key>, eg. a key named “temperature” used by
the alternative named “gpt3” becomes “model==gpt3/temperature”.
param which: langchain_core.runnables.utils.ConfigurableField [Required]¶
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
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;