id stringlengths 14 16 | text stringlengths 13 2.7k | source stringlengths 57 178 |
|---|---|---|
22449ede29f6-7 | 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/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-8 | get_num_tokens(text: str) → int¶
Get the number of tokens present in the text.
Useful for checking if an input will fit in a model’s context window.
Parameters
text – The string input to tokenize.
Returns
The integer number of tokens in the text.
get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶
Get the ... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-9 | config – 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 to the RunnableConfig
for more details.
Returns
The output of the runnable.
classmethod is_... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-10 | classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
Pass a single string input to t... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-11 | stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[BaseMessageChunk]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → ... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-12 | 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/chat_models/langchain.chat_models.jinachat.JinaChat.html |
22449ede29f6-13 | 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 included in the serialized kwargs.
These attributes must be accepted by the constr... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.jinachat.JinaChat.html |
78c9503636e4-0 | langchain.chat_models.bedrock.ChatPromptAdapter¶
class langchain.chat_models.bedrock.ChatPromptAdapter[source]¶
Adapter class to prepare the inputs from Langchain to prompt format
that Chat model expects.
Methods
__init__()
convert_messages_to_prompt(provider, messages)
__init__()¶
classmethod convert_messages_to_promp... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.bedrock.ChatPromptAdapter.html |
13dd0c5bbf33-0 | langchain.chat_models.fireworks.acompletion_with_retry_streaming¶
async langchain.chat_models.fireworks.acompletion_with_retry_streaming(llm: ChatFireworks, use_retry: bool, *, run_manager: Optional[AsyncCallbackManagerForLLMRun] = None, **kwargs: Any) → Any[source]¶
Use tenacity to retry the completion call for stream... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.acompletion_with_retry_streaming.html |
878159846395-0 | langchain.chat_models.minimax.MiniMaxChat¶
class langchain.chat_models.minimax.MiniMaxChat[source]¶
Bases: MinimaxCommon, BaseChatModel
Wrapper around Minimax large language models.
To use, you should have the environment variable MINIMAX_GROUP_ID and
MINIMAX_API_KEY set with your API token, or pass it as a named param... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-1 | param top_p: float = 0.95¶
Total probability mass of tokens to consider at each step.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(messages: List[BaseMessage], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: A... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-2 | 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 PromptValue is an object that can be
converted to match the format of any languag... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-3 | **kwargs – Arbitrary additional keyword arguments. These are usually passed
to the model provider API call.
Returns
Top model prediction as a string.
async apredict_messages(messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → BaseMessage¶
Asynchronously pass messages to the model and ... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-4 | 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 can be applied in order to construct state.
async atransform(input: As... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-5 | 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/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-6 | classmethod from_orm(obj: Any) → Model¶
generate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwarg... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-7 | 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/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-8 | Returns
A pydantic model that can be used to validate output.
get_token_ids(text: str) → List[int]¶
Return the ordered ids of the tokens in a text.
Parameters
text – The string input to tokenize.
Returns
A list of ids corresponding to the tokens in the text, in order they occurin the text.
invoke(input: Union[PromptVal... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-9 | 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/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-10 | Parameters
messages – A sequence of chat messages corresponding to a single model input.
stop – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these substrings.
**kwargs – Arbitrary additional keyword arguments. These are usually passed
to the model provider API call.
Retur... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-11 | 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/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
878159846395-12 | 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/chat_models/langchain.chat_models.minimax.MiniMaxChat.html |
50d1a460c5aa-0 | langchain.chat_models.azure_openai.AzureChatOpenAI¶
class langchain.chat_models.azure_openai.AzureChatOpenAI[source]¶
Bases: ChatOpenAI
Azure OpenAI Chat Completion API.
To use this class you
must have a deployed model on Azure OpenAI. Use deployment_name in the
constructor to refer to the “Model deployment name” in th... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-1 | Your Azure Active Directory token.
Automatically inferred from env var AZURE_OPENAI_AD_TOKEN if not provided.
For more:
https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id.
param azure_ad_token_provider: Union[str, None] = None¶
A function that returns an Azure Active Directory token.
W... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-2 | Holds any model parameters valid for create call not explicitly specified.
param model_name: str = 'gpt-3.5-turbo' (alias 'model')¶
Model name to use.
param model_version: str = ''¶
Legacy, for openai<1.0.0 support.
param n: int = 1¶
Number of chat completions to generate for each prompt.
param openai_api_base: Optiona... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-3 | The model name to pass to tiktoken when using this class.
Tiktoken is used to count the number of tokens in documents to constrain
them to be under a certain limit. By default, when set to None, this will
be the same as the embedding model name. However, there are some cases
where you may want to use this Embedding cla... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-4 | e.g., if the underlying runnable uses an API which supports a batch mode.
async agenerate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-5 | async ainvoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → BaseMessage¶
Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not i... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-6 | to the model provider API call.
Returns
Top model prediction as a message.
async astream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[BaseMessageChunk]¶
Default implementation of astream, which calls ainvo... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-7 | input is still being generated.
batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation runs invoke in parallel using a thread pool executor.
The default implementation of batch w... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-8 | The type of config this runnable accepts specified as a pydantic model.
To mark a field as configurable, see the configurable_fields
and configurable_alternatives methods.
Parameters
include – A list of fields to include in the config schema.
Returns
A pydantic model that can be used to validate config.
configurable_al... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-9 | Returns
new model instance
dict(**kwargs: Any) → Dict¶
Return a dictionary of the LLM.
classmethod from_orm(obj: Any) → Model¶
generate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = N... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-10 | to the model provider API call.
Returns
An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output.
get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model that can be used to validate input to the runnable.
R... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-11 | 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... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-12 | 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/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-13 | Pass a message sequence to the model and return a message prediction.
Use this method when passing in chat messages. If you want to pass in raw text,use predict.
Parameters
messages – A sequence of chat messages corresponding to a single model input.
stop – Stop words to use when generating. Model output is cut off at ... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-14 | classmethod validate(value: Any) → Model¶
with_config(config: Optional[RunnableConfig] = None, **kwargs: Any) → Runnable[Input, Output]¶
Bind config to a Runnable, returning a new Runnable.
with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'E... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
50d1a460c5aa-15 | Create a new Runnable that retries the original runnable on exceptions.
Parameters
retry_if_exception_type – A tuple of exception types to retry on
wait_exponential_jitter – Whether to add jitter to the wait time
between retries
stop_after_attempt – The maximum number of attempts to make before giving up
Returns
A new ... | lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.azure_openai.AzureChatOpenAI.html |
a784db12ddd4-0 | langchain.chat_loaders.imessage.IMessageChatLoader¶
class langchain.chat_loaders.imessage.IMessageChatLoader(path: Optional[Union[str, Path]] = None)[source]¶
Load chat sessions from the iMessage chat.db SQLite file.
It only works on macOS when you have iMessage enabled and have the chat.db file.
The chat.db file is li... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.imessage.IMessageChatLoader.html |
8cb9e8b0278a-0 | langchain.chat_loaders.utils.merge_chat_runs_in_session¶
langchain.chat_loaders.utils.merge_chat_runs_in_session(chat_session: ChatSession, delimiter: str = '\n\n') → ChatSession[source]¶
Merge chat runs together in a chat session.
A chat run is a sequence of messages from the same sender.
Parameters
chat_session – A c... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.utils.merge_chat_runs_in_session.html |
a320ebde5e83-0 | langchain.chat_loaders.facebook_messenger.SingleFileFacebookMessengerChatLoader¶
class langchain.chat_loaders.facebook_messenger.SingleFileFacebookMessengerChatLoader(path: Union[Path, str])[source]¶
Load Facebook Messenger chat data from a single file.
Parameters
path (Union[Path, str]) – The path to the chat file.
pa... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.facebook_messenger.SingleFileFacebookMessengerChatLoader.html |
a6e14632bc6f-0 | langchain.chat_loaders.gmail.GMailLoader¶
class langchain.chat_loaders.gmail.GMailLoader(creds: Any, n: int = 100, raise_error: bool = False)[source]¶
Load data from GMail.
There are many ways you could want to load data from GMail.
This loader is currently fairly opinionated in how to do so.
The way it does it is it f... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.gmail.GMailLoader.html |
5873ffb75469-0 | langchain.chat_loaders.telegram.TelegramChatLoader¶
class langchain.chat_loaders.telegram.TelegramChatLoader(path: Union[str, Path])[source]¶
Load telegram conversations to LangChain chat messages.
To export, use the Telegram Desktop app from
https://desktop.telegram.org/, select a conversation, click the three dots
in... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.telegram.TelegramChatLoader.html |
040a03f9d70a-0 | langchain.chat_loaders.slack.SlackChatLoader¶
class langchain.chat_loaders.slack.SlackChatLoader(path: Union[str, Path])[source]¶
Load Slack conversations from a dump zip file.
Initialize the chat loader with the path to the exported Slack dump zip file.
Parameters
path – Path to the exported Slack dump zip file.
Metho... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.slack.SlackChatLoader.html |
89bcaa648e1c-0 | langchain.chat_loaders.whatsapp.WhatsAppChatLoader¶
class langchain.chat_loaders.whatsapp.WhatsAppChatLoader(path: str)[source]¶
Load WhatsApp conversations from a dump zip file or directory.
Initialize the WhatsAppChatLoader.
Parameters
path (str) – Path to the exported WhatsApp chat
zip directory, folder, or file.
To... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.whatsapp.WhatsAppChatLoader.html |
e43afedd7eb3-0 | langchain.chat_loaders.facebook_messenger.FolderFacebookMessengerChatLoader¶
class langchain.chat_loaders.facebook_messenger.FolderFacebookMessengerChatLoader(path: Union[str, Path])[source]¶
Load Facebook Messenger chat data from a folder.
Parameters
path (Union[str, Path]) – The path to the directory
containing the c... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.facebook_messenger.FolderFacebookMessengerChatLoader.html |
db0b9c1afb76-0 | langchain.chat_loaders.utils.map_ai_messages_in_session¶
langchain.chat_loaders.utils.map_ai_messages_in_session(chat_sessions: ChatSession, sender: str) → ChatSession[source]¶
Convert messages from the specified ‘sender’ to AI messages.
This is useful for fine-tuning the AI to adapt to your voice. | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.utils.map_ai_messages_in_session.html |
68a57d230eb4-0 | langchain.chat_loaders.base.BaseChatLoader¶
class langchain.chat_loaders.base.BaseChatLoader[source]¶
Base class for chat loaders.
Methods
__init__()
lazy_load()
Lazy load the chat sessions.
load()
Eagerly load the chat sessions into memory.
__init__()¶
abstract lazy_load() → Iterator[ChatSession][source]¶
Lazy load th... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.base.BaseChatLoader.html |
abeafee5c022-0 | langchain.chat_loaders.utils.merge_chat_runs¶
langchain.chat_loaders.utils.merge_chat_runs(chat_sessions: Iterable[ChatSession]) → Iterator[ChatSession][source]¶
Merge chat runs together.
A chat run is a sequence of messages from the same sender.
Parameters
chat_sessions – A list of chat sessions.
Returns
A list of cha... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.utils.merge_chat_runs.html |
66c5516fabd9-0 | langchain.chat_loaders.utils.map_ai_messages¶
langchain.chat_loaders.utils.map_ai_messages(chat_sessions: Iterable[ChatSession], sender: str) → Iterator[ChatSession][source]¶
Convert messages from the specified ‘sender’ to AI messages.
This is useful for fine-tuning the AI to adapt to your voice.
Examples using map_ai_... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.utils.map_ai_messages.html |
0f64d3ee668c-0 | langchain.chat_loaders.langsmith.LangSmithDatasetChatLoader¶
class langchain.chat_loaders.langsmith.LangSmithDatasetChatLoader(*, dataset_name: str, client: Optional['Client'] = None)[source]¶
Load chat sessions from a LangSmith dataset with the “chat” data type.
dataset_name¶
The name of the LangSmith dataset.
Type
st... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.langsmith.LangSmithDatasetChatLoader.html |
8202a5fb4333-0 | langchain.chat_loaders.langsmith.LangSmithRunChatLoader¶
class langchain.chat_loaders.langsmith.LangSmithRunChatLoader(runs: Iterable[Union[str, Run]], client: Optional['Client'] = None)[source]¶
Load chat sessions from a list of LangSmith “llm” runs.
runs¶
The list of LLM run IDs or run objects.
Type
Iterable[Union[st... | lang/api.python.langchain.com/en/latest/chat_loaders/langchain.chat_loaders.langsmith.LangSmithRunChatLoader.html |
0305acca9815-0 | langchain_experimental.rl_chain.base.embed_dict_type¶
langchain_experimental.rl_chain.base.embed_dict_type(item: Dict, model: Any) → Dict[str, Any][source]¶
Helper function to embed a dictionary item. | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.embed_dict_type.html |
262a0cb7d104-0 | langchain_experimental.rl_chain.pick_best_chain.PickBestSelected¶
class langchain_experimental.rl_chain.pick_best_chain.PickBestSelected(index: Optional[int] = None, probability: Optional[float] = None, score: Optional[float] = None)[source]¶
Attributes
index
probability
score
Methods
__init__([index, probability, scor... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBestSelected.html |
eae2e12d96b2-0 | langchain_experimental.rl_chain.base.ToSelectFrom¶
langchain_experimental.rl_chain.base.ToSelectFrom(anything: Any) → _ToSelectFrom[source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.ToSelectFrom.html |
aee80cad87de-0 | langchain_experimental.rl_chain.base.get_based_on_and_to_select_from¶
langchain_experimental.rl_chain.base.get_based_on_and_to_select_from(inputs: Dict[str, Any]) → Tuple[Dict, Dict][source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.get_based_on_and_to_select_from.html |
940acd484191-0 | langchain_experimental.rl_chain.pick_best_chain.PickBest¶
class langchain_experimental.rl_chain.pick_best_chain.PickBest[source]¶
Bases: RLChain[PickBestEvent]
PickBest is a class designed to leverage the Vowpal Wabbit (VW) model for reinforcement learning with a context, with the goal of modifying the prompt before th... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-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... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-2 | 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 callbacks.
You can use these to eg identify a specific instance of a cha... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-3 | Chain.input_keys except for inputs that will be set by the chain’s
memory.
return_only_outputs – 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 by this
chain will be returned. Defaults to False.
callbacks ... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-4 | e.g., if the underlying runnable uses an API which supports a batch mode.
async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, ... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-5 | async ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶
Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not implement a native async version of invoke.
Subclasses should o... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-6 | directly as keyword arguments.
Returns
The chain output.
Example
# Suppose we have a single-input chain that takes a 'question' string:
await chain.arun("What's the temperature in Boise, Idaho?")
# -> "The temperature in Boise is..."
# Suppose we have a multi-input chain that takes a 'question' string
# and 'context' s... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-7 | The jsonpatch ops can be applied in order to construct state.
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 should override this method if th... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-8 | 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/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-9 | # -> {"_type": "foo", "verbose": False, ...}
classmethod from_llm(llm: ~langchain.schema.language_model.BaseLanguageModel, prompt: ~langchain.schema.prompt_template.BasePromptTemplate, selection_scorer: ~typing.Union[~langchain_experimental.rl_chain.base.AutoSelectionScorer, object] = <object object>, **kwargs: ~typing... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-10 | Returns
A pydantic model that can be used to validate output.
invoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶
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 r... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-11 | 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/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-12 | The main difference between this method and Chain.__call__ is that this
method expects inputs to be passed directly in as positional arguments or
keyword arguments, whereas Chain.__call__ expects a single input dictionary
with all the inputs
Parameters
*args – If the chain expects a single input, it can be passed in as... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-13 | This function should be called to save the state of the learned policy model.
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... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-14 | 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/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
940acd484191-15 | 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/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBest.html |
9c69c7e0334a-0 | langchain_experimental.rl_chain.base.Policy¶
class langchain_experimental.rl_chain.base.Policy(**kwargs: Any)[source]¶
Methods
__init__(**kwargs)
learn(event)
log(event)
predict(event)
save()
__init__(**kwargs: Any)[source]¶
abstract learn(event: TEvent) → None[source]¶
abstract log(event: TEvent) → None[source]¶
abstr... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.Policy.html |
3e1fcaaaa373-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]¶
Methods
__init__(model_repo, vw_cmd, ...)
learn(event)
log(event)
predict(event)
save()
... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.VwPolicy.html |
d653fe19cee9-0 | langchain_experimental.rl_chain.base.prepare_inputs_for_autoembed¶
langchain_experimental.rl_chain.base.prepare_inputs_for_autoembed(inputs: Dict[str, Any]) → Dict[str, Any][source]¶
go over all the inputs and if something is either wrapped in _ToSelectFrom or _BasedOn, and if their inner values are not already _Embed,... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.prepare_inputs_for_autoembed.html |
29844a900e07-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]¶
Methods
__init__(folder[, with_history, reset])
get_tag()
has_history()
load(commandline)
save(w... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.model_repository.ModelRepository.html |
c9b8cf473fcd-0 | langchain_experimental.rl_chain.pick_best_chain.PickBestRandomPolicy¶
class langchain_experimental.rl_chain.pick_best_chain.PickBestRandomPolicy(feature_embedder: Embedder, **kwargs: Any)[source]¶
Methods
__init__(feature_embedder, **kwargs)
learn(event)
log(event)
predict(event)
save()
__init__(feature_embedder: Embed... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBestRandomPolicy.html |
7a9b0eec93c5-0 | langchain_experimental.rl_chain.base.stringify_embedding¶
langchain_experimental.rl_chain.base.stringify_embedding(embedding: List) → str[source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.stringify_embedding.html |
9aa4eeaa2394-0 | langchain_experimental.rl_chain.base.Selected¶
class langchain_experimental.rl_chain.base.Selected[source]¶
Methods
__init__()
__init__()¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.Selected.html |
3528c277ac77-0 | langchain_experimental.rl_chain.base.parse_lines¶
langchain_experimental.rl_chain.base.parse_lines(parser: vw.TextFormatParser, input_str: str) → List['vw.Example'][source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.parse_lines.html |
e718f1d80b16-0 | langchain_experimental.rl_chain.metrics.MetricsTrackerRollingWindow¶
class langchain_experimental.rl_chain.metrics.MetricsTrackerRollingWindow(window_size: int, step: int)[source]¶
Attributes
score
Methods
__init__(window_size, step)
on_decision()
on_feedback(value)
to_pandas()
__init__(window_size: int, step: int)[sou... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.metrics.MetricsTrackerRollingWindow.html |
384d38dbb928-0 | langchain_experimental.rl_chain.metrics.MetricsTrackerAverage¶
class langchain_experimental.rl_chain.metrics.MetricsTrackerAverage(step: int)[source]¶
Attributes
score
Methods
__init__(step)
on_decision()
on_feedback(score)
to_pandas()
__init__(step: int)[source]¶
on_decision() → None[source]¶
on_feedback(score: float)... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.metrics.MetricsTrackerAverage.html |
a55edf129336-0 | langchain_experimental.rl_chain.base.BasedOn¶
langchain_experimental.rl_chain.base.BasedOn(anything: Any) → _BasedOn[source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.BasedOn.html |
52b364e26b2f-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]¶
Text Embedder class that embeds the BasedOn and ToSelectFrom inputs into a format that... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.pick_best_chain.PickBestFeatureEmbedder.html |
51ad3f944a36-0 | langchain_experimental.rl_chain.vw_logger.VwLogger¶
class langchain_experimental.rl_chain.vw_logger.VwLogger(path: Optional[Union[str, PathLike]])[source]¶
Methods
__init__(path)
log(vw_ex)
logging_enabled()
__init__(path: Optional[Union[str, PathLike]])[source]¶
log(vw_ex: str) → None[source]¶
logging_enabled() → bool... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.vw_logger.VwLogger.html |
a0b6520316a2-0 | langchain_experimental.rl_chain.base.AutoSelectionScorer¶
class langchain_experimental.rl_chain.base.AutoSelectionScorer[source]¶
Bases: SelectionScorer[Event], BaseModel
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 v... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html |
a0b6520316a2-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/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html |
a0b6520316a2-2 | classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmet... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.AutoSelectionScorer.html |
9fb2f2cbc456-0 | langchain_experimental.rl_chain.base.is_stringtype_instance¶
langchain_experimental.rl_chain.base.is_stringtype_instance(item: Any) → bool[source]¶
Helper function to check if an item is a string. | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.is_stringtype_instance.html |
620e00b2bebc-0 | langchain_experimental.rl_chain.base.Embed¶
langchain_experimental.rl_chain.base.Embed(anything: Any, keep: bool = False) → Any[source]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.Embed.html |
000fca84a00b-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]¶ | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.embed_list_type.html |
6bfcced260ee-0 | langchain_experimental.rl_chain.base.RLChain¶
class langchain_experimental.rl_chain.base.RLChain[source]¶
Bases: Chain, Generic[TEvent]
The RLChain class leverages the Vowpal Wabbit (VW) model as a learned policy for reinforcement learning.
- llm_chain
Represents the underlying Language Model chain.
Type
Chain
- prompt... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-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... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-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,
... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-3 | these runtime callbacks will propagate to calls to other objects.
tags – 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.
metadata – Optional metadata associated with the ... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-4 | returned. If False, both input keys and new keys generated by this
chain will be returned. Defaults to False.
callbacks – Callbacks to use for this chain run. These will be called in
addition to callbacks passed to the chain during construction, but only
these runtime callbacks will propagate to calls to other objects.... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-5 | Convenience method for executing chain.
The main difference between this method and Chain.__call__ is that this
method expects inputs to be passed directly in as positional arguments or
keyword arguments, whereas Chain.__call__ expects a single input dictionary
with all the inputs
Parameters
*args – If the chain expect... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-6 | 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/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-7 | 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/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
6bfcced260ee-8 | 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
deactivat... | lang/api.python.langchain.com/en/latest/rl_chain/langchain_experimental.rl_chain.base.RLChain.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.