id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
c8286ec5c23e-1
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/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-2
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/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-3
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/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-4
Extend the chat template with a sequence of messages. format(**kwargs: Any) → str[source]¶ Format the chat template into a string. Parameters **kwargs – keyword arguments to use for filling in template variables in all the template messages in this chat template. Returns formatted string format_messages(**kwargs: Any) ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-5
(message type, template); e.g., (“human”, “{user_input}”), (4) 2-tuple of (message class, template), (4) a string which is shorthand for (“human”, template); e.g., “{user_input}” Returns a chat prompt template classmethod from_orm(obj: Any) → Model¶ classmethod from_role_strings(string_messages: List[Tuple[str, str]]) ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-6
the human. Parameters template – template string **kwargs – keyword arguments to pass to the constructor. Returns A new instance of this class. get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage th...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-7
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_lc_serializable() → bool¶ Return whether this class i...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-8
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¶ partial(**kwargs: Union[str, Callable[[], str]]) → ChatPromptTemplate[source]¶ Get a new ChatPromptTemplate with ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-9
to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ transform(input: Iterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of transform, which buffers input and then calls stream...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-10
on_error: Called if the runnable throws an error, with the Run object. The Run object contains information about the run, including its id, type, input, output, error, start_time, end_time, and any tags or metadata added to the run. with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
c8286ec5c23e-11
constructor. property lc_secrets: Dict[str, str]¶ A map of constructor argument names to secret ids. For example,{“openai_api_key”: “OPENAI_API_KEY”} property output_schema: Type[pydantic.main.BaseModel]¶ The type of output this runnable produces specified as a pydantic model. Examples using ChatPromptTemplate¶ Faceboo...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptTemplate.html
b88a9a252e64-0
langchain.prompts.chat.MessagesPlaceholder¶ class langchain.prompts.chat.MessagesPlaceholder[source]¶ Bases: BaseMessagePromptTemplate Prompt template that assumes variable is already list of messages. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input da...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.MessagesPlaceholder.html
b88a9a252e64-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/prompts/langchain.prompts.chat.MessagesPlaceholder.html
b88a9a252e64-2
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/prompts/langchain.prompts.chat.MessagesPlaceholder.html
b88a9a252e64-3
A map of constructor argument names to secret ids. For example,{“openai_api_key”: “OPENAI_API_KEY”} Examples using MessagesPlaceholder¶ Set env var OPENAI_API_KEY or load from a .env file: Conversational Retrieval Agent Agents Memory in LLMChain Add Memory to OpenAI Functions Agent Types of `MessagePromptTemplate` Addi...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.MessagesPlaceholder.html
632130a7d9b0-0
langchain.prompts.prompt.Prompt¶ langchain.prompts.prompt.Prompt¶ alias of PromptTemplate
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.prompt.Prompt.html
4cab35cd0c9e-0
langchain.prompts.base.StringPromptValue¶ class langchain.prompts.base.StringPromptValue[source]¶ Bases: PromptValue String prompt value. 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 text: str [Requ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.base.StringPromptValue.html
4cab35cd0c9e-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/prompts/langchain.prompts.base.StringPromptValue.html
4cab35cd0c9e-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/prompts/langchain.prompts.base.StringPromptValue.html
316f0fe83fdd-0
langchain.prompts.few_shot.FewShotChatMessagePromptTemplate¶ class langchain.prompts.few_shot.FewShotChatMessagePromptTemplate[source]¶ Bases: BaseChatPromptTemplate, _FewShotPromptTemplateMixin Chat prompt template that supports few-shot examples. The high level structure of produced by this prompt template is a list ...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-1
Prompt template with dynamically selected examples: from langchain.prompts import SemanticSimilarityExampleSelector from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import Chroma examples = [ {"input": "2+2", "output": "4"}, {"input": "2+3", "output": "5"}, {"input": "2+4", "out...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-2
print(final_prompt.format_messages(input="What's 3+3?")) # Use within an LLM from langchain.chat_models import ChatAnthropic chain = final_prompt | ChatAnthropic() chain.invoke({"input": "What's 3+3?"}) Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input d...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-3
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, config: Optional[RunnableConfig] = None, **kwargs: Any) → Output¶ Defaul...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-4
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/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-5
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-6
format_prompt(**kwargs: Any) → PromptValue¶ Format prompt. Should return a PromptValue. :param **kwargs: Keyword arguments to use for formatting. Returns PromptValue. classmethod from_orm(obj: Any) → Model¶ get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be use...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-7
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/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-8
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¶ partial(**kwargs: Union[str, Callable[[], str]]) → BasePromptTemplate¶ Return a partial of the prompt template. s...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-9
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/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
316f0fe83fdd-10
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/prompts/langchain.prompts.few_shot.FewShotChatMessagePromptTemplate.html
e158bf434da6-0
langchain.prompts.chat.ChatMessagePromptTemplate¶ class langchain.prompts.chat.ChatMessagePromptTemplate[source]¶ Bases: BaseStringMessagePromptTemplate Chat message prompt template. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatMessagePromptTemplate.html
e158bf434da6-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/prompts/langchain.prompts.chat.ChatMessagePromptTemplate.html
e158bf434da6-2
Get the namespace of the langchain object. For example, if the class is langchain.llms.openai.OpenAI, then the namespace is [“langchain”, “llms”, “openai”] classmethod is_lc_serializable() → bool¶ Return whether or not the class is serializable. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = No...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatMessagePromptTemplate.html
e158bf434da6-3
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ classmethod update_forward_refs(**localns: Any) → None¶ Try to upda...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatMessagePromptTemplate.html
2a25265685fc-0
langchain.prompts.chat.ChatPromptValue¶ class langchain.prompts.chat.ChatPromptValue[source]¶ Bases: PromptValue Chat prompt value. A type of a prompt value that is built from messages. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be par...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptValue.html
2a25265685fc-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/prompts/langchain.prompts.chat.ChatPromptValue.html
2a25265685fc-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/prompts/langchain.prompts.chat.ChatPromptValue.html
0ca8e1ab4f6b-0
langchain.prompts.chat.ChatPromptValueConcrete¶ class langchain.prompts.chat.ChatPromptValueConcrete[source]¶ Bases: ChatPromptValue Chat prompt value which explicitly lists out the message types it accepts. For use in external schemas. Create a new model by parsing and validating input data from keyword arguments. Rai...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.ChatPromptValueConcrete.html
0ca8e1ab4f6b-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/prompts/langchain.prompts.chat.ChatPromptValueConcrete.html
0ca8e1ab4f6b-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/prompts/langchain.prompts.chat.ChatPromptValueConcrete.html
dff309f0c02b-0
langchain.prompts.example_selector.length_based.LengthBasedExampleSelector¶ class langchain.prompts.example_selector.length_based.LengthBasedExampleSelector[source]¶ Bases: BaseExampleSelector, BaseModel Select examples based on length. Create a new model by parsing and validating input data from keyword arguments. Rai...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.example_selector.length_based.LengthBasedExampleSelector.html
dff309f0c02b-1
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/prompts/langchain.prompts.example_selector.length_based.LengthBasedExampleSelector.html
dff309f0c02b-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/prompts/langchain.prompts.example_selector.length_based.LengthBasedExampleSelector.html
01608b002030-0
langchain.prompts.chat.AIMessagePromptTemplate¶ class langchain.prompts.chat.AIMessagePromptTemplate[source]¶ Bases: BaseStringMessagePromptTemplate AI message prompt template. This is a message sent from the AI. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if t...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.AIMessagePromptTemplate.html
01608b002030-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/prompts/langchain.prompts.chat.AIMessagePromptTemplate.html
01608b002030-2
Get the namespace of the langchain object. For example, if the class is langchain.llms.openai.OpenAI, then the namespace is [“langchain”, “llms”, “openai”] classmethod is_lc_serializable() → bool¶ Return whether or not the class is serializable. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = No...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.AIMessagePromptTemplate.html
01608b002030-3
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ classmethod update_forward_refs(**localns: Any) → None¶ Try to upda...
lang/api.python.langchain.com/en/latest/prompts/langchain.prompts.chat.AIMessagePromptTemplate.html
77b39f033514-0
langchain_experimental.comprehend_moderation.prompt_safety.ComprehendPromptSafety¶ class langchain_experimental.comprehend_moderation.prompt_safety.ComprehendPromptSafety(client: Any, callback: Optional[Any] = None, unique_id: Optional[str] = None, chain_id: Optional[str] = None)[source]¶ Methods __init__(client[, call...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.prompt_safety.ComprehendPromptSafety.html
078f752d7889-0
langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPromptSafetyConfig¶ class langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPromptSafetyConfig[source]¶ Bases: BaseModel Create a new model by parsing and validating input data from keyword arguments. Raises Valida...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPromptSafetyConfig.html
078f752d7889-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPromptSafetyConfig.html
078f752d7889-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPromptSafetyConfig.html
886c70fc64e6-0
langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain¶ class langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain[source]¶ Bases: Chain A subclass of Chain, designed to apply moderation to LLMs. Create a new model b...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-1
and at the end of every chain. At the start, memory loads variables and passes them along in the chain. At the end, it saves any returned variables. 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 ...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-2
and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a chain with its use case. param unique_id: Optional[str] = None¶ A unique id that can be used to identify or group a user or session param verbose: bool [Optional]¶ Whether or not run in verbose mode. ...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-3
metadata – Optional metadata associated with the chain. Defaults to None include_run_info – Whether to include run info in the response. Defaults to False. Returns A dict of named outputs. Should contain all outputs specified inChain.output_keys. async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, ...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-4
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/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-5
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. tags – List of string tags to pass to all callbacks. These will be passed in addition to tags passed to the c...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-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/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-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/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-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 dict(**kw...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-9
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/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-10
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 each input. classmethod parse_file...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-11
Returns A dict of the final chain outputs. run(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → Any¶ Convenience method for executing chain. The main difference between this method...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-12
save(file_path: Union[Path, str]) → None¶ Save the chain. Expects Chain._chain_type property to be implemented and for memory to benull. Parameters file_path – Path to file to save the chain to. Example chain.save(file_path="path/chain.yaml") classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definiti...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-13
Add fallbacks to a runnable, returning a new Runnable. Parameters fallbacks – A sequence of runnables to try if the original runnable fails. exceptions_to_handle – A tuple of exception types to handle. Returns A new Runnable that will try the original runnable, and then each fallback in order, upon failures. with_liste...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-14
Bind input and output types to a Runnable, returning a new Runnable. property InputType: Type[langchain.schema.runnable.utils.Input]¶ The type of input this runnable accepts specified as a type annotation. property OutputType: Type[langchain.schema.runnable.utils.Output]¶ The type of output this runnable produces speci...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
886c70fc64e6-15
external use. 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/comprehend_moderation/langchain_experimental.comprehend_moderation.amazon_comprehend_moderation.AmazonComprehendModerationChain.html
7f0051eff250-0
langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPiiConfig¶ class langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPiiConfig[source]¶ Bases: BaseModel Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the i...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPiiConfig.html
7f0051eff250-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPiiConfig.html
7f0051eff250-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationPiiConfig.html
f79129b2e0bf-0
langchain_experimental.comprehend_moderation.pii.ComprehendPII¶ class langchain_experimental.comprehend_moderation.pii.ComprehendPII(client: Any, callback: Optional[Any] = None, unique_id: Optional[str] = None, chain_id: Optional[str] = None)[source]¶ Methods __init__(client[, callback, unique_id, chain_id]) validate(p...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.pii.ComprehendPII.html
7a8241cc14f2-0
langchain_experimental.comprehend_moderation.base_moderation_config.BaseModerationConfig¶ class langchain_experimental.comprehend_moderation.base_moderation_config.BaseModerationConfig[source]¶ Bases: BaseModel Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.BaseModerationConfig.html
7a8241cc14f2-1
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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.BaseModerationConfig.html
7a8241cc14f2-2
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 = None, encoding: unicode = 'utf8', proto...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.BaseModerationConfig.html
6d0163f3530b-0
langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPiiError¶ class langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPiiError(message: str = 'The prompt contains PII entities and cannot be processed')[source]¶ Exception raised if PII entities are detected. ...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPiiError.html
cb6a5ed8564e-0
langchain_experimental.comprehend_moderation.toxicity.ComprehendToxicity¶ class langchain_experimental.comprehend_moderation.toxicity.ComprehendToxicity(client: Any, callback: Optional[Any] = None, unique_id: Optional[str] = None, chain_id: Optional[str] = None)[source]¶ Methods __init__(client[, callback, unique_id, c...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.toxicity.ComprehendToxicity.html
c35135b28f61-0
langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPromptSafetyError¶ class langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPromptSafetyError(message: str = 'The prompt is unsafe and cannot be processed')[source]¶ Exception raised if Intention entities ar...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationPromptSafetyError.html
033f8b006061-0
langchain_experimental.comprehend_moderation.base_moderation_config.ModerationToxicityConfig¶ class langchain_experimental.comprehend_moderation.base_moderation_config.ModerationToxicityConfig[source]¶ Bases: BaseModel Create a new model by parsing and validating input data from keyword arguments. Raises ValidationErro...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationToxicityConfig.html
033f8b006061-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationToxicityConfig.html
033f8b006061-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/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_config.ModerationToxicityConfig.html
2e0fed39c2d5-0
langchain_experimental.comprehend_moderation.base_moderation.BaseModeration¶ class langchain_experimental.comprehend_moderation.base_moderation.BaseModeration(client: Any, config: Optional[Any] = None, moderation_callback: Optional[Any] = None, unique_id: Optional[str] = None, run_manager: Optional[CallbackManagerForCh...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation.BaseModeration.html
2ec8f6663184-0
langchain_experimental.comprehend_moderation.base_moderation_callbacks.BaseModerationCallbackHandler¶ class langchain_experimental.comprehend_moderation.base_moderation_callbacks.BaseModerationCallbackHandler[source]¶ Attributes pii_callback prompt_safety_callback toxicity_callback Methods __init__() on_after_pii(moder...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_callbacks.BaseModerationCallbackHandler.html
dba22dade3f5-0
langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationToxicityError¶ class langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationToxicityError(message: str = 'The prompt contains toxic content and cannot be processed')[source]¶ Exception raised if Toxic entities a...
lang/api.python.langchain.com/en/latest/comprehend_moderation/langchain_experimental.comprehend_moderation.base_moderation_exceptions.ModerationToxicityError.html
bb78cb1e1d74-0
langchain_experimental.smart_llm.base.SmartLLMChain¶ class langchain_experimental.smart_llm.base.SmartLLMChain[source]¶ Bases: Chain Generalized implementation of SmartGPT (origin: https://youtu.be/wVzuvf9D9BU) A SmartLLMChain is an LLMChain that instead of simply passing the prompt to the LLM performs these 3 steps: 1...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-1
Each custom chain can optionally call additional callback methods, see Callback docs for full details. param critique_llm: Optional[langchain.schema.language_model.BaseLanguageModel] = None¶ LLM to use in critique step. If None given, ‘llm’ will be used. param history: langchain_experimental.smart_llm.base.SmartLLMChai...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-2
Prompt object to use. param resolver_llm: Optional[langchain.schema.language_model.BaseLanguageModel] = None¶ LLM to use in resolve step. If None given, ‘llm’ will be used. param return_intermediate_steps: bool = False¶ Whether to return ideas and critique, in addition to resolution. param tags: Optional[List[str]] = N...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-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 – 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 thi...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-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/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-5
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 override this method if they can run asynchronously. apply(input_list: List[Dict[str, Any]], callbacks: Optional...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-6
# -> "The temperature in Boise is..." # Suppose we have a multi-input chain that takes a 'question' string # 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...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-7
Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if they can start producing output while input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-8
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-9
This method allows to get an input schema for a specific configuration. Parameters config – A config to use when generating the schema. Returns A pydantic model that can be used to validate input. classmethod get_lc_namespace() → List[str]¶ Get the namespace of the langchain object. For example, if the class is langcha...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-10
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-11
Parameters inputs – Dictionary of raw inputs, or single input if chain expects only one param. Should contain all inputs specified in 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. prep_outputs(inputs: Dict[str,...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-12
addition to callbacks passed to the chain during construction, but only 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 c...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-13
Subclasses should override this method if they support streaming output. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ transform(input: Iterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Defau...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-14
on_end: Called after the runnable finishes running, with the Run object. on_error: Called if the runnable throws an error, with the Run object. The Run object contains information about the run, including its id, type, input, output, error, start_time, end_time, and any tags or metadata added to the run. with_retry(*, ...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
bb78cb1e1d74-15
property lc_attributes: Dict¶ List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_secrets: Dict[str, str]¶ A map of constructor argument names to secret ids. For example,{“openai_api_key”: “OPENAI_API_KEY”} property output_keys: Lis...
lang/api.python.langchain.com/en/latest/smart_llm/langchain_experimental.smart_llm.base.SmartLLMChain.html
8d5b453c2c64-0
langchain.storage.encoder_backed.EncoderBackedStore¶ class langchain.storage.encoder_backed.EncoderBackedStore(store: BaseStore[str, Any], key_encoder: Callable[[K], str], value_serializer: Callable[[V], bytes], value_deserializer: Callable[[Any], V])[source]¶ Wraps a store with key and value encoders/decoders. Example...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.encoder_backed.EncoderBackedStore.html