id
stringlengths
14
15
text
stringlengths
101
5.26k
source
stringlengths
57
120
03890c24ea5c-50
Get the number of tokens present in the text. get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) → int# Get the number of tokens in the message. get_token_ids(text: str) → List[int]# Get the token present in the text. json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-51
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-52
yield token classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.PromptLayerOpenAIChat[source]# Wrapper around OpenAI large language models. To use, you should have the openai and promptlayer python package i...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-53
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a list of p...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-54
Run the LLM on the given prompt and input. async agenerate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a li...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-55
The model param is required, but any other model parameters can also be passed in with the format input={model_param: value, …} Example from langchain.llms import Replicate replicate = Replicate(model="stability-ai/stable-diffusion: 27b93a2413e7f36cd83da926f365628 ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-56
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). predict(text: str, *, stop: Optional[Sequence[str]] = None) → str# Predict text from text. predict_messages(messages: List[...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-57
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://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-58
def get_pipeline(): model_id = "gpt2" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) pipe = pipeline( "text-generation", model=model, tokenizer=tokenizer ) return pipe hf = SelfHostedHuggingFaceLLM( model_load_fn=get_pipelin...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-59
Run the LLM on the given prompt and input. generate_prompt(prompts: List[langchain.schema.PromptValue], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Take in a list of p...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-60
field hardware: Any = None# Remote hardware to send the inference function to. field inference_fn: Callable = <function _generate_text># Inference function to send to the remote hardware. field load_fn_kwargs: Optional[dict] = None# Key word arguments to pass to the model load function. field model_load_fn: Callable [R...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-61
Get the token present in the text. 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_defaults: bool = False, exclude_none: ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-62
dict(**kwargs: Any) → Dict# Return a dictionary of the LLM. generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → langchain.schema.LLMResult# Run the LLM on the given prompt an...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-63
Take in a list of prompt values and return an LLMResult. async apredict(text: str, *, stop: Optional[Sequence[str]] = None) → str# Predict text from text. async apredict_messages(messages: List[langchain.schema.BaseMessage], *, stop: Optional[Sequence[str]] = None) → langchain.schema.BaseMessage# Predict message from m...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-64
Generates this many completions server-side and returns the “best”. field logprobs: bool = False# Whether to return log probabilities. field max_tokens: Optional[int] = None# Maximum number of tokens to generate. field min_tokens: Optional[int] = None# Minimum number of tokens to generate. field model_id: str = 'palmyr...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
03890c24ea5c-65
Get the token present in the text. 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_defaults: bool = False, exclude_none: ...
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html
dbc1327bb7ca-0
.rst .pdf Document Loaders Document Loaders# All different types of document loaders. class langchain.document_loaders.AZLyricsLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Loader that loads AZLyrics webpages. load() → List[langchain.schema.Document][source]# Load webpage. cla...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-1
Load data into document objects. class langchain.document_loaders.BiliBiliLoader(video_urls: List[str])[source]# Loader that loads bilibili transcripts. load() → List[langchain.schema.Document][source]# Load from bilibili url. class langchain.document_loaders.BlackboardLoader(blackboard_course_url: str, bbrouter: str, ...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-2
Loader that loads conversations from exported ChatGPT data. load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.CoNLLULoader(file_path: str)[source]# Load CoNLL-U files. load() → List[langchain.schema.Document][source]# Load from file path. class langchain...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-3
ValueError – _description_ ImportError – _description_ Returns _description_ Return type List[Document] paginate_request(retrieval_method: Callable, **kwargs: Any) → List[source]# Paginate the various methods to retrieve groups of pages. Unfortunately, due to page size, sometimes the Confluence API doesn’t match the li...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-4
load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.Docx2txtLoader(file_path: str)[source]# Loads a DOCX with docx2txt and chunks at character level. Defaults to check for local file, but if the file is a web path, it will download it to a temporary file, and use that, the...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-5
field direction: Optional[Literal['asc', 'desc']] = None# The direction to sort the results by. Can be one of: ‘asc’, ‘desc’. field include_prs: bool = True# If True include Pull Requests in results, otherwise ignore them. field labels: Optional[List[str]] = None# Label names to filter one. Example: bug,ui,@high. field...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-6
token_path: pathlib.Path = PosixPath('/home/docs/.credentials/token.json')# classmethod validate_channel_or_videoIds_is_set(values: Dict[str, Any]) → Dict[str, Any][source]# Validate that either folder_id or document_ids is set, but not both. class langchain.document_loaders.GoogleApiYoutubeLoader(google_api_client: la...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-7
load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.IFixitLoader(web_path: str)[source]# Load iFixit repair guides, device wikis and answers. iFixit is the largest, open repair community on the web. The site contains nearly 100k repair manuals, 200k Questions & Answers on ...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-8
load() → List[langchain.schema.Document][source]# Load from file path. class langchain.document_loaders.MastodonTootsLoader(mastodon_accounts: Sequence[str], number_toots: Optional[int] = 100, exclude_replies: bool = False, access_token: Optional[str] = None, api_base_url: str = 'https://mastodon.social')[source]# Mast...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-9
field file: File [Required]# load() → List[langchain.schema.Document][source]# Load Documents pydantic model langchain.document_loaders.OneDriveLoader[source]# field auth_with_token: bool = False# field drive_id: str [Required]# field folder_path: Optional[str] = None# field object_ids: Optional[List[str]] = None# fiel...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-10
Load given path as pages. class langchain.document_loaders.PyPDFium2Loader(file_path: str)[source]# Loads a PDF with pypdfium2 and chunks at character level. lazy_load() → Iterator[langchain.schema.Document][source]# Lazy load given path as pages. load() → List[langchain.schema.Document][source]# Load given path as pag...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-11
Loader that fetches a sitemap and loads those URLs. load() → List[langchain.schema.Document][source]# Load sitemap. parse_sitemap(soup: Any) → List[dict][source]# Parse sitemap xml and load into a list of dicts. class langchain.document_loaders.SlackDirectoryLoader(zip_path: str, workspace_url: Optional[str] = None)[so...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-12
include_checklist – Whether to include the checklist on the card in the document. card_filter – Filter on card status. Valid values are “closed”, “open”, “all”. extra_metadata – List of additional metadata fields to include as document metadata.Valid values are “due_date”, “labels”, “list”, “closed”. load() → List[lang...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-13
Loader that uses unstructured to load open office ODT files. class langchain.document_loaders.UnstructuredPDFLoader(file_path: Union[str, List[str]], mode: str = 'single', **unstructured_kwargs: Any)[source]# Loader that uses unstructured to load PDF files. class langchain.document_loaders.UnstructuredPowerPointLoader(...
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
dbc1327bb7ca-14
Load documents. previous Text Splitter next Vector Stores By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/reference/modules/document_loaders.html
5118617f3f06-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://langchain.readthedocs.io/en/latest/reference/modules/docstore.html
14e754802292-0
.rst .pdf Chat Models Chat Models# pydantic model langchain.chat_models.AzureChatOpenAI[source]# Wrapper around Azure OpenAI Chat Completion API. To use this class you must have a deployed model on Azure OpenAI. Use deployment_name in the constructor to refer to the “Model deployment name” in the Azure portal. In addit...
https://langchain.readthedocs.io/en/latest/reference/modules/chat_models.html
14e754802292-1
field openai_api_base: Optional[str] = None# field openai_api_key: Optional[str] = None# Base URL path for API requests, leave blank if not using a proxy or service emulator. field openai_organization: Optional[str] = None# field openai_proxy: Optional[str] = None# field request_timeout: Optional[Union[float, Tuple[flo...
https://langchain.readthedocs.io/en/latest/reference/modules/chat_models.html
cc5bdc0b3848-0
.rst .pdf Experimental Modules Contents Autonomous Agents Generative Agents Experimental Modules# This module contains experimental modules and reproductions of existing work using LangChain primitives. Autonomous Agents# Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module. class ...
https://langchain.readthedocs.io/en/latest/reference/modules/experimental.html
cc5bdc0b3848-1
field name: str [Required]# The character’s name. field status: str [Required]# The traits of the character you wish not to change. summarize_related_memories(observation: str) → str[source]# Summarize memories that are most relevant to an observation. field summary: str = ''# Stateful self-summary generated via reflec...
https://langchain.readthedocs.io/en/latest/reference/modules/experimental.html
ef0c727085c1-0
.rst .pdf Embeddings Embeddings# Wrappers around embedding modules. pydantic model langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding[source]# Wrapper for Aleph Alpha’s Asymmetric Embeddings AA provides you with an endpoint to embed a document and a query. The models were optimized to make the embeddings of doc...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-1
field region_name: Optional[str] = None# The aws region e.g., us-west-2. Fallsback to AWS_DEFAULT_REGION env variable or region specified in ~/.aws/config in case it is not provided here. embed_documents(texts: List[str], chunk_size: int = 1) → List[List[float]][source]# Compute doc embeddings using a Bedrock model. Pa...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-2
embed_documents(texts: List[str]) → List[List[float]][source]# Generate embeddings for a list of documents. Parameters texts (List[str]) – A list of document text strings to generate embeddings for. Returns A list of embeddings, one for each document in the inputlist. Return type List[List[float]] embed_query(text: str...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-3
model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs ) field cache_folder: Optional[str] = None# Path to store models. Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable. field encode_kwargs: Dict[str, Any] [Optional]# Key word arguments to pass when calling the encode m...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-4
path to the Llama model as a named parameter to the constructor. Check out: abetlen/llama-cpp-python Example from langchain.embeddings import LlamaCppEmbeddings llama = LlamaCppEmbeddings(model_path="/path/to/model.bin") field f16_kv: bool = False# Use half-precision for key/value cache. field logits_all: bool = False#...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-5
environment variable MOSAICML_API_TOKEN set with your API token, or pass it as a named parameter to the constructor. Example from langchain.llms import MosaicMLInstructorEmbeddings endpoint_url = ( "https://models.hosted-on.mosaicml.hosting/instructor-large/v1/predict" ) mosaic_llm = MosaicMLInstructorEmbeddings( ...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-6
If a specific credential profile should be used, you must pass the name of the profile from the ~/.aws/credentials file that is to be used. Make sure the credentials / roles used have the required policies to access the Sagemaker endpoint. See: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html field...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-7
Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Compute query embeddings using a HuggingFace transformer model. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.SelfHostedHuggingFaceEmbeddings[source]# Runs sentence_tr...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
ef0c727085c1-8
Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Compute query embeddings using a TensorflowHub embedding model. Parameters text – The text to embed. Returns Embeddings for the text. previous Chat Models next Indexes By Harrison Chase © Copyright 2023, Harrison Cha...
https://langchain.readthedocs.io/en/latest/reference/modules/embeddings.html
dc364dbee1e2-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://langchain.readthedocs.io/en/latest/reference/modules/prompts.html
dc364dbee1e2-1
PromptTemplate used to format an individual example. field example_selector: Optional[langchain.prompts.example_selector.base.BaseExampleSelector] = None# ExampleSelector to choose the examples to format into the prompt. Either this or examples should be provided. field example_separator: str = '\n\n'# String separator...
https://langchain.readthedocs.io/en/latest/reference/modules/prompts.html
dc364dbee1e2-2
Unified method for loading a prompt from LangChainHub or local fs. previous Prompts next Example Selector By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/reference/modules/prompts.html
96dc59d7a1f7-0
.rst .pdf Text Splitter Text Splitter# Functionality for splitting text. class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]# Implementation of splitting text that looks at characters. split_text(text: str) → List[str][source]# Split incoming text and return chunks. class...
https://langchain.readthedocs.io/en/latest/reference/modules/text_splitter.html
96dc59d7a1f7-1
Split documents. abstract split_text(text: str) → List[str][source]# Split text into multiple components. transform_documents(documents: Sequence[langchain.schema.Document], **kwargs: Any) → Sequence[langchain.schema.Document][source]# Transform sequence of documents by splitting them. class langchain.text_splitter.Tok...
https://langchain.readthedocs.io/en/latest/reference/modules/text_splitter.html
5ce94617e1eb-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://langchain.readthedocs.io/en/latest/reference/modules/document_compressors.html
5ce94617e1eb-1
Filter down documents based on their relevance to the query. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: Optional[langchain.prompts.base.BasePromptTemplate] = None, **kwargs: Any) → langchain.retrievers.document_compressors.chain_filter.LLMChainFilter[source]# previous Retrievers next D...
https://langchain.readthedocs.io/en/latest/reference/modules/document_compressors.html
d42eb0c67a58-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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-1
llm=llm, chain=qa_chain, constitutional_principles=[ ConstitutionalPrinciple( critique_request="Tell if this answer is good.", revision_request="Give a better answer.", ) ], ) constitutional_chain.run(question="What is the meaning of life?") Validators raise_deprecati...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-2
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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-3
but is also partially explained by general relativity, whereby the Schwarzschild solution predicts an additional term to the Sun’s gravitational field that is smaller and decays more quickly than Newton’s law. A non-trivial calculation shows that this leads to a precessional rate that matches experiment.'}, {'input_pro...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-4
their consent. 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.'}, {'input_prompt': 'Tell me something cool about general relativity. Like what is the anomalous perihelion precession of Mercury and how is it exp...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-5
Request: {revision_request}\n\nRevision:', example_separator='\n === \n', prefix='Below is a conversation between a human and an AI model.', template_format='f-string', validate_template=True), **kwargs: Any) → langchain.chains.constitutional_ai.base.ConstitutionalChain[source]#
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-6
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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-7
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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-8
Load and use LLMChain for a specific prompt key. property input_keys: List[str]# Input keys for Hyde’s LLM chain. property output_keys: List[str]# Output keys for Hyde’s LLM chain. pydantic model langchain.chains.LLMBashChain[source]# Chain that interprets a prompt and executes bash code to perform bash operations. Exa...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-9
Utilize the LLM generate method for speed gains. apply_and_parse(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → Sequence[Union[str, List[str], Dict[str, str]]][source]# Call apply and then parse the...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-10
field question_to_checked_assertions_chain: SequentialChain [Required]# field revised_answer_prompt: PromptTemplate = PromptTemplate(input_variables=['checked_assertions', 'question'], output_parser=None, partial_variables={}, template="{checked_assertions}\n\nQuestion: In light of the above assertions and checks, how ...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-11
[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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-12
[Deprecated] LLM wrapper to use. field max_checks: int = 2# 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 ass...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-13
field text_splitter: TextSplitter [Required]# Text splitter to use. classmethod from_params(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate, text_splitter: langchain.text_splitter.TextSplitter, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler]...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-14
field api_request_chain: LLMChain [Required]# field api_response_chain: Optional[LLMChain] = None# field param_mapping: _ParamMapping [Required]# field requests: Requests [Optional]# field return_intermediate_steps: bool = False# deserialize_json_input(serialized_args: str) → dict[source]# Use the serialized typescript...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-15
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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-16
solution in Python:\n\n\ndef solution():\n    """If there are 3 cars in the parking lot 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 ...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-17
[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://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-18
to fix the initial SQL from the LLM. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, db: langchain.sql_database.SQLDatabase, prompt: Optional[langchain.prompts.base.BasePromptTemplate] = None, **kwargs: Any) → langchain.chains.sql_database.base.SQLDatabaseChain[source]# pydantic model langchain.cha...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d42eb0c67a58-19
Search type to use over vectorstore. similarity or mmr. 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 va...
https://langchain.readthedocs.io/en/latest/reference/modules/chains.html
d3687b6fc1f3-0
.rst .pdf Utilities Utilities# General utilities. pydantic model langchain.utilities.ApifyWrapper[source]# Wrapper around Apify. To use, you should have the apify-client python package installed, and the environment variable APIFY_API_TOKEN set with your API key, or pass apify_api_token as a named parameter to the cons...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-1
See https://lukasschwab.me/arxiv.py/index.html#Search See https://lukasschwab.me/arxiv.py/index.html#Result It uses only the most informative fields of article meta information. class langchain.utilities.BashProcess(strip_newlines: bool = False, return_err_output: bool = False, persistent: bool = False)[source]# Execut...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-2
- You now have an API_KEY 3. Setup Custom Search Engine so you can search the entire web - Create a custom search engine in this link. - In Sites to search, add any valid URL (i.e. www.stackoverflow.com). - That’s all you have to fill up, the rest doesn’t matter. In the left-side menu, click Edit search engine → {your ...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-3
in YYYY-MM-DD format. Otherwise, None. Return type A list of dictionaries with the following keys async results_async(query: str, num_results: int) → List[Dict][source]# Get results from the Metaphor Search API asynchronously. pydantic model langchain.utilities.OpenWeatherMapAPIWrapper[source]# Wrapper for OpenWeatherM...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-4
Run command with own globals/locals and returns anything printed. pydantic model langchain.utilities.SearxSearchWrapper[source]# Wrapper for Searx API. To use you need to provide the searx host by passing the named parameter searx_host or exporting the environment variable SEARX_HOST. In some situations you might want ...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-5
from langchain import SerpAPIWrapper serpapi = SerpAPIWrapper() field aiosession: Optional[aiohttp.client.ClientSession] = None# field params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}# field serpapi_api_key: Optional[str] = None# async aresults(query: str) → dict[source]# Use a...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
d3687b6fc1f3-6
Sms Client using Twilio. To use, you should have the twilio python package installed, and the environment variables TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_FROM_NUMBER, or pass account_sid, auth_token, and from_number as named parameters to the constructor. Example from langchain.utilities.twilio import Twili...
https://langchain.readthedocs.io/en/latest/reference/modules/utilities.html
1b608297383e-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://langchain.readthedocs.io/en/latest/reference/modules/retrievers.html
1b608297383e-1
To connect to an Elasticsearch instance that requires login credentials, including Elastic Cloud, use the Elasticsearch URL format https://username:password@es_host:9243. For example, to connect to Elastic Cloud, create the Elasticsearch URL with the required authentication details and pass it to the ElasticVectorSearc...
https://langchain.readthedocs.io/en/latest/reference/modules/retrievers.html
1b608297383e-2
pydantic model langchain.retrievers.PubMedRetriever[source]# It is effectively a wrapper for PubMedAPIWrapper. It wraps load() to get_relevant_documents(). It uses all PubMedAPIWrapper arguments without any change. async aget_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents releva...
https://langchain.readthedocs.io/en/latest/reference/modules/retrievers.html
1b608297383e-3
field tfidf_array: Any = None# field vectorizer: Any = None# async aget_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 classmethod from_documents(documents: Iterable...
https://langchain.readthedocs.io/en/latest/reference/modules/retrievers.html
1b608297383e-4
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 get_relevant_documents_with_filter(query: str, *, _filter: Optional[str] = None) → List[langchain.schema.Document]...
https://langchain.readthedocs.io/en/latest/reference/modules/retrievers.html
61a39a44520d-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://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-1
save_agent(file_path: Union[pathlib.Path, str]) → None[source]# Save the underlying agent. pydantic model langchain.agents.AgentOutputParser[source]# abstract parse(text: str) → Union[langchain.schema.AgentAction, langchain.schema.AgentFinish][source]# Parse text into agent action/finish. class langchain.agents.AgentTy...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-2
Parameters intermediate_steps – Steps the LLM has taken to date, along with observations callbacks – Callbacks to run. **kwargs – User inputs. Returns Action specifying what tool to use. return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-3
Returns A PromptTemplate with the template assembled from the pieces here. classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.age...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-4
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], system_message: 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 r...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-5
Given input, decided what to do. Parameters intermediate_steps – Steps the LLM has taken to date, along with observations callbacks – Callbacks to run. **kwargs – User inputs. Returns Action specifying what tool to use. dict(**kwargs: Any) → Dict[source]# Return dictionary representation of agent. plan(intermediate_ste...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-6
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Respond to the human as helpfully and accurately as possible. You have access to the following tools:', suffix: str = 'Begin! Reminder to ALWAYS respond with...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-7
Initialize tool from a function. property args: dict# The tool’s input arguments. pydantic model langchain.agents.ZeroShotAgent[source]# Agent for the MRKL chain. field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: s...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-8
Create csv agent by loading to a dataframe and using pandas agent. langchain.agents.create_json_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: langchain.agents.agent_toolkits.json.toolkit.JsonToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-9
Construct a json agent from an LLM and tools. langchain.agents.create_openapi_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = "You are an agent de...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-10
Construct a pandas agent from an LLM and dataframe. langchain.agents.create_pbi_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langch...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-11
Construct a pbi agent from an LLM and tools. langchain.agents.create_pbi_chat_agent(llm: langchain.chat_models.base.BaseChatModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-12
Construct a spark agent from an LLM and dataframe. langchain.agents.create_spark_sql_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: langchain.agents.agent_toolkits.spark_sql.toolkit.SparkSQLToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are a...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-13
Construct a sql agent from an LLM and tools. langchain.agents.create_sql_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designe...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
61a39a44520d-14
Get a list of all possible tool names. langchain.agents.initialize_agent(tools: Sequence[langchain.tools.base.BaseTool], llm: langchain.base_language.BaseLanguageModel, agent: Optional[langchain.agents.agent_types.AgentType] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, agent_...
https://langchain.readthedocs.io/en/latest/reference/modules/agents.html
64456b903bc9-0
.rst .pdf Memory Memory# class langchain.memory.CassandraChatMessageHistory(contact_points: List[str], session_id: str, port: int = 9042, username: str = 'cassandra', password: str = 'cassandra', keyspace_name: str = 'chat_history', table_name: str = 'message_store')[source]# Chat message history that stores history in...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html