id
stringlengths
14
15
text
stringlengths
101
5.26k
source
stringlengths
57
120
64456b903bc9-1
field entity_cache: List[str] = []# field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
64456b903bc9-2
information about knowledge triples in the conversation. field ai_prefix: str = 'AI'# field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a c...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
64456b903bc9-3
field kg: langchain.graphs.networkx_graph.NetworkxEntityGraph [Optional]# field knowledge_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template="You are a networked intelligence helping a human track knowled...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
64456b903bc9-4
clear() β†’ None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. prune() β†’ None[source]# Prune buffer if it exceeds max token limit save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversati...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
64456b903bc9-5
set(key: str, value: Optional[str]) β†’ None[source]# Set entity value in store. class langchain.memory.MomentoChatMessageHistory(session_id: str, cache_client: momento.CacheClient, cache_name: str, *, key_prefix: str = 'message_store:', ttl: Optional[timedelta] = None, ensure_cache_exists: bool = True)[source]# Chat mes...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
64456b903bc9-6
exists(key: str) β†’ bool[source]# Check if entity exists in store. get(key: str, default: Optional[str] = None) β†’ Optional[str][source]# Get entity value from store. set(key: str, value: Optional[str]) β†’ None[source]# Set entity value in store. property full_key_prefix: str# pydantic model langchain.memory.SQLiteEntityS...
https://langchain.readthedocs.io/en/latest/reference/modules/memory.html
d82e18b5bc14-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://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-1
Toolkit for web browser tools. field async_browser: Optional['AsyncBrowser'] = None# field sync_browser: Optional['SyncBrowser'] = None# classmethod from_browser(sync_browser: Optional[SyncBrowser] = None, async_browser: Optional[AsyncBrowser] = None) β†’ PlayWrightBrowserToolkit[source]# Instantiate the toolkit. get_too...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-2
Create csv agent by loading to a dataframe and using pandas agent. 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:...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-3
Construct a json agent from an LLM and tools. 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 ...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-4
Construct a pandas agent from an LLM and dataframe. 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: ...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-5
Construct a pbi agent from an LLM and tools. 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: Opt...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-6
Construct a spark agent from an LLM and dataframe. 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: s...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
d82e18b5bc14-7
Construct a sql agent from an LLM and tools. 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 a...
https://langchain.readthedocs.io/en/latest/reference/modules/agent_toolkits.html
e3a914c29c6c-0
.rst .pdf Document Transformers Document Transformers# Transform documents pydantic model langchain.document_transformers.EmbeddingsRedundantFilter[source]# Filter that drops redundant documents by comparing their embeddings. field embeddings: langchain.embeddings.base.Embeddings [Required]# Embeddings to use for embed...
https://langchain.readthedocs.io/en/latest/reference/modules/document_transformers.html
35c54f5cf747-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://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-1
Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. field verbose: bool = False# Whether to log the tool’s progress. async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', col...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-2
pydantic model langchain.tools.DuckDuckGoSearchResults[source]# Tool that queries the Duck Duck Go Search API and get back json. field api_wrapper: langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper [Optional]# field num_results: int = 4# pydantic model langchain.tools.DuckDuckGoSearchRun[source]# Tool th...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-3
pydantic model langchain.tools.GmailGetThread[source]# field args_schema: Type[langchain.tools.gmail.get_thread.GetThreadSchema] = <class 'langchain.tools.gmail.get_thread.GetThreadSchema'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to search for emai...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-4
pydantic model langchain.tools.ListPowerBITool[source]# 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: langc...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-5
pydantic model langchain.tools.OpenWeatherMapQueryRun[source]# Tool that adds the capability to query using the OpenWeatherMap API. field api_wrapper: langchain.utilities.openweathermap.OpenWeatherMapAPIWrapper [Optional]# pydantic model langchain.tools.PubmedQueryRun[source]# Tool that adds the capability to search us...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-6
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://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-7
AVERAGEX(<table>,<expression>) - these are all variantions of average functions.\nMAX(<column>), MAXA(<column>), MAXX(<table>,<expression>) - these are all variantions of max functions.\nMIN(<column>), MINA(<column>), MINX(<table>,<expression>) - these are all variantions of min functions.\nPRODUCT(<column>), PRODUCTX(...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-8
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://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-9
pydantic model langchain.tools.VectorStoreQATool[source]# Tool for the VectorDBQA chain. To be initialized with name and chain. static get_description(name: str, description: str) β†’ str[source]# pydantic model langchain.tools.VectorStoreQAWithSourcesTool[source]# Tool for the VectorDBQAWithSources chain. static get_des...
https://langchain.readthedocs.io/en/latest/reference/modules/tools.html
35c54f5cf747-10
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://langchain.readthedocs.io/en/latest/reference/modules/tools.html
02eaaead57f5-0
.rst .pdf Models Contents Model Types Models# Note Conceptual Guide This section of the documentation deals with different types of models that are used in LangChain. On this page we will go over the model types at a high level, but we have individual pages for each model type. The pages contain more detailed β€œhow-to...
https://langchain.readthedocs.io/en/latest/modules/models.html
aeea8047b05a-0
.rst .pdf Prompts Prompts# Note Conceptual Guide The new way of programming models is through prompts. A prompt refers to the input to the model. This input is often constructed from multiple components. A PromptTemplate is responsible for the construction of this input. LangChain provides several classes and functions...
https://langchain.readthedocs.io/en/latest/modules/prompts.html
7b04887d7def-0
.rst .pdf Indexes Contents Index Types Indexes# Note Conceptual Guide Indexes refer to ways to structure documents so that LLMs can best interact with them. The most common way that indexes are used in chains is in a β€œretrieval” step. This step refers to taking a user’s query and returning the most relevant documents...
https://langchain.readthedocs.io/en/latest/modules/indexes.html
4b37dba65969-0
.rst .pdf Chains Chains# Note Conceptual Guide Using an LLM in isolation is fine for some simple applications, but more complex applications require chaining LLMs - either with each other or with other experts. LangChain provides a standard interface for Chains, as well as several common implementations of chains. Gett...
https://langchain.readthedocs.io/en/latest/modules/chains.html
38481b646b42-0
.rst .pdf Agents Contents Action Agents Plan-and-Execute Agents Agents# Note Conceptual Guide Some applications require not just a predetermined chain of calls to LLMs/other tools, but potentially an unknown chain that depends on the user’s input. In these types of chains, there is an agent which has access to a suit...
https://langchain.readthedocs.io/en/latest/modules/agents.html
4b048f9cead6-0
.rst .pdf Memory Memory# Note Conceptual Guide By default, Chains and Agents are stateless, meaning that they treat each incoming query independently (as are the underlying LLMs and chat models). In some applications (chatbots being a GREAT example) it is highly important to remember previous interactions, both at a sh...
https://langchain.readthedocs.io/en/latest/modules/memory.html
f22f920cac97-0
.rst .pdf LLMs LLMs# Note Conceptual Guide Large Language Models (LLMs) are a core component of LangChain. LangChain is not a provider of LLMs, but rather provides a standard interface through which you can interact with a variety of LLMs. The following sections of documentation are provided: Getting Started: An overvi...
https://langchain.readthedocs.io/en/latest/modules/models/llms.html
394e80e1d743-0
.rst .pdf Text Embedding Models Text Embedding Models# Note Conceptual Guide This documentation goes over how to use the Embedding class in LangChain. The Embedding class is a class designed for interfacing with embeddings. There are lots of Embedding providers (OpenAI, Cohere, Hugging Face, etc) - this class is design...
https://langchain.readthedocs.io/en/latest/modules/models/text_embedding.html
a1ec9c95141e-0
.ipynb .pdf Getting Started Contents Language Models text -> text interface messages -> message interface Getting Started# One of the core value props of LangChain is that it provides a standard interface to models. This allows you to swap easily between models. At a high level, there are two main types of models: La...
https://langchain.readthedocs.io/en/latest/modules/models/getting_started.html
9d86444f89bc-0
.rst .pdf Chat Models Chat Models# Note Conceptual Guide Chat models are a variation on language models. While chat models use language models under the hood, the interface they expose is a bit different. Rather than expose a β€œtext in, text out” API, they expose an interface where β€œchat messages” are the inputs and out...
https://langchain.readthedocs.io/en/latest/modules/models/chat.html
f97316815651-0
.ipynb .pdf Getting Started Contents PromptTemplates LLMChain Streaming Getting Started# This notebook covers how to get started with chat models. The interface is based around messages rather than raw text. from langchain.chat_models import ChatOpenAI from langchain import PromptTemplate, LLMChain from langchain.pro...
https://langchain.readthedocs.io/en/latest/modules/models/chat/getting_started.html
f97316815651-1
"J'adore la programmation." Streaming# Streaming is supported for ChatOpenAI through callback handling. from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler chat = ChatOpenAI(streaming=True, callbacks=[StreamingStdOutCallbackHandler()], temperature=0) resp = chat([HumanMessage(content="Write ...
https://langchain.readthedocs.io/en/latest/modules/models/chat/getting_started.html
030cc8cbd4d1-0
.rst .pdf How-To Guides How-To Guides# The examples here all address certain β€œhow-to” guides for working with chat models. How to use few shot examples How to stream responses previous Getting Started next How to use few shot examples By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated ...
https://langchain.readthedocs.io/en/latest/modules/models/chat/how_to_guides.html
6bc58d8ac987-0
.rst .pdf Integrations Integrations# The examples here all highlight how to integrate with different chat models. Anthropic Azure Google Vertex AI PaLM OpenAI PromptLayer ChatOpenAI previous How to stream responses next Anthropic By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Ju...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations.html
23e07c25024d-0
.ipynb .pdf PromptLayer ChatOpenAI Contents Install PromptLayer Imports Set the Environment API Key Use the PromptLayerOpenAI LLM like normal Using PromptLayer Track PromptLayer ChatOpenAI# PromptLayer is a devtool that allows you to track, manage, and share your GPT prompt engineering. It acts as a middleware betwee...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations/promptlayer_chatopenai.html
9b25e26baf98-0
.ipynb .pdf Google Vertex AI PaLM Google Vertex AI PaLM# Vertex AI is a machine learning (ML) platform that lets you train and deploy ML models and AI applications. Vertex AI combines data engineering, data science, and ML engineering workflows, enabling your teams to collaborate using a common toolset. Note: This is s...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations/google_vertex_ai_palm.html
68bc3168b86a-0
.ipynb .pdf Anthropic Contents ChatAnthropic also supports async and streaming functionality: Anthropic# Anthropic is an American artificial intelligence (AI) startup and public-benefit corporation, founded by former members of OpenAI. Anthropic specializes in developing general AI systems and language models, with a...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations/anthropic.html
9d0d21a46ae0-0
.ipynb .pdf OpenAI OpenAI# This notebook covers how to get started with OpenAI chat models. from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate, SystemMessagePromptTemplate, AIMessagePromptTemplate, HumanMessagePromptTemplate, ) from langchain.schema impo...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations/openai.html
d57d7dc8daab-0
.ipynb .pdf Azure Azure# This notebook goes over how to connect to an Azure hosted OpenAI endpoint from langchain.chat_models import AzureChatOpenAI from langchain.schema import HumanMessage BASE_URL = "https://${TODO}.openai.azure.com" API_KEY = "..." DEPLOYMENT_NAME = "chat" model = AzureChatOpenAI( openai_api_ba...
https://langchain.readthedocs.io/en/latest/modules/models/chat/integrations/azure_chat_openai.html
a36603026f21-0
.ipynb .pdf How to stream responses How to stream responses# This notebook goes over how to use streaming with a chat model. from langchain.chat_models import ChatOpenAI from langchain.schema import ( HumanMessage, ) from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler chat = ChatOpenAI(s...
https://langchain.readthedocs.io/en/latest/modules/models/chat/examples/streaming.html
7def20fc6c66-0
.ipynb .pdf How to use few shot examples Contents Alternating Human/AI messages System Messages How to use few shot examples# This notebook covers how to use few shot examples in chat models. There does not appear to be solid consensus on how best to do few shot prompting. As a result, we are not solidifying any abst...
https://langchain.readthedocs.io/en/latest/modules/models/chat/examples/few_shot_examples.html
6fb7e9b90c68-0
.ipynb .pdf Getting Started Getting Started# This notebook goes over how to use the LLM class in LangChain. The LLM class is a class designed for interfacing with LLMs. There are lots of LLM providers (OpenAI, Cohere, Hugging Face, etc) - this class is designed to provide a standard interface for all of them. In this p...
https://langchain.readthedocs.io/en/latest/modules/models/llms/getting_started.html
4b8f8b8e2431-0
.rst .pdf Generic Functionality Generic Functionality# The examples here all address certain β€œhow-to” guides for working with LLMs. How to use the async API for LLMs How to write a custom LLM wrapper How (and why) to use the fake LLM How (and why) to use the human input LLM How to cache LLM calls How to serialize LLM c...
https://langchain.readthedocs.io/en/latest/modules/models/llms/how_to_guides.html
edf776916a32-0
.rst .pdf Integrations Integrations# The examples here are all β€œhow-to” guides for how to integrate with various LLM providers. AI21 Aleph Alpha Anyscale Aviary Azure OpenAI Banana Beam Bedrock CerebriumAI Cohere C Transformers Databricks DeepInfra ForefrontAI Google Cloud Platform Vertex AI PaLM GooseAI GPT4All Huggin...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations.html
cef8273f7d60-0
.ipynb .pdf ForefrontAI Contents Imports Set the Environment API Key Create the ForefrontAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain ForefrontAI# The Forefront platform gives you the ability to fine-tune and use open source large language models. This notebook goes over how to use Lang...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/forefrontai_example.html
3789748e1823-0
.ipynb .pdf Azure OpenAI Contents API configuration Deployments Azure OpenAI# This notebook goes over how to use Langchain with Azure OpenAI. The Azure OpenAI API is compatible with OpenAI’s API. The openai Python package makes it easy to use both OpenAI and Azure OpenAI. You can call Azure OpenAI the same way you ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/azure_openai_example.html
55825e7c57cb-0
.ipynb .pdf Anyscale Anyscale# Anyscale is a fully-managed Ray platform, on which you can build, deploy, and manage scalable AI and Python applications This example goes over how to use LangChain to interact with Anyscale service import os os.environ["ANYSCALE_SERVICE_URL"] = ANYSCALE_SERVICE_URL os.environ["ANYSCALE_S...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/anyscale.html
6824c50dd26d-0
.ipynb .pdf Bedrock Contents Using in a conversation chain Bedrock# Amazon Bedrock is a fully managed service that makes FMs from leading AI startups and Amazon available via an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case %pip install boto3 from langchain.ll...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/bedrock.html
0c8cdeb5635e-0
.ipynb .pdf Runhouse Runhouse# The Runhouse allows remote compute and data across environments and users. See the Runhouse docs. This example goes over how to use LangChain and Runhouse to interact with models hosted on your own GPU, or on-demand GPUs on AWS, GCP, AWS, or Lambda. Note: Code uses SelfHosted name instead...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/runhouse.html
0c8cdeb5635e-1
llm = SelfHostedPipeline.from_pipeline(pipeline="models/pipeline.pkl", hardware=gpu) previous Replicate next SageMaker Endpoint By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/runhouse.html
db70a1dc79f4-0
.ipynb .pdf AI21 AI21# AI21 Studio provides API access to Jurassic-2 large language models. This example goes over how to use LangChain to interact with AI21 models. # install the package: !pip install ai21 # get AI21_API_KEY. Use https://studio.ai21.com/account/account from getpass import getpass AI21_API_KEY = getpa...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/ai21.html
03570e9198c0-0
.ipynb .pdf OpenLM Contents Setup Using LangChain with OpenLM OpenLM# OpenLM is a zero-dependency OpenAI-compatible LLM provider that can call different inference endpoints directly via HTTP. It implements the OpenAI Completion class so that it can be used as a drop-in replacement for the OpenAI API. This changeset u...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/openlm.html
05d1989954ed-0
.ipynb .pdf Manifest Contents Compare HF Models Manifest# This notebook goes over how to use Manifest and LangChain. For more detailed information on manifest, and how to use it with local hugginface models like in this example, see https://github.com/HazyResearch/manifest Another example of using Manifest with Langc...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/manifest.html
be1cc2036820-0
.ipynb .pdf GooseAI Contents Install openai Imports Set the Environment API Key Create the GooseAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain GooseAI# GooseAI is a fully managed NLP-as-a-Service, delivered via API. GooseAI provides access to these models. This notebook goes over how to u...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/gooseai_example.html
01573e1dcd4a-0
.ipynb .pdf NLP Cloud NLP Cloud# The NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text g...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/nlpcloud.html
dbba96b7ddd9-0
.ipynb .pdf Beam Beam# Beam makes it easy to run code on GPUs, deploy scalable web APIs, schedule cron jobs, and run massively parallel workloads β€” without managing any infrastructure. Calls the Beam API wrapper to deploy and make subsequent calls to an instance of the gpt2 LLM in a cloud deployment. Requires installat...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/beam.html
b8a5e880a727-0
.ipynb .pdf Hugging Face Hub Contents Examples StableLM, by Stability AI Dolly, by Databricks Camel, by Writer Hugging Face Hub# The Hugging Face Hub is a platform with over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source and publicly available, in an online platform where people can easily col...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/huggingface_hub.html
bb805bf9082e-0
.ipynb .pdf SageMaker Endpoint Contents Set up Example SageMaker Endpoint# Amazon SageMaker is a system that can build, train, and deploy machine learning (ML) models for any use case with fully managed infrastructure, tools, and workflows. This notebooks goes over how to use an LLM hosted on a SageMaker endpoint. !p...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/sagemaker.html
6c1927bdabca-0
.ipynb .pdf Google Cloud Platform Vertex AI PaLM Google Cloud Platform Vertex AI PaLM# Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there. PaLM API on Vertex AI is a Preview offering, su...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/google_vertex_ai_palm.html
c1d86a971c0c-0
.ipynb .pdf GPT4All Contents Specify Model GPT4All# GitHub:nomic-ai/gpt4all an ecosystem of open-source chatbots trained on a massive collections of clean assistant data including code, stories and dialogue. This example goes over how to use LangChain to interact with GPT4All models. %pip install gpt4all > /dev/null ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/gpt4all.html
5f31a564acc1-0
.ipynb .pdf Huggingface TextGen Inference Huggingface TextGen Inference# Text Generation Inference is a Rust, Python and gRPC server for text generation inference. Used in production at HuggingFace to power LLMs api-inference widgets. This notebooks goes over how to use a self hosted LLM using Text Generation Inference...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/huggingface_textgen_inference.html
8b5dfee89727-0
.ipynb .pdf Llama-cpp Contents Installation CPU only installation Installation with OpenBLAS / cuBLAS / CLBlast Usage CPU GPU Llama-cpp# llama-cpp is a Python binding for llama.cpp. It supports several LLMs. This notebook goes over how to run llama-cpp within LangChain. Installation# There is a banch of options how t...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/llamacpp.html
8b5dfee89727-1
n_batch - how many tokens are processed in parallel. Setting these parameters correctly will dramatically improve the evaluation speed (see wrapper code for more details). n_gpu_layers = 40 # Change this value based on your model and your GPU VRAM pool. n_batch = 512 # Should be between 1 and n_ctx, consider the amount...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/llamacpp.html
526d94c3c4a5-0
.ipynb .pdf CerebriumAI Contents Install cerebrium Imports Set the Environment API Key Create the CerebriumAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain CerebriumAI# Cerebrium is an AWS Sagemaker alternative. It also provides API access to several LLM models. This notebook goes over how ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/cerebriumai_example.html
ba134dac5dc0-0
.ipynb .pdf DeepInfra Contents Imports Set the Environment API Key Create the DeepInfra instance Create a Prompt Template Initiate the LLMChain Run the LLMChain DeepInfra# DeepInfra provides several LLMs. This notebook goes over how to use Langchain with DeepInfra. Imports# import os from langchain.llms import DeepIn...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/deepinfra_example.html
142d2e6d9403-0
.ipynb .pdf OpenAI OpenAI# OpenAI offers a spectrum of models with different levels of power suitable for different tasks. This example goes over how to use LangChain to interact with OpenAI models # get a token: https://platform.openai.com/account/api-keys from getpass import getpass OPENAI_API_KEY = getpass() Β·Β·Β·Β·Β·Β·...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/openai.html
a0c475e9c443-0
.ipynb .pdf Petals Contents Install petals Imports Set the Environment API Key Create the Petals instance Create a Prompt Template Initiate the LLMChain Run the LLMChain Petals# Petals runs 100B+ language models at home, BitTorrent-style. This notebook goes over how to use Langchain with Petals. Install petals# The p...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/petals_example.html
573c61cdf0b6-0
.ipynb .pdf Aviary Aviary# Aviary is an open source tooklit for evaluating and deploying production open source LLMs. This example goes over how to use LangChain to interact with Aviary. You can try Aviary out https://aviary.anyscale.com. You can find out more about Aviary at https://github.com/ray-project/aviary. One ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/aviary.html
c18caeb8fbe7-0
.ipynb .pdf ReLLM Contents Hugging Face Baseline RELLM LLM Wrapper ReLLM# ReLLM is a library that wraps local Hugging Face pipeline models for structured decoding. It works by generating tokens one at a time. At each step, it masks tokens that don’t conform to the provided partial regular expression. Warning - this m...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/rellm_experimental.html
27647d5369bb-0
.ipynb .pdf PipelineAI Contents Install pipeline-ai Imports Set the Environment API Key Create the PipelineAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain PipelineAI# PipelineAI allows you to run your ML models at scale in the cloud. It also provides API access to several LLM models. This ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/pipelineai_example.html
a1fc71f33da1-0
.ipynb .pdf PromptLayer OpenAI Contents Install PromptLayer Imports Set the Environment API Key Use the PromptLayerOpenAI LLM like normal Using PromptLayer Track PromptLayer OpenAI# PromptLayer is the first platform that allows you to track, manage, and share your GPT prompt engineering. PromptLayer acts a middleware...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/promptlayer_openai.html
4332467bf60c-0
.ipynb .pdf Databricks Contents Wrapping a serving endpoint Wrapping a cluster driver proxy app Databricks# The Databricks Lakehouse Platform unifies data, analytics, and AI on one platform. This example notebook shows how to wrap Databricks endpoints as LLMs in LangChain. It supports two endpoint types: Serving endp...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/databricks.html
4332467bf60c-1
model = "databricks/dolly-v2-3b" tokenizer = AutoTokenizer.from_pretrained(model, padding_side="left") dolly = pipeline(model=model, tokenizer=tokenizer, trust_remote_code=True, device_map="auto") device = dolly.device class CheckStop(StoppingCriteria): def __init__(self, stop=None): super().__init__() ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/databricks.html
a89dda4b28f9-0
.ipynb .pdf Prediction Guard Contents Prediction Guard Control the output structure/ type of LLMs Chaining Prediction Guard# Prediction Guard gives a quick and easy access to state-of-the-art open and closed access LLMs, without needing to spend days and weeks figuring out all of the implementation details, managing...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/predictionguard.html
202ea09dce66-0
.ipynb .pdf Jsonformer Contents HuggingFace Baseline JSONFormer LLM Wrapper Jsonformer# Jsonformer is a library that wraps local HuggingFace pipeline models for structured decoding of a subset of the JSON Schema. It works by filling in the structure tokens and then sampling the content tokens from the model. Warning ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/jsonformer_experimental.html
202ea09dce66-1
json_former = JsonFormer(json_schema=decoder_schema, pipeline=hf_model) results = json_former.predict(prompt, stop=["Observation:", "Human:"]) print(results) {"action": "ask_star_coder", "action_input": {"query": "What's the difference between an iterator and an iter", "temperature": 0.0, "max_new_tokens": 50.0}} Voila...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/jsonformer_experimental.html
8e17057eb757-0
.ipynb .pdf StochasticAI StochasticAI# Stochastic Acceleration Platform aims to simplify the life cycle of a Deep Learning model. From uploading and versioning the model, through training, compression and acceleration to putting it into production. This example goes over how to use LangChain to interact with Stochastic...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/stochasticai.html
5090d5c6c019-0
.ipynb .pdf C Transformers C Transformers# The C Transformers library provides Python bindings for GGML models. This example goes over how to use LangChain to interact with C Transformers models. Install %pip install ctransformers Load Model from langchain.llms import CTransformers llm = CTransformers(model='marella/gp...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/ctransformers.html
3be102031509-0
.ipynb .pdf Banana Banana# Banana is focused on building the machine learning infrastructure. This example goes over how to use LangChain to interact with Banana models # Install the package https://docs.banana.dev/banana-docs/core-concepts/sdks/python !pip install banana-dev # get new tokens: https://app.banana.dev/ ...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/banana.html
b4380670ce9e-0
.ipynb .pdf Writer Writer# Writer is a platform to generate different language content. This example goes over how to use LangChain to interact with Writer models. You have to get the WRITER_API_KEY here. from getpass import getpass WRITER_API_KEY = getpass() import os os.environ["WRITER_API_KEY"] = WRITER_API_KEY from...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/writer.html
f0f0e4d0eefe-0
.ipynb .pdf Hugging Face Pipeline Contents Load the model Integrate the model in an LLMChain Hugging Face Pipeline# Hugging Face models can be run locally through the HuggingFacePipeline class. The Hugging Face Model Hub hosts over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source and publicly av...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/huggingface_pipelines.html
99359df7ce00-0
.ipynb .pdf Aleph Alpha Aleph Alpha# The Luminous series is a family of large language models. This example goes over how to use LangChain to interact with Aleph Alpha models # Install the package !pip install aleph-alpha-client # create a new token: https://docs.aleph-alpha.com/docs/account/#create-a-new-token from ge...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/aleph_alpha.html
3a596b67fd81-0
.ipynb .pdf MosaicML MosaicML# MosaicML offers a managed inference service. You can either use a variety of open source models, or deploy your own. This example goes over how to use LangChain to interact with MosaicML Inference for text completion. # sign up for an account: https://forms.mosaicml.com/demo?utm_source=la...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/mosaicml.html
3a54aa28c60c-0
.ipynb .pdf Replicate Contents Setup Calling a model Chaining Calls Replicate# Replicate runs machine learning models in the cloud. We have a library of open-source models that you can run with a few lines of code. If you’re building your own machine learning models, Replicate makes it easy to deploy them at scale. T...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/replicate.html
3a54aa28c60c-1
Second prompt to get the logo for company description second_prompt = PromptTemplate( input_variables=["company_name"], template="Write a description of a logo for this company: {company_name}", ) chain_two = LLMChain(llm=dolly_llm, prompt=second_prompt) Third prompt, let’s create the image based on the descrip...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/replicate.html
fcabce51c202-0
.ipynb .pdf Cohere Cohere# Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions. This example goes over how to use LangChain to interact with Cohere models. # Install the package !pip install cohere # get a new token: https://dashboard.cohe...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/cohere.html
bf714b54d5fb-0
.ipynb .pdf Modal Modal# The Modal Python Library provides convenient, on-demand access to serverless cloud compute from Python scripts on your local computer. The Modal itself does not provide any LLMs but only the infrastructure. This example goes over how to use LangChain to interact with Modal. Here is another exam...
https://langchain.readthedocs.io/en/latest/modules/models/llms/integrations/modal.html
e98a40784bdd-0
.ipynb .pdf How (and why) to use the fake LLM How (and why) to use the fake LLM# We expose a fake LLM class that can be used for testing. This allows you to mock out calls to the LLM and simulate what would happen if the LLM responded in a certain way. In this notebook we go over how to use this. We start this with usi...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/fake_llm.html
ccc5f662796f-0
.ipynb .pdf How to write a custom LLM wrapper How to write a custom LLM wrapper# This notebook goes over how to create a custom LLM wrapper, in case you want to use your own LLM or a different wrapper than one that is supported in LangChain. There is only one required thing that a custom LLM needs to implement: A _call...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/custom_llm.html
54e11334c9f2-0
.ipynb .pdf How to cache LLM calls Contents In Memory Cache SQLite Cache Redis Cache Standard Cache Semantic Cache GPTCache Momento Cache SQLAlchemy Cache Custom SQLAlchemy Schemas Optional Caching Optional Caching in Chains How to cache LLM calls# This notebook covers how to cache results of individual LLM calls. im...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/llm_caching.html
54e11334c9f2-1
Wall time: 262 ms "\n\nWhy don't scientists trust atoms?\nBecause they make up everything." GPTCache# We can use GPTCache for exact match caching OR to cache results based on semantic similarity Let’s first start with an example of exact match from gptcache import Cache from gptcache.manager.factory import manager_fact...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/llm_caching.html
54e11334c9f2-2
# When run in the same region as the cache, latencies are single digit ms llm("Tell me a joke") CPU times: user 3.16 ms, sys: 2.98 ms, total: 6.14 ms Wall time: 57.9 ms '\n\nWhy did the chicken cross the road?\n\nTo get to the other side!' SQLAlchemy Cache# # You can use SQLAlchemyCache to cache with any SQL database s...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/llm_caching.html
54e11334c9f2-3
Wall time: 5.09 s '\n\nPresident Biden is discussing the American Rescue Plan and the Bipartisan Infrastructure Law, which will create jobs and help Americans. He also talks about his vision for America, which includes investing in education and infrastructure. In response to Russian aggression in Ukraine, the United S...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/llm_caching.html
05a8334ed79d-0
.ipynb .pdf How to track token usage How to track token usage# This notebook goes over how to track your token usage for specific calls. It is currently only implemented for the OpenAI API. Let’s first look at an extremely simple example of tracking token usage for a single LLM call. from langchain.llms import OpenAI f...
https://langchain.readthedocs.io/en/latest/modules/models/llms/examples/token_usage_tracking.html