id
stringlengths
14
15
text
stringlengths
44
2.47k
source
stringlengths
61
181
7f5324a2f984-0
langchain.chains.flare.base.QuestionGeneratorChain¶ class langchain.chains.flare.base.QuestionGeneratorChain[source]¶ Bases: LLMChain Chain that generates questions from uncertain spans. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be pa...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-1
Defaults to one that takes the most likely string but does not change it otherwise. param prompt: BasePromptTemplate = PromptTemplate(input_variables=['user_input', 'current_response', 'uncertain_span'], template='Given a user input and an existing partial response as context, ask a question to which the answer is the ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-2
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-3
Default implementation of abatch, which calls ainvoke N times. Subclasses should override this method if they can batch more efficiently. async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optiona...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-4
Generate LLM result from inputs. async ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶ Default implementation of ainvoke, which calls invoke in a thread pool. Subclasses should override this method if they can run asynchronously. apply(input_list: List[Dict[str, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-5
Prepare prompts from inputs. 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 method and Ch...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-6
# -> "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.flare.base.QuestionGeneratorChain.html
7f5324a2f984-7
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.flare.base.QuestionGeneratorChain.html
7f5324a2f984-8
# -> {"_type": "foo", "verbose": False, ...} classmethod from_orm(obj: Any) → Model¶ classmethod from_string(llm: BaseLanguageModel, template: str) → LLMChain¶ Create LLMChain from LLM and template. generate(input_list: List[Dict[str, Any]], run_manager: Optional[CallbackManagerForChainRun] = None) → LLMResult¶ Generat...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-9
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(path: Union[str, Path], *, content_type: unicode = None, encod...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-10
Returns A dictionary of all inputs, including those added by the chain’s memory. prep_outputs(inputs: Dict[str, str], outputs: Dict[str, str], return_only_outputs: bool = False) → Dict[str, str]¶ Validate and prepare chain outputs, and save info about this run to memory. Parameters inputs – Dictionary of chain inputs, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
7f5324a2f984-11
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.flare.base.QuestionGeneratorChain.html
7f5324a2f984-12
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.flare.base.QuestionGeneratorChain.html
7f5324a2f984-13
For example,{“openai_api_key”: “OPENAI_API_KEY”} property output_schema: Type[pydantic.main.BaseModel]¶
https://api.python.langchain.com/en/latest/chains/langchain.chains.flare.base.QuestionGeneratorChain.html
a80939ad114f-0
langchain.chains.openai_functions.base.convert_to_openai_function¶ langchain.chains.openai_functions.base.convert_to_openai_function(function: Union[Dict[str, Any], Type[BaseModel], Callable]) → Dict[str, Any][source]¶ Convert a raw function/class to an OpenAI function. Parameters function – Either a dictionary, a pyda...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.base.convert_to_openai_function.html
3b05ee7de738-0
langchain.chains.query_constructor.ir.Comparison¶ class langchain.chains.query_constructor.ir.Comparison[source]¶ Bases: FilterDirective A comparison to a 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 mode...
https://api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.ir.Comparison.html
3b05ee7de738-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.Comparison.html
3b05ee7de738-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.Comparison.html
a065a1b93d74-0
langchain.chains.api.openapi.chain.OpenAPIEndpointChain¶ class langchain.chains.api.openapi.chain.OpenAPIEndpointChain[source]¶ Bases: Chain, BaseModel Chain interacts with an OpenAPI endpoint using natural language. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-1
param requests: Requests [Optional]¶ param return_intermediate_steps: bool = False¶ 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.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-2
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 info in the response. Defaults to False. Returns A dict of named outputs. Sho...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-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 ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-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. **kwargs – If the chain expects multiple inputs, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-5
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-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.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-7
Create an OpenAPIEndpoint from a spec at the specified url. 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[RunnableConfi...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-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¶ 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.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-9
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.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-10
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.api.openapi.chain.OpenAPIEndpointChain.html
a065a1b93d74-11
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.api.openapi.chain.OpenAPIEndpointChain.html
71cfd83ee931-0
langchain.chains.combine_documents.stuff.StuffDocumentsChain¶ class langchain.chains.combine_documents.stuff.StuffDocumentsChain[source]¶ Bases: BaseCombineDocumentsChain Chain that combines documents by stuffing into context. This chain takes a list of documents and first combines them into a single string. It does th...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-1
Optional list of callback handlers (or callback manager). Defaults to None. Callback handlers are called throughout the lifecycle of a call to a chain, starting with on_chain_start, ending with on_chain_end or on_chain_error. Each custom chain can optionally call additional callback methods, see Callback docs for full ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-2
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.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-3
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.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-4
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 acombine_docs(docs: List[Document], callbacks: Optional[Union[List[...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-5
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 during construction, but only these runtime callbacks will propagate to call...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-6
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.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-7
Bind arguments to a Runnable, returning a new Runnable. combine_docs(docs: List[Document], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Tuple[str, dict][source]¶ Stuff all documents into one prompt and pass to LLM. Parameters docs – List of documents to join togeth...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-8
Expects Chain._chain_type property to be implemented and for memory to benull. Parameters **kwargs – Keyword arguments passed to default pydantic.BaseModel.dict method. Returns A dictionary representation of the chain. Example chain.dict(exclude_unset=True) # -> {"_type": "foo", "verbose": False, ...} classmethod from_...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-9
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(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool =...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-10
This can be used by a caller to determine whether passing in a list of documents would exceed a certain prompt length. This useful when trying to ensure that the size of a prompt remains below a certain context limit. Parameters docs – List[Document], a list of documents to use to calculate the total prompt length. Ret...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-11
# -> "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..." chain.run(question=question, context=context) # -> "The temperature in Boise ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
71cfd83ee931-12
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: ~typing.Sequence[~langchain.schema.runnable.base.Runnable[~langchain.schema.runnable.utils.Input, ~langc...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.stuff.StuffDocumentsChain.html
d4b19852829b-0
langchain.chains.openai_functions.extraction.create_extraction_chain¶ langchain.chains.openai_functions.extraction.create_extraction_chain(schema: dict, llm: BaseLanguageModel, prompt: Optional[BasePromptTemplate] = None, verbose: bool = False) → Chain[source]¶ Creates a chain that extracts information from a passage. ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.extraction.create_extraction_chain.html
ccfa1b7271ed-0
langchain.chains.retrieval_qa.base.RetrievalQA¶ class langchain.chains.retrieval_qa.base.RetrievalQA[source]¶ Bases: BaseRetrievalQA Chain for question-answering against an index. Example from langchain.llms import OpenAI from langchain.chains import RetrievalQA from langchain.vectorstores import FAISS from langchain.s...
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-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.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-2
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....
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-3
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 – Callbacks to use for this chain run. These will be called in addi...
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-4
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 the sole positional argument. callbacks – Callbacks to use for this cha...
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-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.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-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.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-7
Load chain from chain type. classmethod from_llm(llm: BaseLanguageModel, prompt: Optional[PromptTemplate] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → BaseRetrievalQA¶ Initialize from LLM. classmethod from_orm(obj: Any) → Model¶ classmethod get_lc_namespace...
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-8
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(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool =...
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-9
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.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-10
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.retrieval_qa.base.RetrievalQA.html
ccfa1b7271ed-11
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.retrieval_qa.base.RetrievalQA.html
2be0049b3c5c-0
langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain¶ class langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain[source]¶ Bases: BaseCombineDocumentsChain Combining documents by mapping a chain over them, then combining results. We first call llm_chain on each document individually, pa...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-1
document_variable_name=document_variable_name ) reduce_documents_chain = ReduceDocumentsChain( combine_documents_chain=combine_documents_chain, ) chain = MapReduceDocumentsChain( llm_chain=llm_chain, reduce_documents_chain=reduce_documents_chain, ) # If we wanted to, we could also pass in collapse_documents...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-2
If only one variable in the llm_chain, this need not be provided. param llm_chain: LLMChain [Required]¶ Chain to apply to each document individually. param memory: Optional[BaseMemory] = None¶ Optional memory object. Defaults to None. Memory is a class that gets called at the start and at the end of every chain. At the...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-3
will be printed to the console. Defaults to langchain.verbose value. __call__(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, run_name...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-4
Default implementation of abatch, which calls ainvoke N times. Subclasses should override this method if they can batch more efficiently. async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optiona...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-5
Returns A dict of named outputs. Should contain all outputs specified inChain.output_keys. async acombine_docs(docs: List[Document], token_max: Optional[int] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Tuple[str, dict][source]¶ Combine documents in a map r...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-6
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.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-7
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.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-9
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.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-10
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.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-11
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 the sole positional argument. callbacks – Callbacks to use for this cha...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-12
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → Iterator[Output]¶ Default implementation of stream, which calls invoke. Subclasses should override t...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
2be0049b3c5c-13
property InputType: Type[langchain.schema.runnable.utils.Input]¶ property OutputType: Type[langchain.schema.runnable.utils.Output]¶ property collapse_document_chain: langchain.chains.combine_documents.base.BaseCombineDocumentsChain¶ Kept for backward compatibility. property combine_document_chain: langchain.chains.comb...
https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.map_reduce.MapReduceDocumentsChain.html
e1165348e26e-0
langchain.chains.api.base.APIChain¶ class langchain.chains.api.base.APIChain[source]¶ Bases: Chain Chain that makes API calls and summarizes the responses to answer a question. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to fo...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-1
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 use these to eg identify a specific instance of a chain with its use case. param verbose: bool [Optional]¶ Whether or not r...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-2
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, ...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-3
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 info in the response. Defaults to False. Returns A dict of named outputs. Sho...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-4
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, they can be passed in directly as keyword arguments. Returns The chain output. Example # Suppose we have a single-input chain that takes a 'que...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-5
jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default im...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-6
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-7
# -> {"_type": "foo", "verbose": False, ...} classmethod from_llm_and_api_docs(llm: BaseLanguageModel, api_docs: str, headers: Optional[dict] = None, api_url_prompt: BasePromptTemplate = PromptTemplate(input_variables=['api_docs', 'question'], template='You are given the below API Documentation:\n{api_docs}\nUsing this...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-8
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: Any) → Dict[str, Any]¶ classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[Ab...
https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
e1165348e26e-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.api.base.APIChain.html
e1165348e26e-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.api.base.APIChain.html
e1165348e26e-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.api.base.APIChain.html
e1165348e26e-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.api.base.APIChain.html
78d109139b04-0
langchain.chains.query_constructor.base.load_query_constructor_chain¶ langchain.chains.query_constructor.base.load_query_constructor_chain(llm: BaseLanguageModel, document_contents: str, attribute_info: List[AttributeInfo], examples: Optional[List] = None, allowed_comparators: Optional[Sequence[Comparator]] = None, all...
https://api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.base.load_query_constructor_chain.html
8a1b0918229b-0
langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain¶ class langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain[source]¶ Bases: Chain Chain for chatting with an index. Create a new model by parsing and validating input data from keyword arguments. Raises Validation...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-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 output_key: str = 'answer'¶ The output key to return the final answer of this chain in. param question_generator: LLMChain [Required]¶ The chain used to generate a new q...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-2
will be printed to the console. Defaults to langchain.verbose value. __call__(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, run_name...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-3
Default implementation of abatch, which calls ainvoke N times. Subclasses should override this method if they can batch more efficiently. async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optiona...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-4
Default implementation of ainvoke, which calls invoke in a thread pool. Subclasses should override this method if they can run asynchronously. apply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None) → List[Dict[str, str]]¶ Call the chain on all inputs i...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-5
# 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 Boise is..." async astream(input: Inp...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-6
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 of batch, which calls invoke N times. Subclasses should override this method if they can ba...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-7
**kwargs – Keyword arguments passed to default pydantic.BaseModel.dict method. Returns A dictionary representation of the chain. Example chain.dict(exclude_unset=True) # -> {"_type": "foo", "verbose": False, ...} classmethod from_orm(obj: Any) → Model¶ classmethod get_lc_namespace() → List[str]¶ Get the namespace of th...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-8
by calling invoke() with each input. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = No...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-9
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...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-10
Example chain.save(file_path="path/chain.yaml") 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(input: Input, config: Optiona...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
8a1b0918229b-11
with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[Input, Output]¶ property InputType: Type[langchain.schema.runnable.utils.Input]¶ property OutputType: Type[langchain.schema.runna...
https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.BaseConversationalRetrievalChain.html
239b4255fba3-0
langchain.chains.graph_qa.neptune_cypher.trim_query¶ langchain.chains.graph_qa.neptune_cypher.trim_query(query: str) → str[source]¶
https://api.python.langchain.com/en/latest/chains/langchain.chains.graph_qa.neptune_cypher.trim_query.html
1f4f98d30849-0
langchain.chains.router.base.Route¶ class langchain.chains.router.base.Route(destination, next_inputs)[source]¶ Create new instance of Route(destination, next_inputs) Attributes destination Alias for field number 0 next_inputs Alias for field number 1 Methods __init__() count(value, /) Return number of occurrences of v...
https://api.python.langchain.com/en/latest/chains/langchain.chains.router.base.Route.html
9e480a97a0eb-0
langchain.chains.graph_qa.neptune_cypher.extract_cypher¶ langchain.chains.graph_qa.neptune_cypher.extract_cypher(text: str) → str[source]¶ Extract Cypher code from text using Regex.
https://api.python.langchain.com/en/latest/chains/langchain.chains.graph_qa.neptune_cypher.extract_cypher.html
008c0a61b64c-0
langchain.chains.llm_summarization_checker.base.LLMSummarizationCheckerChain¶ class langchain.chains.llm_summarization_checker.base.LLMSummarizationCheckerChain[source]¶ Bases: Chain Chain for question-answering with self-verification. Example from langchain.llms import OpenAI from langchain.chains import LLMSummarizat...
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_summarization_checker.base.LLMSummarizationCheckerChain.html