id
stringlengths
14
16
text
stringlengths
20
3.26k
source
stringlengths
65
181
692590522142-0
langchain_google_vertexai.callbacks.VertexAICallbackHandler¶ class langchain_google_vertexai.callbacks.VertexAICallbackHandler[source]¶ Callback Handler that tracks VertexAI info. Attributes always_verbose Whether to call verbose callbacks even if verbose is False. completion_characters completion_tokens ignore_agent W...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-1
on_llm_new_token(token, **kwargs) Runs on new LLM token. on_llm_start(serialized, prompts, **kwargs) Runs when LLM starts running. on_retriever_end(documents, *, run_id[, ...]) Run when Retriever ends running. on_retriever_error(error, *, run_id[, ...]) Run when Retriever errors. on_retriever_start(serialized, query, *...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-2
Parameters finish (AgentFinish) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_chain_end(outputs: Dict[str, Any], *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when chain ends running. Parameters outputs (Dict[str, Any]) – run_id (UUID) – pa...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-3
kwargs (Any) – Return type Any on_chat_model_start(serialized: Dict[str, Any], messages: List[List[BaseMessage]], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when a chat model starts running. ATTENTION: Th...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-4
on_llm_new_token(token: str, **kwargs: Any) → None[source]¶ Runs on new LLM token. Only available when streaming is enabled. Parameters token (str) – kwargs (Any) – Return type None on_llm_start(serialized: Dict[str, Any], prompts: List[str], **kwargs: Any) → None[source]¶ Runs when LLM starts running. Parameters ser...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-5
query (str) – run_id (UUID) – parent_run_id (Optional[UUID]) – tags (Optional[List[str]]) – metadata (Optional[Dict[str, Any]]) – kwargs (Any) – Return type Any on_retry(retry_state: RetryCallState, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run on a retry event. Parameters retry...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
692590522142-6
kwargs (Any) – Return type Any on_tool_start(serialized: Dict[str, Any], input_str: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, inputs: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when tool starts running. Param...
https://api.python.langchain.com/en/latest/callbacks/langchain_google_vertexai.callbacks.VertexAICallbackHandler.html
d43eaaa7dd9d-0
langchain_community.callbacks.utils.import_pandas¶ langchain_community.callbacks.utils.import_pandas() → Any[source]¶ Import the pandas python package and raise an error if it is not installed. Return type Any
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.utils.import_pandas.html
e45866429cfc-0
langchain_community.callbacks.mlflow_callback.MlflowLogger¶ class langchain_community.callbacks.mlflow_callback.MlflowLogger(**kwargs: Any)[source]¶ Callback Handler that logs metrics and artifacts to mlflow server. Parameters name (str) – Name of the run. experiment (str) – Name of the experiment. tags (dict) – Tags t...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.mlflow_callback.MlflowLogger.html
e45866429cfc-1
Return type None html(html: str, filename: str) → None[source]¶ To log the input html string as html file artifact. Parameters html (str) – filename (str) – Return type None jsonf(data: Dict[str, Any], filename: str) → None[source]¶ To log the input data as json file artifact. Parameters data (Dict[str, Any]) – file...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.mlflow_callback.MlflowLogger.html
e45866429cfc-2
name (str) – dataframe (Any) – Return type None text(text: str, filename: str) → None[source]¶ To log the input text as text file artifact. Parameters text (str) – filename (str) – Return type None
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.mlflow_callback.MlflowLogger.html
cd6e12c948a9-0
langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler¶ class langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler(identifier: str, *, token_ratelimit: None = None, request_ratelimit: None = None, include_output_tokens: bool = False)[source]¶ Callback to handle rate...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-1
redis = Redis.from_env() ratelimit = Ratelimit( redis=redis, # fixed window to allow 10 requests every 10 seconds: limiter=FixedWindow(max_requests=10, window=10), ) user_id = "foo" handler = UpstashRatelimitHandler( identifier=user_id, request_ratelimit=ratelimit ) # Initialize a simple runnable to...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-2
on_llm_end(response, **kwargs) Run when LLM ends running on_llm_error(error, *, run_id[, parent_run_id]) Run when LLM errors. :param error: The error that occurred. :type error: BaseException :param kwargs: Additional keyword arguments. - response (LLMResult): The response which was generated before ...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-3
__init__(identifier: str, *, token_ratelimit: None = None, request_ratelimit: None = None, include_output_tokens: bool = False)[source]¶ Creates UpstashRatelimitHandler. Must be passed an identifier to ratelimit like a user id or an ip address. Additionally, it must be passed at least one of token_ratelimit or request_...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-4
output = chain.invoke( "input", config={ "callbacks": [handler] } ) on_agent_action(action: AgentAction, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run on agent action. Parameters action (AgentAction) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-5
Run when chain starts running. on_chain_start runs multiple times during a chain execution. To make sure that it’s only called once, we keep a bool state _checked. If not self._checked, we call limit with request_ratelimit and raise UpstashRatelimitError if the identifier is rate limited. Parameters serialized (Dict[st...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-6
Run when LLM errors. :param error: The error that occurred. :type error: BaseException :param kwargs: Additional keyword arguments. response (LLMResult): The response which was generated beforethe error occurred. Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Retu...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-7
kwargs (Any) – Return type Any on_retriever_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when Retriever errors. Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_retriever_start(seria...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-8
parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_tool_end(output: Any, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when tool ends running. Parameters output (Any) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_tool_error(...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
cd6e12c948a9-9
ratelimit configurations but with a new identifier if it’s provided. Also resets the state of the handler. Parameters identifier (Optional[str]) – Return type UpstashRatelimitHandler
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.upstash_ratelimit_callback.UpstashRatelimitHandler.html
0bd0e8877c19-0
langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler¶ class langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler[source]¶ Callback Handler that tracks OpenAI info. Attributes always_verbose Whether to call verbose callbacks even if verbose is False. completion_tokens Completion tokens used. ignore_agent...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-1
on_llm_error(error, *, run_id[, parent_run_id]) Run when LLM errors. :param error: The error that occurred. :type error: BaseException :param kwargs: Additional keyword arguments. - response (LLMResult): The response which was generated before the error occurred. :type kwargs: Any. on_llm_new_token(t...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-2
Parameters action (AgentAction) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_agent_finish(finish: AgentFinish, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run on agent end. Parameters finish (AgentFinish) – run_id (UUID) – parent_run_id (Opt...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-3
inputs (Dict[str, Any]) – run_id (UUID) – parent_run_id (Optional[UUID]) – tags (Optional[List[str]]) – metadata (Optional[Dict[str, Any]]) – kwargs (Any) – Return type Any on_chat_model_start(serialized: Dict[str, Any], messages: List[List[BaseMessage]], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tag...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-4
Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_llm_new_token(token: str, **kwargs: Any) → None[source]¶ Run on new LLM token. Only available when streaming is enabled. Parameters token (str) – The new token. chunk (GenerationChunk | ChatGenerati...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-5
run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_retriever_start(serialized: Dict[str, Any], query: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when Retriever start...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
0bd0e8877c19-6
Parameters output (Any) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_tool_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when tool errors. Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optiona...
https://api.python.langchain.com/en/latest/callbacks/langchain_nvidia_ai_endpoints.callbacks.UsageCallbackHandler.html
d488a8bb51a5-0
langchain_community.callbacks.human.HumanApprovalCallbackHandler¶ class langchain_community.callbacks.human.HumanApprovalCallbackHandler(approve: ~typing.Callable[[~typing.Any], bool] = <function _default_approve>, should_check: ~typing.Callable[[~typing.Dict[str, ~typing.Any]], bool] = <function _default_true>)[source...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-1
on_llm_error(error, *, run_id[, parent_run_id]) Run when LLM errors. :param error: The error that occurred. :type error: BaseException :param kwargs: Additional keyword arguments. - response (LLMResult): The response which was generated before the error occurred. :type kwargs: Any. on_llm_new_token(t...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-2
should_check (Callable[[Dict[str, Any]], bool]) – __init__(approve: ~typing.Callable[[~typing.Any], bool] = <function _default_approve>, should_check: ~typing.Callable[[~typing.Dict[str, ~typing.Any]], bool] = <function _default_true>)[source]¶ Parameters approve (Callable[[Any], bool]) – should_check (Callable[[Dict...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-3
Run when chain errors. Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_chain_start(serialized: Dict[str, Any], inputs: Dict[str, Any], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dic...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-4
kwargs (Any) – Return type Any on_llm_end(response: LLMResult, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when LLM ends running. Parameters response (LLMResult) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_llm_error(error: BaseException,...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-5
kwargs (Any) – Return type Any on_llm_start(serialized: Dict[str, Any], prompts: List[str], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when LLM starts running. ATTENTION: This method is called for non-cha...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-6
kwargs (Any) – Return type Any on_retriever_start(serialized: Dict[str, Any], query: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when Retriever starts running. Parameters serialized (Dict[str, Any]) –...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
d488a8bb51a5-7
kwargs (Any) – Return type Any on_tool_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when tool errors. Parameters error (BaseException) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type Any on_tool_start(serialized: Dict[str...
https://api.python.langchain.com/en/latest/callbacks/langchain_community.callbacks.human.HumanApprovalCallbackHandler.html
cd7b773cac1b-0
langchain_core.callbacks.stdout.StdOutCallbackHandler¶ class langchain_core.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 chain c...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-1
on_llm_start(serialized, prompts, *, run_id) Run when LLM starts running. on_retriever_end(documents, *, run_id[, ...]) Run when Retriever ends running. on_retriever_error(error, *, run_id[, ...]) Run when Retriever errors. on_retriever_start(serialized, query, *, run_id) Run when Retriever starts running. on_retry(ret...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-2
color (Optional[str]) – kwargs (Any) – Return type None on_chain_end(outputs: Dict[str, Any], **kwargs: Any) → None[source]¶ Print out that we finished a chain. Parameters outputs (Dict[str, Any]) – kwargs (Any) – Return type None on_chain_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] =...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-3
metadata (Optional[Dict[str, Any]]) – kwargs (Any) – Return type Any on_llm_end(response: LLMResult, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when LLM ends running. Parameters response (LLMResult) – run_id (UUID) – parent_run_id (Optional[UUID]) – kwargs (Any) – Return type...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-4
kwargs (Any) – Return type Any on_llm_start(serialized: Dict[str, Any], prompts: List[str], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when LLM starts running. ATTENTION: This method is called for non-cha...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-5
kwargs (Any) – Return type Any on_retriever_start(serialized: Dict[str, Any], query: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Run when Retriever starts running. Parameters serialized (Dict[str, Any]) –...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
cd7b773cac1b-6
color (Optional[str]) – observation_prefix (Optional[str]) – llm_prefix (Optional[str]) – kwargs (Any) – Return type None on_tool_error(error: BaseException, *, run_id: UUID, parent_run_id: Optional[UUID] = None, **kwargs: Any) → Any¶ Run when tool errors. Parameters error (BaseException) – run_id (UUID) – parent...
https://api.python.langchain.com/en/latest/callbacks/langchain_core.callbacks.stdout.StdOutCallbackHandler.html
891d93f5b778-0
langchain_experimental.rl_chain.base.embed_list_type¶ langchain_experimental.rl_chain.base.embed_list_type(item: list, model: Any, namespace: Optional[str] = None) → List[Dict[str, Union[str, List[str]]]][source]¶ Embed a list item. Parameters item (list) – model (Any) – namespace (Optional[str]) – Return type List[...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.embed_list_type.html
2d862e67785d-0
langchain_experimental.rl_chain.base.BasedOn¶ langchain_experimental.rl_chain.base.BasedOn(anything: Any) → _BasedOn[source]¶ Wrap a value to indicate that it should be based on. Parameters anything (Any) – Return type _BasedOn
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.BasedOn.html
1bd03ccd7a8d-0
langchain_experimental.rl_chain.pick_best_chain.PickBestFeatureEmbedder¶ class langchain_experimental.rl_chain.pick_best_chain.PickBestFeatureEmbedder(auto_embed: bool, model: Optional[Any] = None, *args: Any, **kwargs: Any)[source]¶ Embed the BasedOn and ToSelectFrom inputs into a format that can be used by the learni...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBestFeatureEmbedder.html
1bd03ccd7a8d-1
Parameters event (PickBestEvent) – Return type str get_context_and_action_embeddings(event: PickBestEvent) → tuple[source]¶ Parameters event (PickBestEvent) – Return type tuple get_indexed_dot_product(context_emb: List, action_embs: List) → Dict[source]¶ Parameters context_emb (List) – action_embs (List) – Return t...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBestFeatureEmbedder.html
e2818f4f48ba-0
langchain_experimental.rl_chain.base.embed¶ langchain_experimental.rl_chain.base.embed(to_embed: Union[str, _Embed, Dict, List[Union[str, _Embed]], List[Dict]], model: Any, namespace: Optional[str] = None) → List[Dict[str, Union[str, List[str]]]][source]¶ Embed the actions or context using the SentenceTransformer model...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.embed.html
f29741117307-0
langchain_experimental.rl_chain.base.Policy¶ class langchain_experimental.rl_chain.base.Policy(**kwargs: Any)[source]¶ Abstract class to represent a policy. Methods __init__(**kwargs) learn(event) log(event) predict(event) save() Parameters kwargs (Any) – __init__(**kwargs: Any)[source]¶ Parameters kwargs (Any) – abs...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.Policy.html
bfb74908f164-0
langchain_experimental.rl_chain.base.RLChain¶ class langchain_experimental.rl_chain.base.RLChain[source]¶ Bases: Chain, Generic[TEvent] Chain that leverages the Vowpal Wabbit (VW) model as a learned policy for reinforcement learning. - llm_chain Represents the underlying Language Model chain. Type Chain - prompt The te...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-1
Notes The class initializes the VW model using the provided arguments. If selection_scorer is not provided, a warning is logged, indicating that no reinforcement learning will occur unless the update_with_delayed_score method is called. Create a new model by parsing and validating input data from keyword arguments. Rai...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-2
param prompt: BasePromptTemplate [Required]¶ param selection_scorer: Union[SelectionScorer, None] = None¶ param selection_scorer_activated: bool = True¶ param tags: Optional[List[str]] = None¶ Optional list of tags associated with the chain. Defaults to None. These tags will be associated with each call to this chain, ...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-3
addition to callbacks passed to the chain during construction, but only these runtime callbacks will propagate to calls to other objects. tags (Optional[List[str]]) – List of string tags to pass to all callbacks. These will be passed in addition to tags passed to the chain during construction, but only these runtime ta...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-4
Run ainvoke in parallel on a list of inputs, yielding results as they complete. Parameters inputs (Sequence[Input]) – config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type AsyncIterator[Tuple[int, Union[Output, Exception]]] async acall(i...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-5
these runtime tags will propagate to calls to other objects. metadata (Optional[Dict[str, Any]]) – Optional metadata associated with the chain. Defaults to None include_run_info (bool) – Whether to include run info in the response. Defaults to False. run_name (Optional[str]) – Returns A dict of named outputs. Should c...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-6
Return type List[Dict[str, str]] async aprep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶ Prepare chain inputs, including adding inputs from memory. Parameters inputs (Union[Dict[str, Any], Any]) – Dictionary of raw inputs, or single input if chain expects only one param. Should contain all inputs speci...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-7
with all the inputs Parameters *args (Any) – If the chain expects a single input, it can be passed in as the sole positional argument. callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – Callbacks to use for this chain run. These will be called in addition to callbacks passed to the chain duri...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-8
Assigns new fields to the dict output of this runnable. Returns a new runnable. from langchain_community.llms.fake import FakeStreamingListLLM from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import SystemMessagePromptTemplate from langchain_core.runnables import Runnable from opera...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-9
config (Optional[RunnableConfig]) – kwargs (Optional[Any]) – Return type AsyncIterator[Output] astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Seque...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-10
data: Dict[str, Any] Below is a table that illustrates some evens that might be emitted by various chains. Metadata fields have been omitted from the table for brevity. Chain definitions have been included after the table. ATTENTION This reference table is for the V2 version of the schema. event name chunk input output...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-11
Here are declarations associated with the events shown above: format_docs: def format_docs(docs: List[Document]) -> str: '''Format the docs.''' return ", ".join([doc.page_content for doc in docs]) format_docs = RunnableLambda(format_docs) some_tool: @tool def some_tool(x: int, y: str) -> dict: '''Some_tool....
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-12
"tags": [], }, ] Parameters input (Any) – The input to the runnable. config (Optional[RunnableConfig]) – The config to use for the runnable. version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1. Users should use v2. v1 is for backwards compatibility and will be deprecated in 0.4.0. No de...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-13
An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes 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: O...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-14
exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags. kwargs (Any) – Return type Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]] async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of a...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-15
yielding results as they complete. Parameters inputs (Sequence[Input]) – config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type Iterator[Tuple[int, Union[Output, Exception]]] bind(**kwargs: Any) → Runnable[Input, Output]¶ Bind arguments t...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-16
Return type Type[BaseModel] configurable_alternatives(which: ConfigurableField, *, default_key: str = 'default', prefix_keys: bool = False, **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶ Configure alternatives for runnables that can be set at runt...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-17
max_tokens=ConfigurableField( id="output_token_number", name="Max tokens in the output", description="The maximum number of tokens in the output", ) ) # max_tokens = 20 print( "max_tokens_20: ", model.invoke("tell me something about chess").content ) # max_tokens = 200 print("max_tok...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-18
update (Optional[DictStrAny]) – 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 (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model deactivate_selection_scorer() → None[so...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-19
config (Optional[RunnableConfig]) – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. Return type Type[BaseModel] classmethod get_lc_namespace() → List[str]¶ Get the namespace of the langchain object. For example, if the class is langchain.llms.openai.OpenAI, then ...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-20
Parameters input (Dict[str, Any]) – The input to the runnable. config (Optional[RunnableConfig]) – A config to use when invoking the runnable. The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer t...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-21
dumps_kwargs (Any) – Return type unicode 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. Return type List[str] map() → Runnable[List[Input], List[Output]]¶ Return a new Runnable that maps a...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-22
proto (Protocol) – allow_pickle (bool) – Return type Model pick(keys: Union[str, List[str]]) → RunnableSerializable[Any, Any]¶ Pick keys from the dict output of this runnable. Pick single key:import json from langchain_core.runnables import RunnableLambda, RunnableMap as_str = RunnableLambda(str) as_json = RunnableLa...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-23
Parameters keys (Union[str, List[str]]) – Return type RunnableSerializable[Any, Any] pipe(*others: Union[Runnable[Any, Other], Callable[[Any], Other]], name: Optional[str] = None) → RunnableSerializable[Input, Other]¶ Compose this Runnable with Runnable-like objects to make a RunnableSequence. Equivalent to RunnableSe...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-24
Chain.input_keys except for inputs that will be set by the chain’s memory. Returns A dictionary of all inputs, including those added by the chain’s memory. Return type Dict[str, str] prep_outputs(inputs: Dict[str, str], outputs: Dict[str, str], return_only_outputs: bool = False) → Dict[str, str]¶ Validate and prepare c...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-25
these runtime callbacks will propagate to calls to other objects. tags (Optional[List[str]]) – List of string tags to pass to all callbacks. These will be passed in addition to tags passed to the chain during construction, but only these runtime tags will propagate to calls to other objects. **kwargs (Any) – If the cha...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-26
Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode stream(input...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-27
Parameters localns (Any) – Return type None update_with_delayed_score(score: float, chain_response: Dict[str, Any], force_score: bool = False) → None[source]¶ Updates the learned policy with the score provided. Will raise an error if selection_scorer is set, and force_score=True was not provided during the method call...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-28
kwargs (Any) – Return type Runnable[Input, Output] with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,), exception_key: Optional[str] = None) → RunnableWithFallbacksT[Input, Output]¶ Add fallbacks to a runnable, returning a new R...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-29
Return type RunnableWithFallbacksT[Input, Output] with_listeners(*, on_start: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_end: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_error: Optional[Union[Callable[[Run], None], Callable[[Run,...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-30
on_error (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) – Return type Runnable[Input, Output] with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[I...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
bfb74908f164-31
output_type (Optional[Type[Output]]) – Return type Runnable[Input, Output] property InputType: Type[Input]¶ The type of input this runnable accepts specified as a type annotation. property OutputType: Type[Output]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[Co...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html
3ae655827703-0
langchain_experimental.rl_chain.base.AutoSelectionScorer¶ class langchain_experimental.rl_chain.base.AutoSelectionScorer[source]¶ Bases: SelectionScorer[Event], BaseModel Auto selection scorer. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data canno...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html
3ae655827703-1
the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: ...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html
3ae655827703-2
Return type SystemMessagePromptTemplate 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, exclude_n...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html
3ae655827703-3
Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pi...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html
e995d1f2faaf-0
langchain_experimental.rl_chain.base.VwPolicy¶ class langchain_experimental.rl_chain.base.VwPolicy(model_repo: ModelRepository, vw_cmd: List[str], feature_embedder: Embedder, vw_logger: VwLogger, *args: Any, **kwargs: Any)[source]¶ Vowpal Wabbit policy. Methods __init__(model_repo, vw_cmd, ...) learn(event) log(event) ...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.VwPolicy.html
4d78b36d5bab-0
langchain_experimental.rl_chain.base.stringify_embedding¶ langchain_experimental.rl_chain.base.stringify_embedding(embedding: List) → str[source]¶ Convert an embedding to a string. Parameters embedding (List) – Return type str
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.stringify_embedding.html
40b530807927-0
langchain_experimental.rl_chain.model_repository.ModelRepository¶ class langchain_experimental.rl_chain.model_repository.ModelRepository(folder: Union[str, PathLike], with_history: bool = True, reset: bool = False)[source]¶ Model Repository. Methods __init__(folder[, with_history, reset]) get_tag() has_history() load(c...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.model_repository.ModelRepository.html
fc5ba3660ef9-0
langchain_experimental.rl_chain.base.Embedder¶ class langchain_experimental.rl_chain.base.Embedder(*args: Any, **kwargs: Any)[source]¶ Abstract class to represent an embedder. Methods __init__(*args, **kwargs) format(event) Parameters args (Any) – kwargs (Any) – __init__(*args: Any, **kwargs: Any)[source]¶ Parameters...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.Embedder.html
6bd30ceb83cf-0
langchain_experimental.rl_chain.pick_best_chain.PickBest¶ class langchain_experimental.rl_chain.pick_best_chain.PickBest[source]¶ Bases: RLChain[PickBestEvent] Chain that leverages the Vowpal Wabbit (VW) model for reinforcement learning with a context, with the goal of modifying the prompt before the LLM call. Each inv...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-1
A list of dictionaries, where each dictionary represents an action with namespace names as keys and corresponding action strings as values. For instance, action = ToSelectFrom([{“namespace1”: [“action1”, “another identifier of action1”], “namespace2”: “action2”}, {“namespace1”: “action3”, “namespace2”: “action4”}]). Ex...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-2
There are many different types of memory - please see memory docs for the full catalog. param metadata: Optional[Dict[str, Any]] = None¶ Optional metadata associated with the chain. Defaults to None. This metadata will be associated with each call to this chain, and passed as arguments to the handlers defined in callba...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-3
only one param. Should contain all inputs specified in Chain.input_keys except for inputs that will be set by the chain’s memory. return_only_outputs (bool) – Whether to return only outputs in the response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-4
e.g., if the underlying runnable uses an API which supports a batch mode. Parameters inputs (List[Input]) – config (Optional[Union[RunnableConfig, List[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type List[Output] async abatch_as_completed(inputs: Sequence[Input], config: Optiona...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-5
response. If True, only new keys generated by this chain will be returned. If False, both input keys and new keys generated by this chain will be returned. Defaults to False. callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – Callbacks to use for this chain run. These will be called in additi...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-6
config (Optional[RunnableConfig]) – kwargs (Any) – Return type Dict[str, Any] apply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → List[Dict[str, str]]¶ [Deprecated] Call the chain on all inputs in the list. Notes Deprecated since version langcha...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-7
Returns A dict of the final chain outputs. Return type Dict[str, str] async arun(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ [Deprecated] Convenience method for executing...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-8
# and 'context' string: question = "What's the temperature in Boise, Idaho?" context = "Weather report for Boise, Idaho on 07/03/23..." await chain.arun(question=question, context=context) # -> "The temperature in Boise is..." Notes Deprecated since version langchain==0.1.0: Use ainvoke instead. assign(**kwargs: Union[...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-9
Parameters kwargs (Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) – Return type RunnableSerializable[Any, Any] async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Asy...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html
6bd30ceb83cf-10
parent runnable is assigned its own unique ID. parent_ids: List[str] - The IDs of the parent runnables thatgenerated the event. The root runnable will have an empty list. The order of the parent IDs is from the root to the immediate parent. Only available for v2 version of the API. The v1 version of the API will return...
https://api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html