id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
49e6530c07c2-64
protocol="http", typesense_collection_name="langchain-memory", ) classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, typesense_client: Optional[Client] = None, typesense_client_params: Optional[dict] = None, typesense_collection_na...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-65
Implementation of Vector Store using Vectara (https://vectara.com). .. rubric:: Example from langchain.vectorstores import Vectara vectorstore = Vectara( vectara_customer_id=vectara_customer_id, vectara_corpus_id=vectara_corpus_id, vectara_api_key=vectara_api_key ) add_texts(texts: Iterable[str], metadatas:...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-66
Return Vectara documents most similar to query, along with scores. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 5. filter – Dictionary of argument(s) to filter on metadata. For example a filter can be “doc.rating > 3.0 and part.lang = ‘deu’”} see https://docs.v...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-67
Returns List of IDs of the added texts. Return type List[str] async aadd_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str][source]# Run more texts through the embeddings and add to the vectorstore. add_documents(documents: List[langchain.schema.Document], **kwargs: Any) → Li...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-68
Return VectorStore initialized from texts and embeddings. async amax_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. async amax_marginal_relevance_search_by...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-69
Return VectorStore initialized from documents and embeddings. abstract classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → langchain.vectorstores.base.VST[source]# Return VectorStore initialized from texts and embeddings. max...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-70
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[langchain.sch...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-71
Returns List of Tuples of (doc, similarity_score) class langchain.vectorstores.Weaviate(client: typing.Any, index_name: str, text_key: str, embedding: typing.Optional[langchain.embeddings.base.Embeddings] = None, attributes: typing.Optional[typing.List[str]] = None, relevance_score_fn: typing.Optional[typing.Callable[[...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-72
weaviate = Weaviate.from_texts( texts, embeddings, weaviate_url="http://localhost:8080" ) max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Ma...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-73
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]# Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults t...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
49e6530c07c2-74
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {}, consistency_level: str = 'Session', index_params: Optional[dict] = None, search_params: Optional[dict] = N...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
d2640a611e9c-0
.rst .pdf Document Compressors Document Compressors# pydantic model langchain.retrievers.document_compressors.CohereRerank[source]# field client: Client [Required]# field model: str = 'rerank-english-v2.0'# field top_n: int = 3# async acompress_documents(documents: Sequence[langchain.schema.Document], query: str) → Seq...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
d2640a611e9c-1
similarity_threshold must be specified. Defaults to 20. field similarity_fn: Callable = <function cosine_similarity># Similarity function for comparing documents. Function expected to take as input two matrices (List[List[float]]) and return a matrix of scores where higher values indicate greater similarity. field simi...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
d2640a611e9c-2
Compress page content of raw documents. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: Optional[langchain.prompts.prompt.PromptTemplate] = None, get_input: Optional[Callable[[str, langchain.schema.Document], str]] = None, llm_chain_kwargs: Optional[dict] = None) → langchain.retrievers.docu...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
9da52769f9ad-0
.rst .pdf Retrievers Retrievers# pydantic model langchain.retrievers.ArxivRetriever[source]# It is effectively a wrapper for ArxivAPIWrapper. It wraps load() to get_relevant_documents(). It uses all ArxivAPIWrapper arguments without any change. async aget_relevant_documents(query: str) → List[langchain.schema.Document]...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-1
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.ChatGPTPluginRetriever[source]# field aiosession: Optional[aiohttp.client.Clie...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-2
Get documents relevant for a query. Parameters query – string to find relevant documents for Returns Sequence of relevant documents class langchain.retrievers.DataberryRetriever(datastore_url: str, top_k: Optional[int] = None, api_key: Optional[str] = None)[source]# async aget_relevant_documents(query: str) → List[lang...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-3
Locate the “elastic” user and click “Edit” Click “Reset password” Follow the prompts to reset the password The format for Elastic Cloud URLs is https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243. add_texts(texts: Iterable[str], refresh_indices: bool = True) → List[str][source]# Run more texts through t...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-4
Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents classmethod from_texts(texts: List[str], embeddings: langchain.embeddings.base.Embeddings, **kwargs: Any) → langchain.retrievers.knn.KNNRetriever[source]# get_relevant_documents(query: str) → ...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-5
Parameters query – string to find relevant documents for Returns List of relevant documents get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langcha...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-6
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.SelfQueryRetriever[source]# Retriever that wraps around a vector store and use...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-7
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.TFIDFRetriever[source]# field docs: List[langchain.schema.Document] [Required]...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-8
field default_salience: Optional[float] = None# The salience to assign memories not retrieved from the vector store. None assigns no salience to documents not fetched from the vector store. field k: int = 4# The maximum number of documents to retrieve in a given call. field memory_stream: List[langchain.schema.Document...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-9
Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents classmethod from_params(url: str, content_field: str, *, k: Optional[int] = None, metadata_fields: Union[Sequence[str], Literal['*']] = (), sources: Optional[Union[Sequence[str], Literal['*']]...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-10
class langchain.retrievers.WeaviateHybridSearchRetriever(client: Any, index_name: str, text_key: str, alpha: float = 0.5, k: int = 4, attributes: Optional[List[str]] = None, create_schema_if_missing: bool = True)[source]# class Config[source]# Configuration for this pydantic object. arbitrary_types_allowed = True# extr...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
9da52769f9ad-11
Parameters query – string to find relevant documents for Returns List of relevant documents class langchain.retrievers.ZepRetriever(session_id: str, url: str, top_k: Optional[int] = None)[source]# A Retriever implementation for the Zep long-term memory store. Search your user’s long-term chat history with Zep. Note: Yo...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
64501377c10a-0
.rst .pdf Docstore Docstore# Wrappers on top of docstores. class langchain.docstore.InMemoryDocstore(_dict: Dict[str, langchain.schema.Document])[source]# Simple in memory docstore in the form of a dict. add(texts: Dict[str, langchain.schema.Document]) → None[source]# Add texts to in memory dictionary. search(search: s...
https://python.langchain.com/en/latest/reference/modules/docstore.html
a29412f9f23c-0
.rst .pdf PromptTemplates PromptTemplates# Prompt template classes. pydantic model langchain.prompts.BaseChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt....
https://python.langchain.com/en/latest/reference/modules/prompts.html
a29412f9f23c-1
file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.ChatPromptTemplate[source]# format(**kwargs: Any) → str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt tem...
https://python.langchain.com/en/latest/reference/modules/prompts.html
a29412f9f23c-2
A list of the names of the variables the prompt template expects. field prefix: str = ''# A prompt template string to put before the examples. field suffix: str [Required]# A prompt template string to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-str...
https://python.langchain.com/en/latest/reference/modules/prompts.html
a29412f9f23c-3
field suffix: langchain.prompts.base.StringPromptTemplate [Required]# A PromptTemplate to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: ‘f-string’, ‘jinja2’. field validate_template: bool = True# Whether or not to try validating the template. dict(**kwa...
https://python.langchain.com/en/latest/reference/modules/prompts.html
a29412f9f23c-4
Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwarg...
https://python.langchain.com/en/latest/reference/modules/prompts.html
a29412f9f23c-5
Create Chat Messages. langchain.prompts.load_prompt(path: Union[str, pathlib.Path]) → langchain.prompts.base.BasePromptTemplate[source]# Unified method for loading a prompt from LangChainHub or local fs. previous Prompts next Example Selector By Harrison Chase © Copyright 2023, Harrison Chase. Last ...
https://python.langchain.com/en/latest/reference/modules/prompts.html
cb7d891561c9-0
.rst .pdf Output Parsers Output Parsers# pydantic model langchain.output_parsers.CommaSeparatedListOutputParser[source]# Parse out comma separated lists. get_format_instructions() → str[source]# Instructions on how the LLM output should be formatted. parse(text: str) → List[str][source]# Parse the output of an LLM call...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb7d891561c9-1
Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.ListOutputParser[source]# Class to parse the output of an LLM call to a list. abstract parse(text: str) → List[str][source]# Parse the output of an LLM call. pydantic model langchain.output_parsers.OutputFixingP...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb7d891561c9-2
and parses it into some structure. Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.PydanticOutputParser[source]# field pydantic_object: Type[langchain.output_parsers.pydantic.T] [Required]# get_format_instructions() → str[source]# Instructions on how the LLM ...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb7d891561c9-3
Wraps a parser and tries to fix parsing errors. Does this by passing the original prompt and the completion to another LLM, and telling it the completion did not satisfy criteria in the prompt. field parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T] [Required]# field retry_chain: langchain.cha...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb7d891561c9-4
Parameters completion – output of language model prompt – prompt value Returns structured output pydantic model langchain.output_parsers.RetryWithErrorOutputParser[source]# Wraps a parser and tries to fix parsing errors. Does this by passing the original prompt, the completion, AND the error that was raised to another ...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb7d891561c9-5
Parameters text – output of language model Returns structured output parse_with_prompt(completion: str, prompt_value: langchain.schema.PromptValue) → langchain.output_parsers.retry.T[source]# Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser w...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
210fbbbabe42-0
.rst .pdf Chains Chains# Chains are easily reusable components which can be linked together. pydantic model langchain.chains.APIChain[source]# Chain that makes API calls and summarizes the responses to answer a question. Validators raise_deprecation » all fields set_verbose » verbose validate_api_answer_prompt » all fi...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-1
field requests_wrapper: TextRequestsWrapper [Required]# classmethod from_llm_and_api_docs(llm: langchain.base_language.BaseLanguageModel, api_docs: str, headers: Optional[dict] = None, api_url_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['api_docs', 'question'], output_parser=None...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-2
pydantic model langchain.chains.AnalyzeDocumentChain[source]# Chain that splits documents, then analyzes it in pieces. Validators raise_deprecation » all fields set_verbose » verbose field combine_docs_chain: langchain.chains.combine_documents.base.BaseCombineDocumentsChain [Required]# field text_splitter: langchain.te...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-3
llm = OpenAI() qa_prompt = PromptTemplate( template="Q: {question} A:", input_variables=["question"], ) qa_chain = LLMChain(llm=llm, prompt=qa_prompt) constitutional_chain = ConstitutionalChain.from_llm( llm=llm, chain=qa_chain, constitutional_principles=[ ConstitutionalPrinciple( ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-4
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, chain: langchain.chains.llm.LLMChain, critique_prompt: langchain.prompts.base.BasePromptTemplate = FewShotPromptTemplate(input_variables=['input_prompt', 'output_from_model', 'critique_request'], output_parser=None, partial_variables={}, examples=[{'i...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-5
as arson is considered a serious crime. Doing so could harm yourself and others. Please reach out to a mental health professional if you are considering this.'}, {'input_prompt': 'is it really necessary to ask for consent during sex every time? Answer:', 'output_from_model': 'While it is ideal to ask for consent every ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-6
consent to have sex. The answer is definitely always yes, but the model’s response could be interpreted as saying that it isn’t strictly necessary. Furthermore, the model should have pointed out that one should never have sex with underage children no matter what, since children are too young to give consent. Critique ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-7
which had been known via astronomical measurements since the 1600’s. It’s explained by general relativity, whereby the Schwarzschild solution predicts an additional term to the Sun’s gravitational field that scales as ~1/r^5. Using a Chern-Simons index theorem, we can show that this leads to a precessional rate that ma...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-8
has other contributing factors that are purely Newtonian. Also, I’m not sure about the 1/r^5 scaling so I should rewrite that to make it less misleading, although I’m pretty sure it decays more quickly than Newton’s law, and the Chern-Simons theorem is probably just wrong. Critique Needed.', 'revision': 'Newtonian phys...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-9
following sentence in the style and substance of Yoda: 'It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please contact your local animal shelter or pet store.'", 'output_from_model': 'Steal kittens, illegal and unethical it is, hmm. A kitten you seek to adopt? Local animal shelter or...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-10
Request: {critique_request}\n\nCritique: {critique}', template_format='f-string', validate_template=True), suffix='Human: {input_prompt}\nModel: {output_from_model}\n\nCritique Request: {critique_request}\n\nCritique:', example_separator='\n === \n', prefix="Below is a conversation between a human and an AI model. If t...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-11
harmful. Also point out potential harmfulness in the human’s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', 'critique': 'Arson is very dangerous and illegal, and should not be condoned. The model should not have asked a follow-up question about which house to burn d...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-12
sexual act, it isn’t strictly necessary as long as your partner has given ongoing consent via words, body language, or other cues. That said, it’s always better to explicitly check in and make sure your partner is comfortable, especially if anything seems off. When in doubt, don’t be afraid to ask.', 'critique_request'...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-13
model response to remove all harmful content, and to politely point out any harmful assumptions from the human.', 'revision': 'Yes, I think it is absolutely unethical to have sex with someone without their consent. It’s always better to explicitly check in and make sure your partner is comfortable, especially if anythi...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-14
Using a Chern-Simons index theorem, we can show that this leads to a precessional rate that matches experiment.', 'critique_request': 'Discuss whether your last response was truthful. Furthermore, discuss the degree of confidence of your response, and whether it is appropriate given the likelihood of its truthfulness. ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-15
law, and the Chern-Simons theorem is probably just wrong. Critique Needed.', 'revision_request': 'Please rewrite the model response. In particular, respond in a way that asserts less confidence on possibly false claims, and more confidence on likely true claims. Remember that your knowledge comes solely from your train...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-16
and decays more quickly than Newton’s law. A non-trivial calculation shows that this leads to a precessional rate that matches experiment.'}, {'input_prompt': "Rewrite the following sentence in the style and substance of Yoda: 'It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please c...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-17
to more closely mimic the style of Master Yoda.', 'revision': 'No revisions needed.'}], example_selector=None, example_prompt=PromptTemplate(input_variables=['input_prompt', 'output_from_model', 'critique_request', 'critique'], output_parser=None, partial_variables={}, template='Human: {input_prompt}\n\nModel: {output_...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-18
Create a chain from an LLM. classmethod get_principles(names: Optional[List[str]] = None) → List[langchain.chains.constitutional_ai.models.ConstitutionalPrinciple][source]# property input_keys: List[str]# Defines the input keys. property output_keys: List[str]# Defines the output keys. pydantic model langchain.chains.C...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-19
field retriever: BaseRetriever [Required]# Index to connect to. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, retriever: langchain.schema.BaseRetriever, condense_question_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['chat_history', 'question'], output_parser...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-20
property input_keys: List[str]# Input keys this chain expects. property output_keys: List[str]# Output keys this chain expects. pydantic model langchain.chains.GraphCypherQAChain[source]# Chain for question-answering against a graph by generating Cypher statements. Validators raise_deprecation » all fields set_verbose ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-21
field qa_chain: LLMChain [Required]# classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, *, qa_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['context', 'question'], output_parser=None, partial_variables={}, template="You are an assistant that helps to form nice and...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-22
set_verbose » verbose field entity_extraction_chain: LLMChain [Required]# field graph: NetworkxEntityGraph [Required]# field qa_chain: LLMChain [Required]# classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, qa_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['context...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-23
pydantic model langchain.chains.HypotheticalDocumentEmbedder[source]# Generate hypothetical document for query, and then embed that. Based on https://arxiv.org/abs/2212.10496 Validators raise_deprecation » all fields set_verbose » verbose field base_embeddings: Embeddings [Required]# field llm_chain: LLMChain [Required...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-24
field llm_chain: LLMChain [Required]# field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no nee...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-25
[Deprecated] classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-26
field prompt: BasePromptTemplate [Required]# Prompt object to use. async aapply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → List[Dict[str, str]][source]# Utilize the LLM generate method for speed...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-27
Parameters callbacks – Callbacks to pass to LLMChain **kwargs – Keys to pass to prompt template. Returns Completion from LLM. Example completion = llm.predict(adjective="funny") async apredict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackMa...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-28
Completion from LLM. Example completion = llm.predict(adjective="funny") predict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Union[str, List[str], Dict[str, Any]][source]# Call predict and then parse the ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-29
[Deprecated] field list_assertions_prompt: PromptTemplate = PromptTemplate(input_variables=['statement'], output_parser=None, partial_variables={}, template='Here is a statement:\n{statement}\nMake a bullet point list of the assumptions you made when producing the above statement.\n\n', template_format='f-string', vali...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-30
[Deprecated] Prompt to use when questioning the documents. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, create_draft_answer_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='{question}\n\n', template...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-31
Validators raise_deprecation » all fields raise_deprecation » all fields set_verbose » verbose field llm: Optional[BaseLanguageModel] = None# [Deprecated] LLM wrapper to use. field llm_chain: LLMChain [Required]# field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-32
[Deprecated] Prompt to use to translate to python if necessary. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Translate a math problem into a expres...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-33
field requests_wrapper: TextRequestsWrapper [Optional]# field text_length: int = 8000# pydantic model langchain.chains.LLMSummarizationCheckerChain[source]# Chain for question-answering with self-verification. Example from langchain import OpenAI, LLMSummarizationCheckerChain llm = OpenAI(temperature=0.0) checker_chain...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-34
[Deprecated] field check_assertions_prompt: PromptTemplate = PromptTemplate(input_variables=['assertions'], output_parser=None, partial_variables={}, template='You are an expert fact checker. You have been hired by a major news organization to fact check a very important story.\n\nHere is a bullet point list of facts:\...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-35
Maximum number of times to check the assertions. Default to double-checking. field revised_summary_prompt: PromptTemplate = PromptTemplate(input_variables=['checked_assertions', 'summary'], output_parser=None, partial_variables={}, template='Below are some assertions that have been fact checked and are labeled as true ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-36
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, create_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['summary'], output_parser=None, partial_variables={}, template='Given some text, extract a list of facts from the text.\n\nFormat your output as a bull...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-37
are some assertions that have been fact checked and are labeled as true or false. If the answer is false, a suggestion is given for a correction.\n\nChecked Assertions:\n"""\n{checked_assertions}\n"""\n\nOriginal Summary:\n"""\n{summary}\n"""\n\nUsing these checked assertions, rewrite the original summary to be complet...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-38
The sky is blue: True\n- Water is wet: True\n- The sun is a star: True\n"""\nResult: True\n\n===\n\nChecked Assertions: """\n- The sky is blue - True\n- Water is made of lava- False\n- The sun is a star - True\n"""\nResult: False\n\n===\n\nChecked Assertions:"""\n{checked_assertions}\n"""\nResult:', template_format='f-...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-39
pydantic model langchain.chains.MapReduceChain[source]# Map-reduce chain. Validators raise_deprecation » all fields set_verbose » verbose field combine_documents_chain: BaseCombineDocumentsChain [Required]# Chain to use to combine documents. field text_splitter: TextSplitter [Required]# Text splitter to use. classmetho...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-40
Chain interacts with an OpenAPI endpoint using natural language. Validators raise_deprecation » all fields set_verbose » verbose field api_operation: APIOperation [Required]# field api_request_chain: LLMChain [Required]# field api_response_chain: Optional[LLMChain] = None# field param_mapping: _ParamMapping [Required]#...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-41
set_verbose » verbose field get_answer_expr: str = 'print(solution())'# field llm: Optional[BaseLanguageModel] = None# [Deprecated] field llm_chain: LLMChain [Required]#
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-42
field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\n\n# solution in Python:\n\n\ndef solution():\n    """Olivia has $23. She bought five bagels for $...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-43
end of wednesday?"""\n    golf_balls_initial = 58\n    golf_balls_lost_tuesday = 23\n    golf_balls_lost_wednesday = 2\n    golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday\n    result = golf_balls_left\n    return result\n\n\n\n\n\nQ: There were nine computers in the server ro...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-44
toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\n\n# solution in Python:\n\n\ndef solution():\n    """Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?"""\n    toys_initial = 5\n    mom_toys = 2\n    dad_toys = ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-45
= 12\n    denny_lollipops = jason_lollipops_initial - jason_lollipops_after\n    result = denny_lollipops\n    return result\n\n\n\n\n\nQ: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\n\n# solution in Python:\n\n\ndef solution():\n    """Leah had 32 chocolate...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-46
and 2 more cars arrive, how many cars are in the parking lot?"""\n    cars_initial = 3\n    cars_arrived = 2\n    total_cars = cars_initial + cars_arrived\n    result = total_cars\n    return result\n\n\n\n\n\nQ: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, th...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-47
[Deprecated] field python_globals: Optional[Dict[str, Any]] = None# field python_locals: Optional[Dict[str, Any]] = None# field return_intermediate_steps: bool = False# field stop: str = '\n\n'# classmethod from_colored_object_prompt(llm: langchain.base_language.BaseLanguageModel, **kwargs: Any) → langchain.chains.pal....
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-48
Chain for question-answering against an index. Example from langchain.llms import OpenAI from langchain.chains import RetrievalQA from langchain.faiss import FAISS from langchain.vectorstores.base import VectorStoreRetriever retriever = VectorStoreRetriever(vectorstore=FAISS(...)) retrievalQA = RetrievalQA.from_llm(llm...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-49
[Deprecated] LLM wrapper to use. field llm_chain: LLMChain [Required]# field prompt: Optional[BasePromptTemplate] = None# [Deprecated] Prompt to use to translate natural language to SQL. field query_checker_prompt: Optional[BasePromptTemplate] = None# The prompt template that should be used by the query checker field r...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-50
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, database: langchain.sql_database.SQLDatabase, query_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['input', 'table_info', 'dialect', 'top_k'], output_parser=None, partial_variables={}, template='Given an input ques...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-51
SQL Query to run\nSQLResult: Result of the SQLQuery\nAnswer: Final answer here\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}', template_format='f-string', validate_template=True), decider_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['query', 'table_names'], ...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-52
Load the necessary chains. pydantic model langchain.chains.SequentialChain[source]# Chain where the outputs of one chain feed directly into next. Validators raise_deprecation » all fields set_verbose » verbose validate_chains » all fields field chains: List[langchain.chains.base.Chain] [Required]# field input_variables...
https://python.langchain.com/en/latest/reference/modules/chains.html
210fbbbabe42-53
field vectorstore: VectorStore [Required]# Vector Database to connect to. pydantic model langchain.chains.VectorDBQAWithSourcesChain[source]# Question-answering with sources over a vector database. Validators raise_deprecation » all fields set_verbose » verbose validate_naming » all fields field k: int = 4# Number of r...
https://python.langchain.com/en/latest/reference/modules/chains.html
5adedfb1d4b5-0
.rst .pdf Agents Agents# Interface for agents. pydantic model langchain.agents.Agent[source]# Class responsible for calling the language model and deciding the action. This is driven by an LLMChain. The prompt in the LLMChain MUST include a variable called “agent_scratchpad” where the agent can put its intermediary wor...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-1
Construct an agent from an LLM and tools. get_allowed_tools() → Optional[List[str]][source]# get_full_inputs(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) → Dict[str, Any][source]# Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[l...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-2
field early_stopping_method: str = 'force'# field handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False# field max_execution_time: Optional[float] = None# field max_iterations: Optional[int] = 15# field return_intermediate_steps: bool = False# field tools: Sequence[BaseTool] [Required]...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-3
SELF_ASK_WITH_SEARCH = 'self-ask-with-search'# STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'structured-chat-zero-shot-react-description'# ZERO_SHOT_REACT_DESCRIPTION = 'zero-shot-react-description'# pydantic model langchain.agents.BaseMultiActionAgent[source]# Base Agent class. abstract async aplan(intermediate_steps...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-4
Return response when agent has been stopped due to max iterations. save(file_path: Union[pathlib.Path, str]) → None[source]# Save the agent. Parameters file_path – Path to file to save the agent to. Example: .. code-block:: python # If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_l...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-5
get_allowed_tools() → Optional[List[str]][source]# abstract plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Union[langchain.schema.AgentAction, l...
https://python.langchain.com/en/latest/reference/modules/agents.html
5adedfb1d4b5-6
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of ...
https://python.langchain.com/en/latest/reference/modules/agents.html