id
stringlengths
14
15
text
stringlengths
13
2.7k
source
stringlengths
60
181
bdf30e7ea3ae-0
langchain_core.runnables.fallbacks.RunnableWithFallbacks¶ class langchain_core.runnables.fallbacks.RunnableWithFallbacks[source]¶ Bases: RunnableSerializable[Input, Output] A Runnable that can fallback to other Runnables if it fails. External APIs (e.g., APIs for a language model) may at times experience degraded perfo...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-1
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 exc...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-2
the runnable did not implement a native async version of invoke. Subclasses should override this method if they can run asynchronously. async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of astream, which calls ainvoke. Subclasse...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-3
exclude_names – Exclude logs with these names. exclude_types – Exclude logs with these types. exclude_tags – Exclude logs with these tags. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-4
configurable_fields(**kwargs: Union[ConfigurableField, ConfigurableFieldSingleOption, ConfigurableFieldMultiOption]) → RunnableSerializable[Input, Output]¶ classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-vali...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-5
classmethod from_orm(obj: Any) → Model¶ get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel][source]¶ Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic input schema tha...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-6
for more details. Returns The output of the runnable. classmethod is_lc_serializable() → bool[source]¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Op...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-7
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-8
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
bdf30e7ea3ae-9
property OutputType: Type[langchain_core.runnables.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.fallbacks.RunnableWithFallbacks.html
4bd768cffe19-0
langchain_core.runnables.utils.accepts_config¶ langchain_core.runnables.utils.accepts_config(callable: Callable[[...], Any]) → bool[source]¶ Check if a callable accepts a config argument.
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.utils.accepts_config.html
d25d44836553-0
langchain_core.runnables.utils.add¶ langchain_core.runnables.utils.add(addables: Iterable[Addable]) → Optional[Addable][source]¶ Add a sequence of addable objects together.
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.utils.add.html
b9c47dc515ec-0
langchain_core.runnables.utils.indent_lines_after_first¶ langchain_core.runnables.utils.indent_lines_after_first(text: str, prefix: str) → str[source]¶ Indent all lines of text after the first line. Parameters text – The text to indent prefix – Used to determine the number of spaces to indent Returns The indented text ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.utils.indent_lines_after_first.html
ebfdca70560d-0
langchain_core.runnables.base.RunnableSequence¶ class langchain_core.runnables.base.RunnableSequence[source]¶ Bases: RunnableSerializable[Input, Output] A sequence of runnables, where the output of each is the input of the next. RunnableSequence is the most important composition operator in LangChain as it is used in v...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-1
def add_one(x: int) -> int: return x + 1 def mul_two(x: int) -> int: return x * 2 runnable_1 = RunnableLambda(add_one) runnable_2 = RunnableLambda(mul_two) sequence = runnable_1 | runnable_2 # Or equivalently: # sequence = RunnableSequence(first=runnable_1, last=runnable_2) sequence.invoke(1) await runnable.ain...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-2
The last runnable in the sequence. param middle: List[langchain_core.runnables.base.Runnable[Any, Any]] [Optional]¶ The middle runnables in the sequence. async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) →...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-3
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-4
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-5
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-6
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str][source]¶ Get the namespace of the langchain object. get_output_schema(config: Op...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-7
classmethod is_lc_serializable() → bool[source]¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, excl...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-8
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output][source]¶ Default implementation of stream, which calls invoke. Subclasses should ov...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-9
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
ebfdca70560d-10
property OutputType: Type[langchain_core.runnables.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSequence.html
3a3582a1ea80-0
langchain_core.runnables.config.get_executor_for_config¶ langchain_core.runnables.config.get_executor_for_config(config: RunnableConfig) → Generator[Executor, None, None][source]¶ Get an executor for a config. Parameters config (RunnableConfig) – The config. Yields Generator[Executor, None, None] – The executor.
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.config.get_executor_for_config.html
8f0f33513b2a-0
langchain_core.runnables.utils.aadd¶ async langchain_core.runnables.utils.aadd(addables: AsyncIterable[Addable]) → Optional[Addable][source]¶ Asynchronously add a sequence of addable objects together.
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.utils.aadd.html
edcc3e7e7580-0
langchain_core.runnables.router.RouterRunnable¶ class langchain_core.runnables.router.RouterRunnable[source]¶ Bases: RunnableSerializable[RouterInput, Output] A runnable that routes to a set of runnables based on Input[‘key’]. Returns the output of the selected runnable. Create a new model by parsing and validating inp...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-1
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-2
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[RouterInput], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool =...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-3
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-4
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str][source]¶ Get the namespace of the langchain object. get_output_schema(config: Op...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-5
Return whether this class is serializable. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclud...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-6
stream(input: RouterInput, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output][source]¶ Default implementation of stream, which calls invoke. Subclasses should override this method if they support streaming output. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_j...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-7
Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run object. on_end: Called after the runnable finishes running, with the Run object. on_error: Called if the runnable throws an error, with the Run object. The Run object contains information ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
edcc3e7e7580-8
property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic model. property lc_attributes: Dict¶ List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_secrets: Dict[str, str]¶ ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.router.RouterRunnable.html
1a68c05bee38-0
langchain_core.runnables.base.coerce_to_runnable¶ langchain_core.runnables.base.coerce_to_runnable(thing: Union[Runnable[Input, Output], Callable[[Input], Output], Callable[[Input], Awaitable[Output]], Callable[[Iterator[Input]], Iterator[Output]], Callable[[AsyncIterator[Input]], AsyncIterator[Output]], Mapping[str, A...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.coerce_to_runnable.html
d2e3badedc93-0
langchain_core.runnables.base.RunnableMap¶ langchain_core.runnables.base.RunnableMap¶ alias of RunnableParallel Examples using RunnableMap¶ OpaquePrompts interface.md First we add a step to load memory sql_db.md prompt_llm_parser.md Adding memory multiple_chains.md
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableMap.html
99937b6ff2bb-0
langchain_core.runnables.base.RunnableSerializable¶ class langchain_core.runnables.base.RunnableSerializable[source]¶ Bases: Serializable, Runnable[Input, Output] A Runnable that can be serialized to JSON. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the inpu...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-1
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-2
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-3
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-4
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str]¶ Get the namespace of the langchain object. For example, if the class is langcha...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-5
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-6
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-7
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
99937b6ff2bb-8
property OutputType: Type[langchain_core.runnables.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableSerializable.html
98291acd3b4f-0
langchain_core.runnables.base.RunnableEachBase¶ class langchain_core.runnables.base.RunnableEachBase[source]¶ Bases: RunnableSerializable[List[Input], List[Output]] A runnable that delegates calls to another runnable with each element of the input sequence. Use only if creating a new RunnableEach subclass with differen...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-1
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-2
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-3
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-4
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str][source]¶ Get the namespace of the langchain object. get_output_schema(config: Op...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-5
classmethod is_lc_serializable() → bool[source]¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, excl...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-6
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-7
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
98291acd3b4f-8
The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic m...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableEachBase.html
da074f00d588-0
langchain_core.runnables.configurable.StrEnum¶ class langchain_core.runnables.configurable.StrEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ A string enum.
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.configurable.StrEnum.html
3379796dfd63-0
langchain_core.runnables.utils.SupportsAdd¶ class langchain_core.runnables.utils.SupportsAdd(*args, **kwargs)[source]¶ Protocol for objects that support addition. Methods __init__(*args, **kwargs) __init__(*args, **kwargs)¶
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.utils.SupportsAdd.html
06aaf36ca4d0-0
langchain.runnables.openai_functions.OpenAIFunctionsRouter¶ class langchain.runnables.openai_functions.OpenAIFunctionsRouter[source]¶ Bases: RunnableBindingBase[BaseMessage, Any] A runnable that routes to the selected function. Create a RunnableBinding from a runnable and kwargs. Parameters bound – The underlying runna...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-1
param kwargs: Mapping[str, Any] [Optional]¶ kwargs to pass to the underlying runnable when running. For example, when the runnable binding is invoked the underlying runnable will be invoked with the same input but with these additional kwargs. async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, Lis...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-2
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-3
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-4
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-5
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str]¶ Get the namespace of the langchain object. get_output_schema(config: Optional[R...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-6
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-7
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-8
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
06aaf36ca4d0-9
property OutputType: Type[langchain_core.runnables.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶...
https://api.python.langchain.com/en/latest/runnables/langchain.runnables.openai_functions.OpenAIFunctionsRouter.html
f15ebc69a7b6-0
langchain_core.runnables.retry.RunnableRetry¶ class langchain_core.runnables.retry.RunnableRetry[source]¶ Bases: RunnableBindingBase[Input, Output] Retry a Runnable if it fails. A RunnableRetry helps can be used to add retry logic to any object that subclasses the base Runnable. Such retries are especially useful for n...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-1
from langchain_core.prompts import PromptTemplate template = PromptTemplate.from_template("tell me a joke about {topic}.") model = ChatOpenAI(temperature=0.5) # Good chain = template | model.with_retry() # Bad chain = template | model retryable_chain = chain.with_retry() Create a RunnableBinding from a runnable and kwa...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-2
param kwargs: Mapping[str, Any] [Optional]¶ kwargs to pass to the underlying runnable when running. For example, when the runnable binding is invoked the underlying runnable will be invoked with the same input but with these additional kwargs. param max_attempt_number: int = 3¶ The maximum number of attempts to retry t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-3
Subclasses should override this method if they can run asynchronously. async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. a...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-4
exclude_types – Exclude logs with these types. exclude_tags – Exclude logs with these tags. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Any) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subclasses should overri...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-5
configurable_fields(**kwargs: Union[ConfigurableField, ConfigurableFieldSingleOption, ConfigurableFieldMultiOption]) → RunnableSerializable[Input, Output]¶ classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-vali...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-6
classmethod from_orm(obj: Any) → Model¶ get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic input schema that depend...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-7
Returns The output of the runnable. classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclu...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-8
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-9
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
f15ebc69a7b6-10
property OutputType: Type[langchain_core.runnables.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html
07f8db321427-0
langchain_core.runnables.passthrough.aidentity¶ async langchain_core.runnables.passthrough.aidentity(x: Other) → Other[source]¶ An async identity function
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.passthrough.aidentity.html
2e0413a1e5a7-0
langchain_core.runnables.configurable.prefix_config_spec¶ langchain_core.runnables.configurable.prefix_config_spec(spec: ConfigurableFieldSpec, prefix: str) → ConfigurableFieldSpec[source]¶
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.configurable.prefix_config_spec.html
86d2bfff437f-0
langchain_core.runnables.base.RunnableBinding¶ class langchain_core.runnables.base.RunnableBinding[source]¶ Bases: RunnableBindingBase[Input, Output] Wrap a runnable with additional functionality. A RunnableBinding can be thought of as a “runnable decorator” that preserves the essential features of Runnable; i.e., batc...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-1
Can also be done by instantiating a RunnableBinding directly (not recommended): from langchain.schema.runnable import RunnableBinding runnable_binding = RunnableBinding( bound=model, kwargs={'stop': ['-']} # <-- Note the additional kwargs ) runnable_binding.invoke('Say "Parrot-MAGIC"') # Should return `Parrot` ...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-2
param custom_output_type: Optional[Any] = None¶ Override the output type of the underlying runnable with a custom type. The type can be a pydantic model, or a type annotation (e.g., List[str]). param kwargs: Mapping[str, Any] [Optional]¶ kwargs to pass to the underlying runnable when running. For example, when the runn...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-3
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Option...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-4
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-5
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-6
Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic input schema that depends on which configuration the runnable is invoked with. This method allows to get an input schema for a specific confi...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-7
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-8
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-9
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output][source]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. Parameters on_start – Called before the runnable starts ru...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
86d2bfff437f-10
property config_specs: List[langchain_core.runnables.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic model. property lc_attributes: Dict¶ List of attribute names that should be...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableBinding.html
18ce0abba772-0
langchain_core.runnables.base.RunnableLambda¶ class langchain_core.runnables.base.RunnableLambda(func: Union[Union[Callable[[Input], Output], Callable[[Input, RunnableConfig], Output], Callable[[Input, CallbackManagerForChainRun], Output], Callable[[Input, CallbackManagerForChainRun, RunnableConfig], Output]], Union[Ca...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-1
# 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...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-2
bind(**kwargs) Bind arguments to a Runnable, returning a new Runnable. config_schema(*[, include]) The type of config this runnable accepts specified as a pydantic model. get_input_schema([config]) The pydantic schema for the input to this runnable. get_output_schema([config]) Get a pydantic model that can be used to v...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-3
Bind input and output types to a Runnable, returning a new Runnable. __init__(func: Union[Union[Callable[[Input], Output], Callable[[Input, RunnableConfig], Output], Callable[[Input, CallbackManagerForChainRun], Output], Callable[[Input, CallbackManagerForChainRun, RunnableConfig], Output]], Union[Callable[[Input], Awa...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-4
Invoke this runnable asynchronously. async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. async astream_log(input: Any, confi...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-5
exclude_types – Exclude logs with these types. exclude_tags – Exclude logs with these tags. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subclasses sho...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-6
Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic output schema that depends on which configuration the runnable is invoked with. This method allows to get an output schema for a specific configuration. Parameters config – A config to use when generating the schem...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-7
Parameters fallbacks – A sequence of runnables to try if the original runnable fails. exceptions_to_handle – A tuple of exception types to handle. Returns A new Runnable that will try the original runnable, and then each fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Op...
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html
18ce0abba772-8
Examples using RunnableLambda¶ sql_db.md Run arbitrary functions
https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.base.RunnableLambda.html