id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
1752d97e2e1e-0
langchain.schema.callbacks.tracers.schemas.TracerSessionV1Create¶ class langchain.schema.callbacks.tracers.schemas.TracerSessionV1Create[source]¶ Bases: TracerSessionV1Base Create class for TracerSessionV1. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the inp...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionV1Create.html
1752d97e2e1e-1
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionV1Create.html
1752d97e2e1e-2
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionV1Create.html
f0289bc8ffaa-0
langchain.schema.callbacks.manager.CallbackManagerForChainRun¶ class langchain.schema.callbacks.manager.CallbackManagerForChainRun(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheritable_ta...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForChainRun.html
f0289bc8ffaa-1
on_retry(retry_state, **kwargs) Run on a retry event. on_text(text, **kwargs) Run when text is received. __init__(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheritable_tags: Optional[List...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForChainRun.html
f0289bc8ffaa-2
Parameters action (AgentAction) – The agent action. Returns The result of the callback. Return type Any on_agent_finish(finish: AgentFinish, **kwargs: Any) → Any[source]¶ Run when agent finish is received. Parameters finish (AgentFinish) – The agent finish. Returns The result of the callback. Return type Any on_chain_e...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForChainRun.html
e45dc5e40fe8-0
langchain.schema.runnable.base.RunnableParallel¶ class langchain.schema.runnable.base.RunnableParallel[source]¶ Bases: RunnableSerializable[Input, Dict[str, Any]] A runnable that runs a mapping of runnables in parallel, and returns a mapping of their outputs. Create a new model by parsing and validating input data from...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-1
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names:...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-2
e.g., if the underlying runnable uses an API which supports a batch mode. bind(**kwargs: Any) → Runnable[Input, Output]¶ Bind arguments to a Runnable, returning a new Runnable. config_schema(*, include: Optional[Sequence[str]] = None) → Type[BaseModel]¶ The type of config this runnable accepts specified as a pydantic m...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-3
exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep – set to True to make a deep copy of the model Returns new model instance dict(*, i...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-4
Get a pydantic model that can be used to validate output to the runnable. 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 co...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-5
classmethod lc_id() → List[str]¶ A unique identifier for this class for serialization purposes. The unique identifier is a list of strings that describes the path to the object. map() → Runnable[List[Input], List[Output]]¶ Return a new Runnable that maps a list of inputs to a list of outputs, by calling invoke() with e...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-6
input is still being generated. classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. classmethod validate(value: Any) → Model¶ with_config(config: Optional[RunnableConfig] = None, **kwargs: Any) → Runnable[Input, Output]¶ Bind config to a...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-7
added to the run. with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[Input, Output]¶ Create a new Runnable that retries the original runnable on exceptions. Parameters retry_if_exc...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
e45dc5e40fe8-8
property output_schema: Type[pydantic.main.BaseModel]¶ The type of output this runnable produces specified as a pydantic model.
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableParallel.html
b359b53f948e-0
langchain.schema.runnable.utils.gather_with_concurrency¶ async langchain.schema.runnable.utils.gather_with_concurrency(n: Optional[int], *coros: Coroutine) → list[source]¶ Gather coroutines with a limit on the number of concurrent coroutines.
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.utils.gather_with_concurrency.html
6c54e8ef2417-0
langchain.schema.runnable.utils.ConfigurableFieldSpec¶ class langchain.schema.runnable.utils.ConfigurableFieldSpec(id: str, name: Optional[str], description: Optional[str], default: Any, annotation: Any)[source]¶ A field that can be configured by the user. It is a specification of a field. Create new instance of Config...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.utils.ConfigurableFieldSpec.html
450205991b21-0
langchain.schema.runnable.fallbacks.RunnableWithFallbacks¶ class langchain.schema.runnable.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 per...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-2
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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-3
Default implementation runs invoke in parallel using a thread pool executor. 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. bind(**kwargs: Any) → R...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-4
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-5
namespace is [“langchain”, “llms”, “openai”] get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel][source]¶ Get a pydantic model that can be used to validate output to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic output sc...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-6
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). classmethod lc_id() → List[str]¶ A unique identifier for this class for serialization purposes. The unique identifier is a ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-7
Default implementation of transform, which buffers input and then calls stream. Subclasses should override this method if they can start producing output while input is still being generated. classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and lo...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-8
added to the run. with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[Input, Output]¶ Create a new Runnable that retries the original runnable on exceptions. Parameters retry_if_exc...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
450205991b21-9
property output_schema: Type[pydantic.main.BaseModel]¶ The type of output this runnable produces specified as a pydantic model. property runnables: Iterator[langchain.schema.runnable.base.Runnable[langchain.schema.runnable.utils.Input, langchain.schema.runnable.utils.Output]]¶
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.fallbacks.RunnableWithFallbacks.html
b6cfd88bc0d3-0
langchain.schema.callbacks.tracers.log_stream.RunLog¶ class langchain.schema.callbacks.tracers.log_stream.RunLog(*ops: Dict[str, Any], state: RunState)[source]¶ A run log. Attributes state Current state of the log, obtained from applying all ops in sequence. Methods __init__(*ops, state) __init__(*ops: Dict[str, Any], ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.log_stream.RunLog.html
3dce2a10d570-0
langchain.schema.runnable.passthrough.identity¶ langchain.schema.runnable.passthrough.identity(x: Other) → Other[source]¶ An identity function
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.passthrough.identity.html
90d0744029c6-0
langchain.schema.runnable.config.RunnableConfig¶ class langchain.schema.runnable.config.RunnableConfig[source]¶ Configuration for a Runnable. Attributes tags Tags for this call and any sub-calls (eg. metadata Metadata for this call and any sub-calls (eg. callbacks Callbacks for this call and any sub-calls (eg. run_name...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.config.RunnableConfig.html
90d0744029c6-1
values() __init__(*args, **kwargs)¶ clear() → None.  Remove all items from D.¶ copy() → a shallow copy of D¶ fromkeys(value=None, /)¶ Create a new dictionary with keys from iterable and values set to value. get(key, default=None, /)¶ Return the value for key if key is in the dictionary, else default. items() → a set-li...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.config.RunnableConfig.html
f9ef8ef73296-0
langchain.schema.callbacks.stdout.StdOutCallbackHandler¶ class langchain.schema.callbacks.stdout.StdOutCallbackHandler(color: Optional[str] = None)[source]¶ Callback Handler that prints to std out. Initialize callback handler. Attributes ignore_agent Whether to ignore agent callbacks. ignore_chain Whether to ignore cha...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.stdout.StdOutCallbackHandler.html
f9ef8ef73296-1
Run when Retriever starts running. on_retry(retry_state, *, run_id[, parent_run_id]) Run on a retry event. on_text(text[, color, end]) Run when agent ends. on_tool_end(output[, color, ...]) If not the final action, print out observation. on_tool_error(error, **kwargs) Do nothing. on_tool_start(serialized, input_str, **...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.stdout.StdOutCallbackHandler.html
f9ef8ef73296-2
Do nothing. on_llm_error(error: BaseException, **kwargs: Any) → None[source]¶ Do nothing. on_llm_new_token(token: str, **kwargs: Any) → None[source]¶ Do nothing. on_llm_start(serialized: Dict[str, Any], prompts: List[str], **kwargs: Any) → None[source]¶ Print out the prompts. on_retriever_end(documents: Sequence[Docume...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.stdout.StdOutCallbackHandler.html
f9ef8ef73296-3
If not the final action, print out observation. on_tool_error(error: BaseException, **kwargs: Any) → None[source]¶ Do nothing. on_tool_start(serialized: Dict[str, Any], input_str: str, **kwargs: Any) → None[source]¶ Do nothing. Examples using StdOutCallbackHandler¶ Argilla Comet Aim Weights & Biases ClearML OpaquePromp...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.stdout.StdOutCallbackHandler.html
6c0024d2fe7f-0
langchain.schema.callbacks.tracers.schemas.TracerSessionBase¶ class langchain.schema.callbacks.tracers.schemas.TracerSessionBase[source]¶ Bases: TracerSessionV1Base Base class for TracerSession. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cann...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionBase.html
6c0024d2fe7f-1
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionBase.html
6c0024d2fe7f-2
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.TracerSessionBase.html
da74605e0f31-0
langchain.schema.runnable.base.RunnableSequence¶ class langchain.schema.runnable.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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-2
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]) → List[Output][source]¶ Default implementation runs ainvoke in parallel using asyncio.gather. The default implementat...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-3
Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-4
Returns A pydantic model that can be used to validate config. configurable_alternatives(which: ConfigurableField, default_key: str = 'default', **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶ configurable_fields(**kwargs: Union[ConfigurableField, C...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-5
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-6
This method allows to get an output 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 output. invoke(input: Input, config: Optional[RunnableConfig] = None) → Output[source]¶ Transform a single input into an output. ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-7
Return a new Runnable that maps a list of inputs to a list of outputs, by calling invoke() with each input. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ cl...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-8
Bind config to a Runnable, returning a new Runnable. with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,)) → RunnableWithFallbacksT[Input, Output]¶ Add fallbacks to a runnable, returning a new Runnable. Parameters fallbacks – A se...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
da74605e0f31-9
between retries stop_after_attempt – The maximum number of attempts to make before giving up Returns A new Runnable that retries the original runnable on exceptions. with_types(*, input_type: Optional[Type[Input]] = None, output_type: Optional[Type[Output]] = None) → Runnable[Input, Output]¶ Bind input and output types...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.RunnableSequence.html
4108ac0d5bbf-0
langchain.schema.runnable.base.coerce_to_runnable¶ langchain.schema.runnable.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,...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.base.coerce_to_runnable.html
1dea8168a532-0
langchain.schema.callbacks.tracers.langchain.wait_for_all_tracers¶ langchain.schema.callbacks.tracers.langchain.wait_for_all_tracers() → None[source]¶ Wait for all tracers to finish. Examples using wait_for_all_tracers¶ LangSmith Walkthrough
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.langchain.wait_for_all_tracers.html
9291e561746b-0
langchain.schema.messages.messages_from_dict¶ langchain.schema.messages.messages_from_dict(messages: List[dict]) → List[BaseMessage][source]¶ Convert a sequence of messages from dicts to Message objects. Parameters messages – Sequence of messages (as dicts) to convert. Returns List of messages (BaseMessages).
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.messages_from_dict.html
e0c81b2f553c-0
langchain.schema.runnable.config.EmptyDict¶ class langchain.schema.runnable.config.EmptyDict[source]¶ Empty dict type. Methods __init__(*args, **kwargs) clear() copy() fromkeys([value]) Create a new dictionary with keys from iterable and values set to value. get(key[, default]) Return the value for key if key is in the...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.config.EmptyDict.html
e0c81b2f553c-1
pop(k[, d]) → v, remove specified key and return the corresponding value.¶ If the key is not found, return the default if given; otherwise, raise a KeyError. popitem()¶ Remove and return a (key, value) pair as a 2-tuple. Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty. setdef...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.config.EmptyDict.html
31f4493a812a-0
langchain.schema.output.ChatGeneration¶ class langchain.schema.output.ChatGeneration[source]¶ Bases: Generation A single chat generation output. 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 generati...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.ChatGeneration.html
31f4493a812a-1
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.ChatGeneration.html
31f4493a812a-2
The unique identifier is a list of strings that describes the path to the object. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Uni...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.ChatGeneration.html
8f2d1a70ec78-0
langchain.schema.callbacks.tracers.schemas.BaseRun¶ class langchain.schema.callbacks.tracers.schemas.BaseRun[source]¶ Bases: BaseModel Base class for Run. 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. para...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.BaseRun.html
8f2d1a70ec78-1
the new model: you should trust this data deep – set to True to make a deep copy of the model Returns new model instance dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[boo...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.BaseRun.html
8f2d1a70ec78-2
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.schemas.BaseRun.html
6452eacbb973-0
langchain.schema.runnable.utils.aadd¶ async langchain.schema.runnable.utils.aadd(addables: AsyncIterable[Addable]) → Optional[Addable][source]¶ Asynchronously add a sequence of addable objects together.
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.utils.aadd.html
73127e01efc3-0
langchain.schema.runnable.config.ensure_config¶ langchain.schema.runnable.config.ensure_config(config: Optional[RunnableConfig] = None) → RunnableConfig[source]¶ Ensure that a config is a dict with all keys present. Parameters config (Optional[RunnableConfig], optional) – The config to ensure. Defaults to None. Returns...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.config.ensure_config.html
6ca4b12e8ca8-0
langchain.schema.output.GenerationChunk¶ class langchain.schema.output.GenerationChunk[source]¶ Bases: Generation A Generation chunk, which can be concatenated with other Generation chunks. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.GenerationChunk.html
6ca4b12e8ca8-1
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.GenerationChunk.html
6ca4b12e8ca8-2
The unique identifier is a list of strings that describes the path to the object. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Uni...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.output.GenerationChunk.html
b041dea9f01d-0
langchain.schema.messages.FunctionMessage¶ class langchain.schema.messages.FunctionMessage[source]¶ Bases: BaseMessage A Message for passing the result of executing a function back to a model. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.FunctionMessage.html
b041dea9f01d-1
deep – set to True to make a deep copy of the model Returns new model instance dict(*, 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, ex...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.FunctionMessage.html
b041dea9f01d-2
The unique identifier is a list of strings that describes the path to the object. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Uni...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.FunctionMessage.html
ecd3f7d27cf9-0
langchain.schema.runnable.retry.RunnableRetry¶ class langchain.schema.runnable.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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-1
from langchain.chat_models import ChatOpenAI from langchain.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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-2
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, co...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-3
The jsonpatch ops can be applied in order to construct state. 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 override this method if they can sta...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-4
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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-5
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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-6
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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-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 ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
ecd3f7d27cf9-9
The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain.schema.runnable.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 ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.runnable.retry.RunnableRetry.html
130068305dea-0
langchain.schema.chat.ChatSession¶ class langchain.schema.chat.ChatSession[source]¶ Chat Session represents a single conversation, channel, or other group of messages. messages: Sequence[langchain.schema.messages.BaseMessage]¶ The LangChain chat messages loaded from the source. functions: Sequence[dict]¶ The function c...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.chat.ChatSession.html
8b30b7e5e4ff-0
langchain.schema.language_model.BaseLanguageModel¶ class langchain.schema.language_model.BaseLanguageModel[source]¶ Bases: RunnableSerializable[Union[PromptValue, str, List[BaseMessage]], LanguageModelOutput], ABC Abstract base class for interfacing with language models. All language model wrappers inherit from BaseLan...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-1
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-2
**kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a string. abstract async apredict_messages(messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → BaseMessage[source]¶ Asynchronously pass messages ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-3
Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, *...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-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...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-5
classmethod from_orm(obj: Any) → Model¶ abstract generate_prompt(prompts: List[PromptValue], stop: Optional[List[str]] = None, callbacks: Callbacks = None, **kwargs: Any) → LLMResult[source]¶ Pass a sequence of prompts to the model and return model generations. This method should make use of batched calls for models th...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-6
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 langchain.llms.openai.OpenAI, then the namespace is [“langchain”, “llms”, “open...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-7
abstract invoke(input: Input, config: Optional[RunnableConfig] = None) → Output¶ Transform a single input into an output. Override to implement. Parameters input – The input to the runnable. config – A config to use when invoking the runnable. The config supports standard keys like ‘tags’, ‘metadata’ for tracing purpos...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-8
by calling invoke() with each input. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = No...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-9
to the model provider API call. Returns Top model prediction as a message. classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(in...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-10
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: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
8b30b7e5e4ff-11
property InputType: TypeAlias¶ Get the input type for this runnable. property OutputType: Type[langchain.schema.runnable.utils.Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain.schema.runnable.utils.ConfigurableFieldSpec]¶ List configurable fields f...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html
a343556478a7-0
langchain.schema.callbacks.manager.CallbackManagerForRetrieverRun¶ class langchain.schema.callbacks.manager.CallbackManagerForRetrieverRun(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheri...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForRetrieverRun.html
a343556478a7-1
on_text(text, **kwargs) Run when text is received. __init__(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheritable_tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = No...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForRetrieverRun.html
a343556478a7-2
Run when retriever errors. on_retry(retry_state: RetryCallState, **kwargs: Any) → None¶ Run on a retry event. on_text(text: str, **kwargs: Any) → Any¶ Run when text is received. Parameters text (str) – The received text. Returns The result of the callback. Return type Any Examples using CallbackManagerForRetrieverRun¶ ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.CallbackManagerForRetrieverRun.html
29ac32343a6a-0
langchain.schema.callbacks.tracers.base.BaseTracer¶ class langchain.schema.callbacks.tracers.base.BaseTracer(**kwargs: Any)[source]¶ Base interface for tracers. Attributes ignore_agent Whether to ignore agent callbacks. ignore_chain Whether to ignore chain callbacks. ignore_chat_model Whether to ignore chat model callb...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.base.BaseTracer.html
29ac32343a6a-1
Run when Retriever ends running. on_retriever_error(error, *, run_id, **kwargs) Run when Retriever errors. on_retriever_start(serialized, query, *, run_id) Run when Retriever starts running. on_retry(retry_state, *, run_id, **kwargs) Run on a retry event. on_text(text, *, run_id[, parent_run_id]) Run on arbitrary text....
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.base.BaseTracer.html
29ac32343a6a-2
Handle an error for a chain run. on_chain_start(serialized: Dict[str, Any], inputs: Dict[str, Any], *, run_id: UUID, tags: Optional[List[str]] = None, parent_run_id: Optional[UUID] = None, metadata: Optional[Dict[str, Any]] = None, run_type: Optional[str] = None, name: Optional[str] = None, **kwargs: Any) → Run[source]...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.base.BaseTracer.html
29ac32343a6a-3
Start a trace for an LLM run. on_retriever_end(documents: Sequence[Document], *, run_id: UUID, **kwargs: Any) → Run[source]¶ Run when Retriever ends running. on_retriever_error(error: BaseException, *, run_id: UUID, **kwargs: Any) → Run[source]¶ Run when Retriever errors. on_retriever_start(serialized: Dict[str, Any], ...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.tracers.base.BaseTracer.html
c59ee4ccf988-0
langchain.schema.callbacks.manager.handle_event¶ langchain.schema.callbacks.manager.handle_event(handlers: List[BaseCallbackHandler], event_name: str, ignore_condition_name: Optional[str], *args: Any, **kwargs: Any) → None[source]¶ Generic event handler for CallbackManager. Note: This function is used by langserve to h...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.callbacks.manager.handle_event.html
1c42795eb5dd-0
langchain.schema.messages.get_buffer_string¶ langchain.schema.messages.get_buffer_string(messages: Sequence[BaseMessage], human_prefix: str = 'Human', ai_prefix: str = 'AI') → str[source]¶ Convert sequence of Messages to strings and concatenate them into one string. Args:messages: Messages to be converted to strings. h...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.get_buffer_string.html
2bf196a59c74-0
langchain.schema.messages.FunctionMessageChunk¶ class langchain.schema.messages.FunctionMessageChunk[source]¶ Bases: FunctionMessage, BaseMessageChunk A Function Message chunk. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to fo...
lang/api.python.langchain.com/en/latest/schema/langchain.schema.messages.FunctionMessageChunk.html