id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
8421cefce063-43
Table Names:', template_format='f-string', validate_template=True), **kwargs: Any) → langchain.chains.sql_database.base.SQLDatabaseSequentialChain[source]#
https://python.langchain.com/en/latest/reference/modules/chains.html
8421cefce063-44
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
8421cefce063-45
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
2c7d93cd9687-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://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-1
Loading logic for loading documents from Azure Blob Storage. load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.AzureBlobStorageFileLoader(conn_str: str, container: str, blob_name: str)[source]# Loading logic for loading documents from Azure Blob Storage. load() → List[la...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-2
load() → List[langchain.schema.Document][source]# Load bibtex file documents from the given bibtex file path. See https://bibtexparser.readthedocs.io/en/master/ Parameters file_path – the path to the bibtex file Returns a list of documents with the document.page_content in text format class langchain.document_loaders.B...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-3
cookie by logging into the course and then copying the value of the BbRouter cookie from the browser’s developer tools. Example from langchain.document_loaders import BlackboardLoader loader = BlackboardLoader( blackboard_course_url="https://blackboard.example.com/webapps/blackboard/execute/announcement?method=sear...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-4
The Loader uses the Alchemy API to interact with the blockchain. ALCHEMY_API_KEY environment variable must be set to use this loader. The API returns 100 NFTs per request and can be paginated using the startToken parameter. If get_all_tokens is set to True, the loader will get all tokens on the contract. Note that for...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-5
column3: value3 load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.ChatGPTLoader(log_file: str, num_logs: int = - 1)[source]# Loader that loads conversations from exported ChatGPT data. load() → List[langchain.schema.Document][source]# Load data into docu...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-6
is set to False by default, if set to True all attachments will be downloaded and ConfluenceReader will extract the text from the attachments and add it to the Document object. Currently supported attachment types are: PDF, PNG, JPEG/JPG, SVG, Word and Excel. Hint: space_key and page_id can both be found in the URL of ...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-7
Check if a page is publicly accessible. load(space_key: Optional[str] = None, page_ids: Optional[List[str]] = None, label: Optional[str] = None, cql: Optional[str] = None, include_restricted_content: bool = False, include_archived_content: bool = False, include_attachments: bool = False, include_comments: bool = False,...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-8
doesn’t match the limit value. If limit is >100 confluence seems to cap the response to 100. Also, due to the Atlassian Python package, we don’t get the “next” values from the “_links” key because they only return the value from the results key. So here, the pagination starts from 0 and goes until the max_pages, getti...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-9
Validates proper combinations of init arguments class langchain.document_loaders.DataFrameLoader(data_frame: Any, page_content_column: str = 'text')[source]# Load Pandas DataFrames. load() → List[langchain.schema.Document][source]# Load from the dataframe. class langchain.document_loaders.DiffbotLoader(api_token: str, ...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-10
load() → List[langchain.schema.Document][source]# Load all chat messages. pydantic model langchain.document_loaders.DocugamiLoader[source]# Loader that loads processed docs from Docugami. To use, you should have the lxml python package installed. field access_token: Optional[str] = None# field api: str = 'https://api.d...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-11
are written into the page_content and none into the metadata. load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.EverNoteLoader(file_path: str, load_single_document: bool = True)[source]# EverNote Loader. Loads an EverNote notebook export file e.g. my_not...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-12
load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.GCSFileLoader(project_name: str, bucket: str, blob: str)[source]# Loading logic for loading documents from GCS. load() → List[langchain.schema.Document][source]# Load documents. pydantic model langchain.document_loaders.G...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-13
field sort: Optional[Literal['created', 'updated', 'comments']] = None# What to sort results by. Can be one of: ‘created’, ‘updated’, ‘comments’. Default is ‘created’. field state: Optional[Literal['open', 'closed', 'all']] = None# Filter on issue state. Can be one of: ‘open’, ‘closed’, ‘all’. lazy_load() → Iterator[la...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-14
Each document represents one file in the repository. The path points to the local Git repository, and the branch specifies the branch to load files from. By default, it loads from the main branch. load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.Gitbook...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-15
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://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-16
Validate that either folder_id or document_ids is set, but not both. video_ids: Optional[List[str]] = None# pydantic model langchain.document_loaders.GoogleDriveLoader[source]# Loader that loads Google Docs from Google Drive. Validators validate_credentials_path » credentials_path validate_inputs » all fields field cre...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-17
Load comments from a HN post. load_results(soup: Any) → List[langchain.schema.Document][source]# Load items from an HN page. class langchain.document_loaders.HuggingFaceDatasetLoader(path: str, page_content_column: str = 'text', name: Optional[str] = None, data_dir: Optional[str] = None, data_files: Optional[Union[str,...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-18
load_guide(url_override: Optional[str] = None) → List[langchain.schema.Document][source]# load_questions_and_answers(url_override: Optional[str] = None) → List[langchain.schema.Document][source]# static load_suggestions(query: str = '', doc_type: str = 'all') → List[langchain.schema.Document][source]# class langchain.d...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-19
Load and return documents from the JSON file. class langchain.document_loaders.JoplinLoader(access_token: Optional[str] = None, port: int = 41184, host: str = 'localhost')[source]# Loader that fetches notes from Joplin. In order to use this loader, you need to have Joplin running with the Web Clipper enabled (look for ...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-20
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://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-21
Convenience constructor that builds the MaxCompute API wrapper fromgiven parameters. Parameters query – SQL query to execute. endpoint – MaxCompute endpoint. project – A project is a basic organizational unit of MaxCompute, which is similar to a database. access_id – MaxCompute access ID. Should be passed in directly o...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-22
:type request_timeout_sec: int load() → List[langchain.schema.Document][source]# Load documents from the Notion database. :returns: List of documents. :rtype: List[Document] load_page(page_id: str) → langchain.schema.Document[source]# Read a page. class langchain.document_loaders.NotionDirectoryLoader(path: str)[source...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-23
Loader that loads online PDFs. load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.OutlookMessageLoader(file_path: str)[source]# Loader that loads Outlook Message files using extract_msg. TeamMsgExtractor/msg-extractor load() → List[langchain.schema.Document][source]# Load...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-24
urls# List of URLs to load. Type List[str] continue_on_failure# If True, continue loading other URLs on failure. Type bool headless# If True, the browser will run in headless mode. Type bool load() → List[langchain.schema.Document][source]# Load the specified URLs using Playwright and create Document instances. Returns...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-25
load() → List[langchain.schema.Document][source]# 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[langchai...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-26
load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.RedditPostsLoader(client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ['new'], number_posts: Optional[int] = 10)[source]# Reddit posts loader. Read po...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-27
Loader that uses Selenium and to load a page and unstructured to load the html. This is useful for loading pages that require javascript to render. urls# List of URLs to load. Type List[str] continue_on_failure# If True, continue loading other URLs on failure. Type bool browser# The browser to use, either ‘chrome’ or ‘...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-28
load() → List[langchain.schema.Document][source]# Load and return documents from the Slack directory dump. class langchain.document_loaders.SpreedlyLoader(access_token: str, resource: str)[source]# load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.Stripe...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-29
autodetect_encoding – Whether to try to autodetect the file encoding if the specified encoding fails. load() → List[langchain.schema.Document][source]# Load from file path. class langchain.document_loaders.ToMarkdownLoader(url: str, api_key: str)[source]# Loader that loads HTML to markdown using 2markdown. lazy_load() ...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-30
Convenience constructor that builds TrelloClient init param for you. Parameters board_name – The name of the Trello board. api_key – Trello API key. Can also be specified as environment variable TRELLO_API_KEY. token – Trello token. Can also be specified as environment variable TRELLO_TOKEN. include_card_name – Whether...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-31
Create a TwitterTweetLoader from OAuth2 bearer token. classmethod from_secrets(access_token: str, access_token_secret: str, consumer_key: str, consumer_secret: str, twitter_users: Sequence[str], number_tweets: Optional[int] = 100) → langchain.document_loaders.twitter.TwitterTweetLoader[source]# Create a TwitterTweetLoa...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-32
Loader that uses unstructured to load file IO objects. class langchain.document_loaders.UnstructuredFileLoader(file_path: Union[str, List[str]], mode: str = 'single', **unstructured_kwargs: Any)[source]# Loader that uses unstructured to load files. class langchain.document_loaders.UnstructuredHTMLLoader(file_path: Unio...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-33
Loader that uses unstructured to load rtf files. class langchain.document_loaders.UnstructuredURLLoader(urls: List[str], continue_on_failure: bool = True, mode: str = 'single', **unstructured_kwargs: Any)[source]# Loader that uses unstructured to load HTML files. load() → List[langchain.schema.Document][source]# Load f...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-34
default_parser: str = 'html.parser'# Default parser to use for BeautifulSoup. async fetch_all(urls: List[str]) → Any[source]# Fetch all urls concurrently with rate limiting. load() → List[langchain.schema.Document][source]# Load text from the url(s) in web_path. requests_kwargs: Dict[str, Any] = {}# kwargs for requests...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
2c7d93cd9687-35
static extract_video_id(youtube_url: str) → str[source]# Extract video id from common YT urls. classmethod from_youtube_url(youtube_url: str, **kwargs: Any) → langchain.document_loaders.youtube.YoutubeLoader[source]# Given youtube URL, load video. load() → List[langchain.schema.Document][source]# Load documents. previo...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
94581ce70c57-0
.rst .pdf Agent Toolkits Agent Toolkits# Agent toolkits. pydantic model langchain.agents.agent_toolkits.AzureCognitiveServicesToolkit[source]# Toolkit for Azure Cognitive Services. get_tools() → List[langchain.tools.base.BaseTool][source]# Get the tools in the toolkit. pydantic model langchain.agents.agent_toolkits.Fil...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-1
get_tools() → List[langchain.tools.base.BaseTool][source]# Get the tools in the toolkit. pydantic model langchain.agents.agent_toolkits.NLAToolkit[source]# Natural Language API Toolkit Definition. field nla_tools: Sequence[langchain.agents.agent_toolkits.nla.tool.NLATool] [Required]# List of API Endpoint Tools. classme...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-2
Instantiate the toolkit from an OpenAPI Spec URL get_tools() → List[langchain.tools.base.BaseTool][source]# Get the tools for all the API operations. pydantic model langchain.agents.agent_toolkits.OpenAPIToolkit[source]# Toolkit for interacting with a OpenAPI api. field json_agent: langchain.agents.agent.AgentExecutor ...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-3
field max_iterations: int = 5# field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# get_tools() → List[langchain.tools.base.BaseTool][source]# Get the tools in the toolkit. pydantic model langchain.agents.agent_toolkits.SQLDatabaseToolkit[source]# Toolkit for interacting with SQL databases. field db: l...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-4
Get the tools in the toolkit. pydantic model langchain.agents.agent_toolkits.VectorStoreToolkit[source]# Toolkit for interacting with a vector store. field llm: langchain.base_language.BaseLanguageModel [Optional]# field vectorstore_info: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo [Required]# g...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-5
langchain.agents.agent_toolkits.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 an agent designed to interact with JSON.\nYour goal...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-6
you should ALWAYS follow up by using the `json_spec_list_keys` tool to see what keys exist at that path.\nDo not simply refer the user to the JSON or a section of the JSON, as this is not a valid answer. Keep digging until you find the answer and explicitly return it.\n', suffix: str = 'Begin!"\n\nQuestion: {input}\nTh...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-7
Construct a json agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-8
langchain.agents.agent_toolkits.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 designed to answer questions by m...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-9
you should always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-10
Construct a json agent from an LLM and tools. langchain.agents.agent_toolkits.create_pandas_dataframe_agent(llm: langchain.base_language.BaseLanguageModel, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: Optional[str] = None, suffix: Optional[str] = None, input_variable...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-11
langchain.agents.agent_toolkits.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[langchain.callbacks.base.BaseCallbackManage...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-12
you should always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-13
Construct a pbi agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-14
langchain.agents.agent_toolkits.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.callbacks.base.BaseCallbackMa...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-15
(remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\n\n{{{{input}}}}\n", examples: Optional[str] = None, input_variables: Optional[List[str]] = None, memory: Optional[langchain.memory.chat_memory.BaseChatMemory] = None, top_k: int = 10, verbose: bool = False, agent_...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-16
Construct a pbi agent from an Chat LLM and tools. If you supply only a toolkit and no powerbi dataset, the same LLM is used for both. langchain.agents.agent_toolkits.create_python_agent(llm: langchain.base_language.BaseLanguageModel, tool: langchain.tools.python.tool.PythonREPLTool, callback_manager: Optional[langchain...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-17
Construct a python agent from an LLM and tool. langchain.agents.agent_toolkits.create_spark_dataframe_agent(llm: langchain.llms.base.BaseLLM, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = '\nYou are working with a spark dataframe in Python. The name of the dataf...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-18
langchain.agents.agent_toolkits.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 an agent designed to interact with Sp...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-19
Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question', input_variables: Optional[List[str]] = None, top_k: int = 10, max_iterations...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-20
Construct a sql agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-21
langchain.agents.agent_toolkits.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 designed to interact with a SQL datab...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-22
Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question', input_variables: Optional[List[str]] = None, top_k: int = 10, max_iterations...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-23
Construct a sql agent from an LLM and tools. langchain.agents.agent_toolkits.create_vectorstore_agent(llm: langchain.base_language.BaseLanguageModel, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: ...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
94581ce70c57-24
Construct a vectorstore router agent from an LLM and tools. previous Tools next Utilities By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
4f324e5a9d27-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
4f324e5a9d27-1
environment variable ANTHROPIC_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example import anthropic from langchain.llms import Anthropic model = ChatAnthropic(model="<model_name>", anthropic_api_key="my-api-key") get_num_tokens(text: str) → int[source]# Calculate number of tokens....
https://python.langchain.com/en/latest/reference/modules/chat_models.html
4f324e5a9d27-2
Wrapper around OpenAI Chat large language models. To use, you should have the openai python package installed, and the environment variable OPENAI_API_KEY set with your API key. Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved on this class. Example fro...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
4f324e5a9d27-3
Use tenacity to retry the completion call. get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) → int[source]# Calculate num tokens for gpt-3.5-turbo and gpt-4 with tiktoken package. Official documentation: openai/openai-cookbook main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb get_token...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
4f324e5a9d27-4
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/reference/modules/chat_models.html
9e2aef44631b-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
9e2aef44631b-1
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 template. Returns A formatted string. Example: promp...
https://python.langchain.com/en/latest/reference/modules/prompts.html
9e2aef44631b-2
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-string’, ‘jinja2’. field validate_template: bool = True# Whether or n...
https://python.langchain.com/en/latest/reference/modules/prompts.html
9e2aef44631b-3
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(**kwargs: Any) → Dict[source]# Return a dictionary of the prompt. format(**...
https://python.langchain.com/en/latest/reference/modules/prompts.html
9e2aef44631b-4
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 = '', **kwargs: Any) → langchain.prompts.prompt....
https://python.langchain.com/en/latest/reference/modules/prompts.html
9e2aef44631b-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
351ed6624640-0
.rst .pdf Example Selector Example Selector# Logic for selecting examples to include in prompts. pydantic model langchain.prompts.example_selector.LengthBasedExampleSelector[source]# Select examples based on length. Validators calculate_example_text_lengths » example_text_lengths field example_prompt: langchain.prompts...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
351ed6624640-1
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An iniialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g....
https://python.langchain.com/en/latest/reference/modules/example_selector.html
351ed6624640-2
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An initialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
479f31c64c6b-0
.rst .pdf LLMs LLMs# Wrappers on top of large language models APIs. pydantic model langchain.llms.AI21[source]# Wrapper around AI21 large language models. To use, you should have the environment variable AI21_API_KEY set with your API key. Example from langchain.llms import AI21 ai21 = AI21(model="j2-jumbo-instruct") V...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-1
How many completions to generate for each prompt. field presencePenalty: langchain.llms.ai21.AI21PenaltyData = AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctuations=True, applyToNumbers=True, applyToStopwords=True, applyToEmojis=True)# Penalizes repeated tokens. field temperature: float = 0.7# What samp...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-2
Predict message from messages. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set ...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-3
Take in a list of prompt values and return an LLMResult. get_num_tokens(text: str) → int# 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 i...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-4
Try to update ForwardRefs on fields based on this Model, globalns and localns. pydantic model langchain.llms.AlephAlpha[source]# Wrapper around Aleph Alpha large language models. To use, you should have the aleph_alpha_client python package installed, and the environment variable ALEPH_ALPHA_API_KEY set with your API k...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-5
field log_probs: Optional[int] = None# Number of top log probabilities to be returned for each generated token. field logit_bias: Optional[Dict[int, float]] = None# The logit bias allows to influence the likelihood of generating tokens. field maximum_tokens: int = 64# The maximum number of tokens to be generated. field...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-6
Number of most likely tokens to consider at each step. field top_p: float = 0.0# Total probability mass of tokens to consider at each step. field use_multiplicative_presence_penalty: Optional[bool] = False# Flag deciding whether presence penalty is applied multiplicatively (True) or additively (False). field verbose: b...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-7
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclu...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-8
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://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-9
Wrapper around Anthropic’s large language models. To use, you should have the anthropic python package installed, and the environment variable ANTHROPIC_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example import anthropic from langchain.llms import Anthropic model = Anthropic(mode...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-10
field verbose: bool [Optional]# Whether to print out response text. __call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → str# Check Cache and run the LLM on the given prompt and inpu...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-11
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] = None, deep: bool = False) → Model# Duplicate a model, optionally...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-12
get_token_ids(text: str) → List[int]# 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_...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-13
Returns A generator representing the stream of tokens from Anthropic. Example prompt = "Write a poem about a stream." prompt = f"\n\nHuman: {prompt}\n\nAssistant:" generator = anthropic.stream(prompt) for token in generator: yield token classmethod update_forward_refs(**localns: Any) → None# Try to update ForwardRe...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-14
Check Cache and run the LLM on the given prompt and input. async agenerate(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 pro...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-15
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 creating the new model: you should trust this data deep – set to True to make a deep co...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-16
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://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-17
in, even if not explicitly saved on this class. Example from langchain.llms import AzureOpenAI openai = AzureOpenAI(model_name="text-davinci-003") Validators build_extra » all fields raise_deprecation » all fields set_verbose » verbose validate_environment » all fields field allowed_special: Union[Literal['all'], Abstr...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-18
field presence_penalty: float = 0# Penalizes repeated tokens. field request_timeout: Optional[Union[float, Tuple[float, float]]] = None# Timeout for requests to OpenAI completion API. Default is 600 seconds. field streaming: bool = False# Whether to stream the results or not. field temperature: float = 0.7# What sampli...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-19
Predict message from messages. classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model# Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set ...
https://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-20
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://python.langchain.com/en/latest/reference/modules/llms.html
479f31c64c6b-21
Parameters prompt – The prompt to pass into the model. Returns The maximum number of tokens to generate for a prompt. Example max_tokens = openai.max_token_for_prompt("Tell me a joke.") modelname_to_contextsize(modelname: str) → int# Calculate the maximum number of tokens possible to generate for a model. Parameters mo...
https://python.langchain.com/en/latest/reference/modules/llms.html