id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
f52a7273f519-0
.rst .pdf Prompts Prompts# The reference guides here all relate to objects for working with Prompts. PromptTemplates Example Selector Output Parsers previous How to serialize prompts next PromptTemplates By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/prompts.html
ccdd4c7ec1b6-0
.rst .pdf Indexes Indexes# Indexes refer to ways to structure documents so that LLMs can best interact with them. LangChain has a number of modules that help you load, structure, store, and retrieve documents. Docstore Text Splitter Document Loaders Vector Stores Retrievers Document Compressors Document Transformers pr...
https://python.langchain.com/en/latest/reference/indexes.html
dd8039bff893-0
.md .pdf Installation Contents Official Releases Installing from source Installation# Official Releases# LangChain is available on PyPi, so to it is easily installable with: pip install langchain That will install the bare minimum requirements of LangChain. A lot of the value of LangChain comes when integrating it wi...
https://python.langchain.com/en/latest/reference/installation.html
8365f9885931-0
.rst .pdf Models Models# LangChain provides interfaces and integrations for a number of different types of models. LLMs Chat Models Embeddings previous API References next Chat Models By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/models.html
c3cf545f2b68-0
.rst .pdf Tools Tools# Core toolkit implementations. pydantic model langchain.tools.AIPluginTool[source]# field api_spec: str [Required]# field args_schema: Type[AIPluginToolSchema] = <class 'langchain.tools.plugin.AIPluginToolSchema'># Pydantic model class to validate and parse the tool’s input arguments. field plugin...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-1
to_typescript() → str[source]# Get typescript string representation of the operation. static ts_type_from_python(type_: Union[str, Type, tuple, None, enum.Enum]) → str[source]# property body_params: List[str]# property path_params: List[str]# property query_params: List[str]# pydantic model langchain.tools.AzureCogsFor...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-2
pydantic model langchain.tools.BaseTool[source]# Interface LangChain tools must implement. field args_schema: Optional[Type[pydantic.main.BaseModel]] = None# Pydantic model class to validate and parse the tool’s input arguments. field callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None# Depr...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-3
Run the tool. property args: dict# property is_single_input: bool# Whether the tool only accepts a single input. pydantic model langchain.tools.BingSearchResults[source]# Tool that has capability to query the Bing Search API and get back json. field api_wrapper: langchain.utilities.bing_search.BingSearchAPIWrapper [Req...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-4
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Create a copy of a file in a specified location'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'copy_file'# The unique name of the to...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-5
field num_results: int = 4# pydantic model langchain.tools.DuckDuckGoSearchRun[source]# Tool that adds the capability to query the DuckDuckGo search API. field api_wrapper: langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper [Optional]# pydantic model langchain.tools.ExtractHyperlinksTool[source]# Extract ...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-6
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Recursively search for files in a subdirectory that match the regex pattern'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'file_sear...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-7
pydantic model langchain.tools.GmailGetMessage[source]# field args_schema: Type[langchain.tools.gmail.get_message.SearchArgsSchema] = <class 'langchain.tools.gmail.get_message.SearchArgsSchema'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to fetch an e...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-8
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to search for email messages or threads. The input must be a valid Gmail query. The output is a JSON list of the requested resource.'# Used to tell the model how/when/why to use the tool. You can provide few-s...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-9
Tool that has capability to query the Serper.dev Google Search API and get back json. field api_wrapper: langchain.utilities.google_serper.GoogleSerperAPIWrapper [Optional]# pydantic model langchain.tools.GoogleSerperRun[source]# Tool that adds the capability to query the Serper.dev Google search API. field api_wrapper...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-10
Tool for getting tables names. field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# pydantic model langchain.tools.MetaphorSearchResults[source]# Tool that has capability to query the Metaphor Search API and get back json. field api_wrapper: langchain.utilities.metaphor_search.MetaphorSearchAPIWrapper ...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-11
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Navigate a browser to the specified URL'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'navigate_browser'# The unique name of the too...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-12
Get the operation object for a given path and HTTP method. get_parameters_for_operation(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation) → List[openapi_schema_pydantic.v3.v3_1_0.parameter.Parameter][source]# Get the components for a given operation. get_referenced_schema(ref: openapi_schema_pydantic.v3...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-13
Validators raise_deprecation » all fields validate_llm_chain_input_variables » llm_chain field examples: Optional[str] = '\nQuestion: How many rows are in the table <table>?\nDAX: EVALUATE ROW("Number of rows", COUNTROWS(<table>))\n----\nQuestion: How many rows are in the table <table> where <column> is not empty?\nDAX...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-14
field template: Optional[str] = '\nAnswer the question below with a DAX query that can be sent to Power BI. DAX queries have a simple syntax comprised of just one required keyword, EVALUATE, and several optional keywords: ORDER BY, START AT, DEFINE, MEASURE, VAR, TABLE, and COLUMN. Each keyword defines a statement used...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-15
columns, expressions, and values. However, some functions, such as PI, do not require any arguments, but always require parentheses to indicate the null argument. For example, you must always type PI(), not PI. You can also nest functions within other functions. \n\nSome commonly used functions are:\nEVALUATE <table> -...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-16
VAR; EVALUATE <table> - The optional DEFINE keyword introduces one or more calculated entity definitions that exist only for the duration of the query. Definitions precede the EVALUATE statement and are valid for all EVALUATE statements in the query. Definitions can be variables, measures, tables1, and columns1. Defini...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-17
<filter> is a Boolean expression that is to be evaluated for each row of the table. For example, [Amount] > 0 or [Region] = "France"\nROW(<name>, <expression>) - Returns a table with a single row containing values that result from the expressions given to each column.\nDISTINCT(<column>) - Returns a one-column table th...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-18
Functions names with an X in it can include a expression as an argument, this will be evaluated for each row in the table and the result will be used in the regular function calculation, these are the functions:\nCOUNT(<column>), COUNTA(<column>), COUNTX(<table>,<expression>), COUNTAX(<table>,<expression>), COUNTROWS([...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-19
Returns a date value that represents the specified year, month, and day.\nDATEDIFF(date1, date2, <interval>) - Returns the difference between two date values, in the specified interval, that can be SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.\nDATEVALUE(<date_text>) - Returns a date value that represents the ...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-20
case you need to rewrite the DAX query to get the correct answer.\n\nThe following tables exist: {tables}\n\nand the schema\'s for some are given here:\n{schemas}\n\nExamples:\n{examples}\n\nQuestion: {tool_input}\nDAX: \n'#
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-21
pydantic model langchain.tools.ReadFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.read.ReadFileInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Read file from disk'# Used to tell the model how/when/why...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-22
The input arguments’ schema. The tool schema. field coroutine: Optional[Callable[[...], Awaitable[Any]]] = None# The asynchronous version of the function. field description: str = ''# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field func: Callabl...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-23
The function to run when the tool is called. field name: str [Required]# The unique name of the tool that clearly communicates its purpose. field return_direct: bool = False# Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. fiel...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-24
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Write file to disk'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'write_file'# The unique name of the tool that clearly communicates...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-25
Parameters action_id – a specific action ID (from list actions) of the action to execute (the set api_key must be associated with the action owner) instructions – a natural language instruction string for using the action (eg. “get the latest email from Mike Knoop” for “Gmail: find email” action) params – a dict, optio...
https://python.langchain.com/en/latest/reference/modules/tools.html
c3cf545f2b68-26
field params: Optional[dict] = None# field params_schema: Dict[str, str] [Optional]# field zapier_description: str [Required]# langchain.tools.tool(*args: Union[str, Callable], return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, infer_schema: bool = True) → Callable[source]# Make t...
https://python.langchain.com/en/latest/reference/modules/tools.html
0abf157430ac-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://python.langchain.com/en/latest/reference/modules/chat_models.html
0abf157430ac-1
Example get_num_tokens(text: str) → int[source]# Calculate number of tokens. pydantic model langchain.chat_models.ChatGooglePalm[source]# Wrapper around Google’s PaLM Chat API. To use you must have the google.generativeai Python package installed and either: The GOOGLE_API_KEY` environment varaible set with your API ke...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
0abf157430ac-2
in, even if not explicitly saved on this class. Example from langchain.chat_models import ChatOpenAI openai = ChatOpenAI(model_name="gpt-3.5-turbo") field max_retries: int = 6# Maximum number of retries to make when generating. field max_tokens: Optional[int] = None# Maximum number of tokens to generate. field model_kw...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
0abf157430ac-3
main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb get_token_ids(text: str) → List[int][source]# Get the tokens present in the text with tiktoken package. pydantic model langchain.chat_models.ChatVertexAI[source]# Wrapper around Vertex AI large language models. field model_name: str = 'chat-bison'# Model name t...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
94dd38cab878-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://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-1
Return type ApifyDatasetLoader call_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], langchain.schema.Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → langchain.document_loaders.apify_dataset.ApifyDatasetLoader[source]#...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-2
Parameters top_k_results – number of the top-scored document used for the arxiv tool ARXIV_MAX_QUERY_LENGTH – the cut limit on the query used for the arxiv tool. load_max_docs – a limit to the number of loaded documents load_all_available_meta – if True: the metadata of the loaded Documents gets all available meta inf...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-3
pydantic model langchain.utilities.BingSearchAPIWrapper[source]# Wrapper for Bing Search API. In order to set this up, follow instructions at: https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e field bing_search_url: str [Required]# field bing_subscription_key: str [Requ...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-4
Returns snippet - The description of the result. title - The title of the result. link - The link to the result. Return type A list of dictionaries with the following keys run(query: str) → str[source]# pydantic model langchain.utilities.GooglePlacesAPIWrapper[source]# Wrapper around Google Places API. To use, you shou...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-5
- Install the library using pip install google-api-python-client The current version of the library is 2.70.0 at this time 2. To create an API key: - Navigate to the APIs & Services→Credentials panel in Cloud Console. - Select Create credentials, then select API key from the drop-down menu. - The API key created dialog...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-6
title - The title of the result. link - The link to the result. Return type A list of dictionaries with the following keys run(query: str) → str[source]# Run query through GoogleSearch and parse result. pydantic model langchain.utilities.GoogleSerperAPIWrapper[source]# Wrapper around the Serper.dev Google Search API. Y...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-7
This wrapper will use the GraphQL API to conduct queries. field custom_headers: Optional[Dict[str, str]] = None# field graphql_endpoint: str [Required]# run(query: str) → str[source]# Run a GraphQL query and get the results. pydantic model langchain.utilities.LambdaWrapper[source]# Wrapper for AWS Lambda SDK. Docs for ...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-8
Wrapper for OpenWeatherMap API using PyOWM. Docs for using: Go to OpenWeatherMap and sign up for an API key Save your API KEY into OPENWEATHERMAP_API_KEY env variable pip install pyowm field openweathermap_api_key: Optional[str] = None# field owm: Any = None# run(location: str) → str[source]# Get the current weather in...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-9
get_schemas() → str[source]# Get the available schema’s. get_table_info(table_names: Optional[Union[List[str], str]] = None) → str[source]# Get information about specified tables. get_table_names() → Iterable[str][source]# Get names of tables available. run(command: str) → Any[source]# Execute a DAX command and return ...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-10
# note the unsecure parameter is not needed if you pass the url scheme as # http searx = SearxSearchWrapper(searx_host="http://localhost:8888", unsecure=True) Validators disable_ssl_warnings » unsecure validate_params » all fields field aiosession: Optional[Any] = None# field cat...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-11
**kwargs – extra parameters to pass to the searx API. Returns {snippet: The description of the result. title: The title of the result. link: The link to the result. engines: The engines used for the result. category: Searx category of the result. } Return type Dict with the following keys run(query: str, engines: Opt...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-12
To use, you should have the google-search-results python package installed, and the environment variable SERPAPI_API_KEY set with your API key, or pass serpapi_api_key as a named parameter to the constructor. Example from langchain import SerpAPIWrapper serpapi = SerpAPIWrapper() field aiosession: Optional[aiohttp.clie...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-13
For example: SparkSQL.from_uri(“sc://localhost:15002”) get_table_info(table_names: Optional[List[str]] = None) → str[source]# get_table_info_no_throw(table_names: Optional[List[str]] = None) → str[source]# Get information about specified tables. Follows best practices as specified in: Rajkumar et al, 2022 (https://arxi...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-14
PATCH the URL and return the text asynchronously. async apost(url: str, data: Dict[str, Any], **kwargs: Any) → str[source]# POST to the URL and return the text asynchronously. async aput(url: str, data: Dict[str, Any], **kwargs: Any) → str[source]# PUT the URL and return the text asynchronously. delete(url: str, **kwar...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-15
field account_sid: Optional[str] = None# Twilio account string identifier. field auth_token: Optional[str] = None# Twilio auth token. field from_number: Optional[str] = None# A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, an [alphanumeric sender ID](https://www.twilio.com/docs/...
https://python.langchain.com/en/latest/reference/modules/utilities.html
94dd38cab878-16
fetch page summaries. By default, it will return the page summaries of the top-k results. It limits the Document content by doc_content_chars_max. field doc_content_chars_max: int = 4000# field lang: str = 'en'# field load_all_available_meta: bool = False# field top_k_results: int = 3# load(query: str) → List[langchain...
https://python.langchain.com/en/latest/reference/modules/utilities.html
0d950dd68449-0
.rst .pdf SearxNG Search Contents Quick Start Searching Engine Parameters Search Tips SearxNG Search# Utility for using SearxNG meta search API. SearxNG is a privacy-friendly free metasearch engine that aggregates results from multiple search engines and databases and supports the OpenSearch specification. More detai...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
0d950dd68449-1
# assuming the searx host is set as above or exported as an env variable s = SearxSearchWrapper(engines=['google', 'bing'], language='es') Search Tips# Searx offers a special search syntax that can also be used instead of passing engine parameters. For example the following query: s = SearxSearchWra...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
0d950dd68449-2
use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your own network as described here. For a list of public SearxNG instances see https://searx.space/ class langchain.utilities.searx_search.SearxResults(data: str)[source]# Dict like wrappe...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
0d950dd68449-3
field params: dict [Optional]# field query_suffix: Optional[str] = ''# field searx_host: str = ''# field unsecure: bool = False# async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) → List[Dict][source]# Asynchronously query with json results...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
0d950dd68449-4
Run query through Searx API and parse results. You can pass any other params to the searx query API. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra param...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
8c25b1017365-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
8c25b1017365-1
field retry_chain: langchain.chains.llm.LLMChain [Required]# classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'error', 'instruc...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
8c25b1017365-2
and parses it into some structure. Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.RegexDictParser[source]# Class to parse the output into a dictionary. field no_update_value: Optional[str] = None# field output_key_to_format: Dict[str, str] [Required]# field ...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
8c25b1017365-3
field retry_chain: langchain.chains.llm.LLMChain [Required]# classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'prompt'], outp...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
8c25b1017365-4
that was raised to another language model and telling it that the completion did not work, and raised the given error. Differs from RetryOutputParser in that this implementation provides the error that was raised back to the LLM, which in theory should give it more information on how to fix it. field parser: langchain....
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
8c25b1017365-5
The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so. Parameters completion – output of language model prompt – prompt value Returns structured output pydantic model langchain.output_parsers.StructuredOutputParser[sourc...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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
5ff2273f5859-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