id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
49d14c486324-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/chains/langchain.chains.graph_qa.cypher.GraphCypherQAChain.html
49d14c486324-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/chains/langchain.chains.graph_qa.cypher.GraphCypherQAChain.html
49d14c486324-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/chains/langchain.chains.graph_qa.cypher.GraphCypherQAChain.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-2
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 ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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 ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-6
Default implementation runs invoke in parallel using a thread pool executor. 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. bind(**kwargs: Any) → R...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-7
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/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-8
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/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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,...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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?")...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-13
added to the run. 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]¶ Create a new Runnable that retries the original runnable on exceptions. Parameters retry_if_exc...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
1cacc2bd76c1-14
property output_schema: Type[pydantic.main.BaseModel]¶ The type of output this runnable produces specified as a pydantic model. Examples using RetrievalQA¶ Cohere Reranker Ollama Confident Document Comparison ScaNN Activeloop Deep Lake StarRocks your local model path Loading documents from a YouTube url Docugami Questi...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html
4712a26c9569-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.
lang/api.python.langchain.com/en/latest/chains/langchain.chains.prompt_selector.is_llm.html
db3902f76c0a-0
langchain.chains.graph_qa.cypher_utils.Schema¶ class langchain.chains.graph_qa.cypher_utils.Schema(left_node, relation, right_node)¶ Create new instance of Schema(left_node, relation, right_node) Attributes left_node Alias for field number 0 relation Alias for field number 1 right_node Alias for field number 2 Methods ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.graph_qa.cypher_utils.Schema.html
2a219f70acc9-0
langchain.chains.qa_with_sources.base.QAWithSourcesChain¶ class langchain.chains.qa_with_sources.base.QAWithSourcesChain[source]¶ Bases: BaseQAWithSourcesChain Question answering with sources over documents. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the in...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-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, ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-3
these runtime callbacks will propagate to calls to other objects. tags – List of string tags to pass to all callbacks. These will be passed in addition to tags passed to the chain during construction, but only these runtime tags will propagate to calls to other objects. metadata – Optional metadata associated with the ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-4
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/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-5
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/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-6
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/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-7
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/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-8
classmethod from_llm(llm: BaseLanguageModel, document_prompt: BasePromptTemplate = PromptTemplate(input_variables=['page_content', 'source'], template='Content: {page_content}\nSource: {source}'), question_prompt: BasePromptTemplate = PromptTemplate(input_variables=['context', 'question'], template='Use the following p...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-9
Agreement.\n\n11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any  kind between the parties.\n\n11.9 No Third-Party Beneficiaries.\nSource: 30-pl\nContent: (b) if Google believes, in good faith, that the Distributor has violated or ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-10
tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.\nSource: 0-pl\nContent: And we won’t stop. \n\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \n\nLet’s use this moment to reset. Let’s stop looking at COVID-1...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-11
world. \n\nAnd I’m taking robust action to make sure the pain of our sanctions  is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \n\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-12
of resolve and conscience, of history itself. \n\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \n\nWell I know this nation.\nSource: 34-pl\n=========\nFINAL ANSWER: The president did not mention Michael Jackson.\nSOURCES:\n\nQUESTION: {question}\n=========\n{summaries}\...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-13
Construct the chain from an LLM. classmethod from_orm(obj: Any) → Model¶ 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 the configurable_fields and configurable_alternatives methods will have a...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-14
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¶ Is this class serializable?...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-15
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-16
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-17
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-18
on_start: Called before the runnable starts running, with the Run object. 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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
2a219f70acc9-19
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.qa_with_sources.base.QAWithSourcesChain.html
33771474f6eb-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. Security Note: This API chain uses the requests toolkitto make GET, POST, PATCH, PUT, and DELETE requests to an API. Exercise care in who is al...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-1
The default value is an empty tuple, which means that no domains are allowed by default. By design this will raise an error on instantiation. Use a None if you want to allow all domains by default – this is not recommended for security reasons, as it would allow malicious users to make requests to arbitrary URLS includ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-2
accessible via langchain.globals.get_verbose(). __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: Optional[str] = Non...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-3
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 acall(inputs: Union[Dict...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-4
Returns A dict of named outputs. Should contain all outputs specified inChain.output_keys. async ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶ Default implementation of ainvoke, calls invoke from a thread. The default implementation allows usage of async code e...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-5
directly as keyword arguments. Returns The chain output. Example # Suppose we have a single-input chain that takes a 'question' string: await chain.arun("What's the temperature in Boise, Idaho?") # -> "The temperature in Boise is..." # Suppose we have a multi-input chain that takes a 'question' string # and 'context' s...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-6
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/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-7
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/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-8
# -> {"_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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-9
Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic input schema that depends on which configuration the runnable is invoked with. This method allows to get an input schema for a specific confi...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-10
for more details. Returns The output of the runnable. 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[b...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-11
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 set by the chain’s memory. Returns A dictionary of all inputs, inc...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-12
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-13
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-14
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], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_af...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
33771474f6eb-15
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 APIChain¶ Set env var OPENAI_API_KEY or load from a .env file:
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html
f2ec6844bed4-0
langchain.chains.openai_functions.tagging.create_tagging_chain¶ langchain.chains.openai_functions.tagging.create_tagging_chain(schema: dict, llm: BaseLanguageModel, prompt: Optional[ChatPromptTemplate] = None, **kwargs: Any) → Chain[source]¶ Creates a chain that extracts information from a passagebased on a schema. Par...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.tagging.create_tagging_chain.html
1b2c409dcba2-0
langchain.chains.graph_qa.neptune_cypher.use_simple_prompt¶ langchain.chains.graph_qa.neptune_cypher.use_simple_prompt(llm: BaseLanguageModel) → bool[source]¶ Decides whether to use the simple prompt
lang/api.python.langchain.com/en/latest/chains/langchain.chains.graph_qa.neptune_cypher.use_simple_prompt.html
ebc5e140de6b-0
langchain.chains.api.openapi.response_chain.APIResponderOutputParser¶ class langchain.chains.api.openapi.response_chain.APIResponderOutputParser[source]¶ Bases: BaseOutputParser Parse the response and error tags. async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-1
to be different candidate outputs for a single model input. Returns Structured output. 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 str...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-2
Default implementation runs invoke in parallel using a thread pool executor. 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. bind(**kwargs: Any) → R...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-3
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/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-4
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 schema. Returns A pydantic model that can be used to validate output. invoke(input:...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-5
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. parse(llm_output: str) → str[source]¶ Parse the response and error tags. classmethod ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-6
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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-7
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
ebc5e140de6b-8
The type of output this runnable produces specified as a type annotation. property config_specs: List[langchain.schema.runnable.utils.ConfigurableFieldSpec]¶ List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.api.openapi.response_chain.APIResponderOutputParser.html
5d133586bda1-0
langchain.chains.query_constructor.base.construct_examples¶ langchain.chains.query_constructor.base.construct_examples(input_output_pairs: Sequence[Tuple[str, dict]]) → List[dict][source]¶ Construct examples from input-output pairs. Parameters input_output_pairs – Sequence of input-output pairs. Returns List of example...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.base.construct_examples.html
4e4c49c0d077-0
langchain.chains.query_constructor.ir.FilterDirective¶ class langchain.chains.query_constructor.ir.FilterDirective[source]¶ Bases: Expr, ABC A filtering expression. 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 m...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.query_constructor.ir.FilterDirective.html
4e4c49c0d077-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/chains/langchain.chains.query_constructor.ir.FilterDirective.html
4e4c49c0d077-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/chains/langchain.chains.query_constructor.ir.FilterDirective.html
46835656825e-0
langchain.chains.openai_functions.citation_fuzzy_match.create_citation_fuzzy_match_chain¶ langchain.chains.openai_functions.citation_fuzzy_match.create_citation_fuzzy_match_chain(llm: BaseLanguageModel) → LLMChain[source]¶ Create a citation fuzzy match chain. Parameters llm – Language model to use for the chain. Return...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.citation_fuzzy_match.create_citation_fuzzy_match_chain.html
f97c36ff59b4-0
langchain.chains.llm.LLMChain¶ class langchain.chains.llm.LLMChain[source]¶ Bases: Chain Chain to run queries against LLMs. Example from langchain.chains import LLMChain from langchain.llms import OpenAI from langchain.prompts import PromptTemplate prompt_template = "Tell me a {adjective} joke" prompt = PromptTemplate(...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-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...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-2
Execute the chain. 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 gen...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-3
Call apply and then parse the results. async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation runs ainvoke in parallel using asyncio.gather. The default implementation of ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-4
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 agener...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-5
Completion from LLM. Example completion = llm.predict(adjective="funny") async apredict_and_parse(callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → Union[str, List[str], Dict[str, str]][source]¶ Call apredict and then parse the results. async aprep_prompts(input_list: L...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-6
Example # Suppose we have a single-input chain that takes a 'question' string: await chain.arun("What's the temperature in Boise, Idaho?") # -> "The temperature in Boise is..." # Suppose we have a multi-input chain that takes a 'question' string # and 'context' string: question = "What's the temperature in Boise, Idaho...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-7
The jsonpatch ops can be applied in order to construct state. async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of atransform, which buffers input and calls astream. Subclasses should override this method if th...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-8
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-9
Create LLMChain from LLM and template. generate(input_list: List[Dict[str, Any]], run_manager: Optional[CallbackManagerForChainRun] = None) → LLMResult[source]¶ Generate LLM result from inputs. get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be used to validate...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-10
Parameters input – The input to the runnable. 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. Retur...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-11
classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ predict(callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → str[s...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-12
inputs are also added to the final outputs. Returns A dict of the final chain outputs. prep_prompts(input_list: List[Dict[str, Any]], run_manager: Optional[CallbackManagerForChainRun] = None) → Tuple[List[PromptValue], Optional[List[str]]][source]¶ Prepare prompts from inputs. run(*args: Any, callbacks: Optional[Union[...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-13
# 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 is..." save(file_path: Union[Path, str]) → None¶ Save the chain. Expects Chain._chain_type property to be i...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-14
Bind config to a Runnable, returning a new Runnable. with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,)) → RunnableWithFallbacksT[Input, Output]¶ Add fallbacks to a runnable, returning a new Runnable. Parameters fallbacks – A se...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-15
between retries stop_after_attempt – The maximum number of attempts to make before giving up Returns A new Runnable that retries the original runnable on exceptions. with_types(*, input_type: Optional[Type[Input]] = None, output_type: Optional[Type[Output]] = None) → Runnable[Input, Output]¶ Bind input and output types...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
f97c36ff59b4-16
Predibase Eden AI Azure ML Removing logical fallacies from model output Amazon Comprehend Moderation Chain Custom Trajectory Evaluator Custom Pairwise Evaluator Set env var OPENAI_API_KEY or load from a .env file: Set env var OPENAI_API_KEY or load from a .env file Retrieve from vector stores directly Improve document ...
lang/api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html
2b5407e0f812-0
langchain.vectorstores.rocksetdb.Rockset¶ class langchain.vectorstores.rocksetdb.Rockset(client: Any, embeddings: Embeddings, collection_name: str, text_key: str, embedding_key: str, workspace: str = 'commons')[source]¶ Rockset vector store. To use, you should have the rockset python package installed. Note that to use...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-1
Attributes embeddings Access the query embedding object if available. Methods __init__(client, embeddings, ...[, workspace]) Initialize with Rockset client. :param client: Rockset client object :param collection: Rockset collection to insert docs / query :param embeddings: Langchain Embeddings object to use to generate...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-2
Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-3
similarity_search_with_score(*args, **kwargs) Run similarity search with distance. __init__(client: Any, embeddings: Embeddings, collection_name: str, text_key: str, embedding_key: str, workspace: str = 'commons')[source]¶ Initialize with Rockset client. :param client: Rockset client object :param collection: Rockset c...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-4
Run more texts through the embeddings and add to the vectorstore Args: texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. ids: Optional list of ids to associate with the texts. batch_size: Send documents in batches to rockset. Returns List of ids from ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-5
as_retriever(**kwargs: Any) → VectorStoreRetriever¶ Return VectorStoreRetriever initialized from this VectorStore. Parameters search_type (Optional[str]) – Defines the type of search that the Retriever should perform. Can be “similarity” (default), “mmr”, or “similarity_score_threshold”. search_kwargs (Optional[Dict]) ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-6
docsearch.as_retriever(search_kwargs={'k': 1}) # Use a filter to only retrieve documents from a specific paper docsearch.as_retriever( search_kwargs={'filter': {'paper_title':'GPT-4 Technical Report'}} ) async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query u...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-7
**kwargs – Other keyword arguments that subclasses might use. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] delete_texts(ids: List[str]) → None[source]¶ Delete a list of docs from the Rockset collection classmethod from_documents(documents: List[Document], ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-8
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevan...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
2b5407e0f812-9
Accepts a query_embedding (vector), and returns documents with similar embeddings. similarity_search_by_vector_with_relevance_scores(embedding: List[float], k: int = 4, distance_func: DistanceFunction = DistanceFunction.COSINE_SIM, where_str: Optional[str] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
1410f7059d9e-0
langchain.vectorstores.azure_cosmos_db.CosmosDBSimilarityType¶ class langchain.vectorstores.azure_cosmos_db.CosmosDBSimilarityType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Cosmos DB Similarity Type as enumerator. COS = 'COS'¶ CosineSimilarity IP = 'IP'¶ inner - produ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.azure_cosmos_db.CosmosDBSimilarityType.html