id
stringlengths
14
15
text
stringlengths
44
2.47k
source
stringlengths
61
181
d7845bf16de8-0
langchain.memory.chat_message_histories.file.FileChatMessageHistory¶ class langchain.memory.chat_message_histories.file.FileChatMessageHistory(file_path: str)[source]¶ Chat message history that stores history in a local file. Parameters file_path – path of the local file to store the messages. Attributes messages Retri...
https://api.python.langchain.com/en/latest/memory/langchain.memory.chat_message_histories.file.FileChatMessageHistory.html
8b0a7acffdf4-0
langchain.memory.chat_message_histories.sql.create_message_model¶ langchain.memory.chat_message_histories.sql.create_message_model(table_name, DynamicBase)[source]¶ Create a message model for a given table name. Parameters table_name – The name of the table to use. DynamicBase – The base class to use for the model. Ret...
https://api.python.langchain.com/en/latest/memory/langchain.memory.chat_message_histories.sql.create_message_model.html
e045541a928c-0
langchain.memory.chat_message_histories.sql.BaseMessageConverter¶ class langchain.memory.chat_message_histories.sql.BaseMessageConverter[source]¶ The class responsible for converting BaseMessage to your SQLAlchemy model. Methods __init__() from_sql_model(sql_message) Convert a SQLAlchemy model to a BaseMessage instance...
https://api.python.langchain.com/en/latest/memory/langchain.memory.chat_message_histories.sql.BaseMessageConverter.html
d6cb3a8f0fbf-0
langchain.chains.mapreduce.MapReduceChain¶ class langchain.chains.mapreduce.MapReduceChain[source]¶ Bases: Chain Map-reduce chain. 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 callback_manager: Opti...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-1
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 text_splitter: TextSplitter [Required]¶ Text splitter to use. param verbose: bool [Optional]¶ Whether or not run in verbose mode. In verbose mode, some intermediate logs...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-2
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, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation of abatch, whic...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-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 ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = N...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-4
these runtime tags will propagate to calls to other objects. **kwargs – If the chain expects multiple inputs, they can be passed in 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, I...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-5
step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subcla...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-6
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(**kwargs: Any) → Dict¶ Dictionary representation of chain. Expects Chain._chain_type property to be implemented and for memory to benull. Parameters **kwargs – Keyword arguments passed to defaul...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-7
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-8
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,...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-9
these runtime tags will propagate to calls to other objects. **kwargs – If the chain expects multiple inputs, they can be passed in directly as keyword arguments. Returns The chain output. Example # Suppose we have a single-input chain that takes a 'question' string: chain.run("What's the temperature in Boise, Idaho?")...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-10
Default implementation of transform, which buffers input and then calls stream. Subclasses should override this method if they can start producing output while input is still being generated. classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and lo...
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d6cb3a8f0fbf-11
Examples using MapReduceChain¶ Manifest LLM Caching integrations Set env var OPENAI_API_KEY or load from a .env file
https://api.python.langchain.com/en/latest/chains/langchain.chains.mapreduce.MapReduceChain.html
d74b871b4e22-0
langchain.chains.sequential.SequentialChain¶ class langchain.chains.sequential.SequentialChain[source]¶ Bases: Chain Chain where the outputs of one chain feed directly into next. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-1
These tags 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 chain with its use case. param verbose: bool [Optional]¶ Whether or not run in verbose mode. In verbose mode, some intermediate logs will be...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-2
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, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation of abatch, whic...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-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 ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = N...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-4
these runtime tags will propagate to calls to other objects. **kwargs – If the chain expects multiple inputs, they can be passed in 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, I...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-5
step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subcla...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-6
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(**kwargs: Any) → Dict¶ Dictionary representation of chain. Expects Chain._chain_type property to be implemented and for memory to benull. Parameters **kwargs – Keyword arguments passed to defaul...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-7
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-8
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-9
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
d74b871b4e22-10
Bind config to a Runnable, returning a new Runnable. with_fallbacks(fallbacks: ~typing.Sequence[~langchain.schema.runnable.base.Runnable[~langchain.schema.runnable.utils.Input, ~langchain.schema.runnable.utils.Output]], *, exceptions_to_handle: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,)) →...
https://api.python.langchain.com/en/latest/chains/langchain.chains.sequential.SequentialChain.html
1f9054d10214-0
langchain.chains.combine_documents.reduce.CombineDocsProtocol¶ class langchain.chains.combine_documents.reduce.CombineDocsProtocol(*args, **kwargs)[source]¶ Interface for the combine_docs method. Methods __init__(*args, **kwargs) __init__(*args, **kwargs)¶
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.reduce.CombineDocsProtocol.html
e5c43f1e9371-0
langchain.chains.qa_with_sources.loading.load_qa_with_sources_chain¶ langchain.chains.qa_with_sources.loading.load_qa_with_sources_chain(llm: BaseLanguageModel, chain_type: str = 'stuff', verbose: Optional[bool] = None, **kwargs: Any) → BaseCombineDocumentsChain[source]¶ Load a question answering with sources chain. Pa...
https://api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.loading.load_qa_with_sources_chain.html
6f1bff330900-0
langchain.chains.openai_functions.citation_fuzzy_match.FactWithEvidence¶ class langchain.chains.openai_functions.citation_fuzzy_match.FactWithEvidence[source]¶ Bases: BaseModel Class representing a single statement. Each fact has a body and a list of sources. If there are multiple facts make sure to break them apart su...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.citation_fuzzy_match.FactWithEvidence.html
6f1bff330900-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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.citation_fuzzy_match.FactWithEvidence.html
6f1bff330900-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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.citation_fuzzy_match.FactWithEvidence.html
ac2c855ae76a-0
langchain.chains.openai_functions.openapi.get_openapi_chain¶ langchain.chains.openai_functions.openapi.get_openapi_chain(spec: Union[OpenAPISpec, str], llm: Optional[BaseLanguageModel] = None, prompt: Optional[BasePromptTemplate] = None, request_chain: Optional[Chain] = None, llm_chain_kwargs: Optional[Dict] = None, ve...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.openapi.get_openapi_chain.html
cf6bdbc0364e-0
langchain.chains.openai_functions.utils.get_llm_kwargs¶ langchain.chains.openai_functions.utils.get_llm_kwargs(function: dict) → dict[source]¶ Returns the kwargs for the LLMChain constructor. Parameters function – The function to use. Returns The kwargs for the LLMChain constructor.
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.utils.get_llm_kwargs.html
fe74009a8a36-0
langchain.chains.query_constructor.ir.Expr¶ class langchain.chains.query_constructor.ir.Expr[source]¶ Bases: BaseModel Base class for all expressions. 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. accept(v...
https://api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.ir.Expr.html
fe74009a8a36-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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.ir.Expr.html
fe74009a8a36-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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.ir.Expr.html
7f69b23d5b02-0
langchain.chains.llm_bash.prompt.BashOutputParser¶ class langchain.chains.llm_bash.prompt.BashOutputParser[source]¶ Bases: BaseOutputParser Parser for bash output. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid mo...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-1
Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-2
Bind arguments to a Runnable, returning a new Runnable. 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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-3
namespace is [“langchain”, “llms”, “openai”] invoke(input: Union[str, BaseMessage], config: Optional[RunnableConfig] = None) → T¶ classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-4
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¶ parse_result(result: List[Generation], *, partial: bool = False) → T¶ Parse a list of candidate model Generations...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-5
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. Subclasses should override this method if they can start producing...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
7f69b23d5b02-6
For example,{“openai_api_key”: “OPENAI_API_KEY”} property output_schema: Type[pydantic.main.BaseModel]¶ Examples using BashOutputParser¶ Bash chain
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_bash.prompt.BashOutputParser.html
dc4fae3ae5df-0
langchain.chains.prompt_selector.is_llm¶ langchain.chains.prompt_selector.is_llm(llm: BaseLanguageModel) → bool[source]¶ Check if the language model is a LLM. Parameters llm – Language model to check. Returns True if the language model is a BaseLLM model, False otherwise.
https://api.python.langchain.com/en/latest/chains/langchain.chains.prompt_selector.is_llm.html
7ff421b52418-0
langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain¶ class langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain[source]¶ Bases: Chain Chain for interacting with Elasticsearch Database. Example from langchain.chains import ElasticsearchDatabaseChain from langchain.llms import OpenA...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-1
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-2
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 ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-3
Parameters inputs – Dictionary of 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. return_only_outputs – Whether to return only outputs in the response. If True, only new keys generated by this chai...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-4
Call the chain on all inputs in the list. 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¶ Convenience method for executing chain. The main difference between this ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-5
# -> "The temperature in Boise is..." async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. async astream_log(input: Any, conf...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-6
Subclasses should override this method if they can batch more efficiently. bind(**kwargs: Any) → Runnable[Input, Output]¶ Bind arguments to a Runnable, returning a new Runnable. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ fr...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-7
# -> {"_type": "foo", "verbose": False, ...} classmethod from_llm(llm: BaseLanguageModel, database: Elasticsearch, *, query_prompt: Optional[BasePromptTemplate] = None, answer_prompt: Optional[BasePromptTemplate] = None, query_output_parser: Optional[BaseLLMOutputParser] = None, **kwargs: Any) → ElasticsearchDatabaseCh...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-8
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-9
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,...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-10
these runtime tags will propagate to calls to other objects. **kwargs – If the chain expects multiple inputs, they can be passed in directly as keyword arguments. Returns The chain output. Example # Suppose we have a single-input chain that takes a 'question' string: chain.run("What's the temperature in Boise, Idaho?")...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-11
Default implementation of transform, which buffers input and then calls stream. Subclasses should override this method if they can start producing output while input is still being generated. classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and lo...
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
7ff421b52418-12
Examples using ElasticsearchDatabaseChain¶ Set env var OPENAI_API_KEY or load from a .env file Elasticsearch SQL
https://api.python.langchain.com/en/latest/chains/langchain.chains.elasticsearch_database.base.ElasticsearchDatabaseChain.html
463dac0c9e5a-0
langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain¶ class langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain[source]¶ Bases: Chain Chain that interprets a prompt and executes python code to do symbolic math. Example from langchain.chains import LLMSymbolicMathChain from langchain.llms import OpenAI ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-1
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 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, and pass...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-2
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 chain. Defaults to None include_run_info – Whether to include run ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-3
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-4
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-5
Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-6
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-7
# -> {"_type": "foo", "verbose": False, ...} classmethod from_llm(llm: BaseLanguageModel, prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], template='Translate a math problem into a expression that can be executed using Python\'s SymPy library. Use the output of running this code to answer the q...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-8
classmethod from_orm(obj: Any) → Model¶ classmethod get_lc_namespace() → List[str]¶ Get the namespace of the langchain object. For example, if the class is langchain.llms.openai.OpenAI, then the namespace is [“langchain”, “llms”, “openai”] invoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs:...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-9
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¶ prep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶ Validate and prepare chain inputs, including ad...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-10
sole positional argument. 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 additi...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-11
Default implementation of stream, which calls invoke. 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] = No...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
463dac0c9e5a-12
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_schema: T...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_symbolic_math.base.LLMSymbolicMathChain.html
af54db5a09b7-0
langchain.chains.llm_requests.LLMRequestsChain¶ class langchain.chains.llm_requests.LLMRequestsChain[source]¶ Bases: Chain Chain that requests a URL and then uses an LLM to parse results. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be p...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-1
These tags 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 chain with its use case. param text_length: int = 8000¶ param verbose: bool [Optional]¶ Whether or not run in verbose mode. In verbose mode,...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-2
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, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwar...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-3
these runtime tags will propagate to calls to other objects. 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 ainvok...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-4
these runtime tags will propagate to calls to other objects. **kwargs – If the chain expects multiple inputs, they can be passed in 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, I...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-5
step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subcla...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-6
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(**kwargs: Any) → Dict¶ Dictionary representation of chain. Expects Chain._chain_type property to be implemented and for memory to benull. Parameters **kwargs – Keyword arguments passed to defaul...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-7
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-8
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-9
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
af54db5a09b7-10
Bind config to a Runnable, returning a new Runnable. with_fallbacks(fallbacks: ~typing.Sequence[~langchain.schema.runnable.base.Runnable[~langchain.schema.runnable.utils.Input, ~langchain.schema.runnable.utils.Output]], *, exceptions_to_handle: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,)) →...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_requests.LLMRequestsChain.html
2b8b83009517-0
langchain.chains.moderation.OpenAIModerationChain¶ class langchain.chains.moderation.OpenAIModerationChain[source]¶ Bases: Chain Pass input through a moderation endpoint. To use, you should have the openai python package installed, and the environment variable OPENAI_API_KEY set with your API key. Any parameters that a...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-1
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 chain with its use case. param model_name: Optional[str] = None¶ Moderation model name to use. param openai_api_key: Optional[str] = None...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-2
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. tags – List of string tags to pass to all callbacks. These will be...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-3
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 – Callbacks to use for this chain run. These will be called in addition to callbacks passed to the chain during construction, but only ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-4
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 the sole positional argument. callbacks – Callbacks to use for this chain run. These will be called in addition to callbacks passed to the chain ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-5
Subclasses should override this method if they support streaming output. async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-6
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 copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclu...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-7
namespace is [“langchain”, “llms”, “openai”] invoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶ classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-8
prep_inputs(inputs: Union[Dict[str, Any], Any]) → Dict[str, str]¶ Validate and prepare chain inputs, including adding inputs from memory. 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 ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-9
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. **kwargs – If the chain expects multiple inputs, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-10
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
2b8b83009517-11
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]¶ Examples using OpenAIModerationChain¶ OpenAI Adding moderation
https://api.python.langchain.com/en/latest/chains/langchain.chains.moderation.OpenAIModerationChain.html
408ec4da345f-0
langchain.chains.combine_documents.base.AnalyzeDocumentChain¶ class langchain.chains.combine_documents.base.AnalyzeDocumentChain[source]¶ Bases: Chain Chain that splits documents, then analyzes it in pieces. This chain is parameterized by a TextSplitter and a CombineDocumentsChain. This chain takes a single document as...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-1
You can use these to eg identify a specific instance of a chain with its use case. 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, and passed as arguments to the handlers defined in callbacks. You can ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-2
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 chain. Defaults to None include_run_info – Whether to include run ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-3
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-4
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-5
Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html
408ec4da345f-6
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html