(langchain.llms.PromptLayerOpenAI method)
    module

langchain.agents
langchain.agents.agent_toolkits
langchain.chains
langchain.chat_models
langchain.docstore
langchain.document_loaders
langchain.document_transformers
langchain.embeddings
langchain.llms
langchain.memory
langchain.output_parsers
langchain.prompts
langchain.prompts.example_selector
langchain.python
langchain.retrievers
langchain.retrievers.document_compressors
langchain.serpapi
langchain.text_splitter
langchain.tools
langchain.utilities
langchain.utilities.searx_search
langchain.vectorstores
moving_summary_buffer (langchain.memory.ConversationSummaryBufferMemory attribute)
MyScale (class in langchain.vectorstores)
N
n (langchain.chat_models.ChatOpenAI attribute)
(langchain.llms.AlephAlpha attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.GooseAI attribute)
n_batch (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
n_ctx (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
n_parts (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
n_predict (langchain.llms.GPT4All attribute)
n_threads (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
name (langchain.agents.agent_toolkits.VectorStoreInfo attribute)
(langchain.experimental.GenerativeAgent attribute)


(langchain.experimental.GenerativeAgent attribute)
(langchain.llms.PredictionGuard attribute)
(langchain.output_parsers.ResponseSchema attribute)
(langchain.tools.BaseTool attribute)
(langchain.tools.ClickTool attribute)
(langchain.tools.CopyFileTool attribute)
(langchain.tools.CurrentWebPageTool attribute)
(langchain.tools.DeleteFileTool attribute)
(langchain.tools.ExtractHyperlinksTool attribute)
(langchain.tools.ExtractTextTool attribute)
(langchain.tools.FileSearchTool attribute)
(langchain.tools.GetElementsTool attribute)
(langchain.tools.ListDirectoryTool attribute)
(langchain.tools.MoveFileTool attribute)
(langchain.tools.NavigateBackTool attribute)
(langchain.tools.NavigateTool attribute)
(langchain.tools.ReadFileTool attribute)
(langchain.tools.ShellTool attribute)
(langchain.tools.WriteFileTool attribute)
nla_tools (langchain.agents.agent_toolkits.NLAToolkit attribute)
NLTKTextSplitter (class in langchain.text_splitter)
no_update_value (langchain.output_parsers.RegexDictParser attribute)
normalize (langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding attribute)
NotebookLoader (class in langchain.document_loaders)
NotionDBLoader (class in langchain.document_loaders)
NotionDirectoryLoader (class in langchain.document_loaders)
num_beams (langchain.llms.NLPCloud attribute)
num_results (langchain.tools.BingSearchResults attribute)
(langchain.tools.DuckDuckGoSearchResults attribute)
(langchain.tools.GoogleSearchResults attribute)
num_return_sequences (langchain.llms.NLPCloud attribute)
numResults (langchain.llms.AI21 attribute)
O
observation_prefix (langchain.agents.Agent property)
(langchain.agents.ConversationalAgent property)
(langchain.agents.ConversationalChatAgent property)


(langchain.agents.ConversationalChatAgent property)
(langchain.agents.ZeroShotAgent property)
ObsidianLoader (class in langchain.document_loaders)
OnlinePDFLoader (class in langchain.document_loaders)
openai_api_base (langchain.chat_models.AzureChatOpenAI attribute)
openai_api_key (langchain.chains.OpenAIModerationChain attribute)
(langchain.chat_models.AzureChatOpenAI attribute)
(langchain.chat_models.ChatOpenAI attribute)
openai_api_type (langchain.chat_models.AzureChatOpenAI attribute)
openai_api_version (langchain.chat_models.AzureChatOpenAI attribute)
openai_organization (langchain.chains.OpenAIModerationChain attribute)
(langchain.chat_models.AzureChatOpenAI attribute)
(langchain.chat_models.ChatOpenAI attribute)
openapi (langchain.tools.OpenAPISpec attribute)
OpenSearchVectorSearch (class in langchain.vectorstores)
openweathermap_api_key (langchain.utilities.OpenWeatherMapAPIWrapper attribute)
operation_id (langchain.tools.APIOperation attribute)
other_score_keys (langchain.retrievers.TimeWeightedVectorStoreRetriever attribute)
OutlookMessageLoader (class in langchain.document_loaders)
output_key (langchain.chains.QAGenerationChain attribute)
(langchain.memory.ConversationStringBufferMemory attribute)
output_key_to_format (langchain.output_parsers.RegexDictParser attribute)
output_keys (langchain.chains.ConstitutionalChain property)
(langchain.chains.HypotheticalDocumentEmbedder property)
(langchain.chains.QAGenerationChain property)
(langchain.experimental.BabyAGI property)
(langchain.output_parsers.RegexParser attribute)
output_parser (langchain.agents.Agent attribute)
(langchain.agents.ConversationalAgent attribute)
(langchain.agents.ConversationalChatAgent attribute)


(langchain.agents.ConversationalChatAgent attribute)
(langchain.agents.LLMSingleActionAgent attribute)
(langchain.agents.ReActTextWorldAgent attribute)
(langchain.agents.ZeroShotAgent attribute)
(langchain.prompts.BasePromptTemplate attribute)
output_variables (langchain.chains.TransformChain attribute)
owm (langchain.utilities.OpenWeatherMapAPIWrapper attribute)
P
p (langchain.llms.Cohere attribute)
page_content_key (langchain.retrievers.RemoteLangChainRetriever attribute)
PagedPDFSplitter (in module langchain.document_loaders)
paginate_request() (langchain.document_loaders.ConfluenceLoader method)
param_mapping (langchain.chains.OpenAPIEndpointChain attribute)
params (langchain.serpapi.SerpAPIWrapper attribute)
(langchain.tools.ZapierNLARunAction attribute)
(langchain.utilities.searx_search.SearxSearchWrapper attribute)
(langchain.utilities.SearxSearchWrapper attribute)
(langchain.utilities.SerpAPIWrapper attribute)
params_schema (langchain.tools.ZapierNLARunAction attribute)
parse() (langchain.agents.AgentOutputParser method)
(langchain.output_parsers.CommaSeparatedListOutputParser method)
(langchain.output_parsers.GuardrailsOutputParser method)
(langchain.output_parsers.ListOutputParser method)
(langchain.output_parsers.OutputFixingParser method)
(langchain.output_parsers.PydanticOutputParser method)
(langchain.output_parsers.RegexDictParser method)
(langchain.output_parsers.RegexParser method)
(langchain.output_parsers.RetryOutputParser method)
(langchain.output_parsers.RetryWithErrorOutputParser method)
(langchain.output_parsers.StructuredOutputParser method)
parse_filename() (langchain.document_loaders.BlackboardLoader method)


parse_filename() (langchain.document_loaders.BlackboardLoader method)
parse_obj() (langchain.tools.OpenAPISpec class method)
parse_sitemap() (langchain.document_loaders.SitemapLoader method)
parse_with_prompt() (langchain.output_parsers.RetryOutputParser method)
(langchain.output_parsers.RetryWithErrorOutputParser method)
parser (langchain.output_parsers.OutputFixingParser attribute)
(langchain.output_parsers.RetryOutputParser attribute)
(langchain.output_parsers.RetryWithErrorOutputParser attribute)
partial() (langchain.prompts.BasePromptTemplate method)
(langchain.prompts.ChatPromptTemplate method)
password (langchain.vectorstores.MyScaleSettings attribute)
patch() (langchain.utilities.TextRequestsWrapper method)
path (langchain.tools.APIOperation attribute)
path_params (langchain.tools.APIOperation property)
paths (langchain.tools.OpenAPISpec attribute)
pause_to_reflect() (langchain.experimental.GenerativeAgentMemory method)
PDFMinerLoader (class in langchain.document_loaders)
PDFMinerPDFasHTMLLoader (class in langchain.document_loaders)
penalty_alpha_frequency (langchain.llms.RWKV attribute)
penalty_alpha_presence (langchain.llms.RWKV attribute)
penalty_bias (langchain.llms.AlephAlpha attribute)
penalty_exceptions (langchain.llms.AlephAlpha attribute)
penalty_exceptions_include_stop_sequences (langchain.llms.AlephAlpha attribute)
persist() (langchain.vectorstores.Chroma method)
(langchain.vectorstores.DeepLake method)
Pinecone (class in langchain.vectorstores)
pipeline_key (langchain.llms.PipelineAI attribute)
pipeline_kwargs (langchain.llms.PipelineAI attribute)
pl_tags (langchain.chat_models.PromptLayerChatOpenAI attribute)


pl_tags (langchain.chat_models.PromptLayerChatOpenAI attribute)
plan() (langchain.agents.Agent method)
(langchain.agents.BaseMultiActionAgent method)
(langchain.agents.BaseSingleActionAgent method)
(langchain.agents.LLMSingleActionAgent method)
PlaywrightURLLoader (class in langchain.document_loaders)
plugin (langchain.tools.AIPluginTool attribute)
port (langchain.vectorstores.MyScaleSettings attribute)
post() (langchain.utilities.TextRequestsWrapper method)
PostgresChatMessageHistory (class in langchain.memory)
powerbi (langchain.agents.agent_toolkits.PowerBIToolkit attribute)
predict() (langchain.chains.LLMChain method)
predict_and_parse() (langchain.chains.LLMChain method)
prefix (langchain.prompts.FewShotPromptTemplate attribute)
(langchain.prompts.FewShotPromptWithTemplates attribute)
prefix_messages (langchain.llms.OpenAIChat attribute)
(langchain.llms.PromptLayerOpenAIChat attribute)
prep_prompts() (langchain.chains.LLMChain method)
prep_streaming_params() (langchain.llms.AzureOpenAI method)
(langchain.llms.OpenAI method)
(langchain.llms.PromptLayerOpenAI method)
prepare_cosmos() (langchain.memory.CosmosDBChatMessageHistory method)
presence_penalty (langchain.llms.AlephAlpha attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.Cohere attribute)
(langchain.llms.GooseAI attribute)
presencePenalty (langchain.llms.AI21 attribute)
prioritize_tasks() (langchain.experimental.BabyAGI method)
process (langchain.tools.ShellTool attribute)
process_attachment() (langchain.document_loaders.ConfluenceLoader method)


process_attachment() (langchain.document_loaders.ConfluenceLoader method)
process_doc() (langchain.document_loaders.ConfluenceLoader method)
process_image() (langchain.document_loaders.ConfluenceLoader method)
process_index_results() (langchain.vectorstores.Annoy method)
process_output() (langchain.utilities.BashProcess method)
process_page() (langchain.document_loaders.ConfluenceLoader method)
process_pages() (langchain.document_loaders.ConfluenceLoader method)
process_pdf() (langchain.document_loaders.ConfluenceLoader method)
process_svg() (langchain.document_loaders.ConfluenceLoader method)
process_xls() (langchain.document_loaders.ConfluenceLoader method)
Prompt (in module langchain.prompts)
prompt (langchain.chains.ConversationChain attribute)
(langchain.chains.LLMBashChain attribute)
(langchain.chains.LLMChain attribute)
(langchain.chains.LLMMathChain attribute)
(langchain.chains.PALChain attribute)
(langchain.chains.SQLDatabaseChain attribute)
prompt_func (langchain.tools.HumanInputRun attribute)
properties (langchain.tools.APIOperation attribute)
put() (langchain.utilities.TextRequestsWrapper method)
pydantic_object (langchain.output_parsers.PydanticOutputParser attribute)
PyMuPDFLoader (class in langchain.document_loaders)
PyPDFDirectoryLoader (class in langchain.document_loaders)
PyPDFLoader (class in langchain.document_loaders)
python_globals (langchain.chains.PALChain attribute)
python_locals (langchain.chains.PALChain attribute)
PythonCodeTextSplitter (class in langchain.text_splitter)
PythonLoader (class in langchain.document_loaders)
Q
qa_chain (langchain.chains.GraphQAChain attribute)
Qdrant (class in langchain.vectorstores)


Qdrant (class in langchain.vectorstores)
query_instruction (langchain.embeddings.HuggingFaceInstructEmbeddings attribute)
(langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings attribute)
query_name (langchain.vectorstores.SupabaseVectorStore attribute)
query_params (langchain.tools.APIOperation property)
query_suffix (langchain.utilities.searx_search.SearxSearchWrapper attribute)
(langchain.utilities.SearxSearchWrapper attribute)
question_to_checked_assertions_chain (langchain.chains.LLMCheckerChain attribute)
R
random_seed (langchain.llms.Writer attribute)
raw_completion (langchain.llms.AlephAlpha attribute)
REACT_DOCSTORE (langchain.agents.AgentType attribute)
ReadTheDocsLoader (class in langchain.document_loaders)
recall_ttl (langchain.memory.RedisEntityStore attribute)
recursive (langchain.document_loaders.GoogleDriveLoader attribute)
RecursiveCharacterTextSplitter (class in langchain.text_splitter)
RedditPostsLoader (class in langchain.document_loaders)
Redis (class in langchain.vectorstores)
redis_client (langchain.memory.RedisEntityStore attribute)
RedisChatMessageHistory (class in langchain.memory)
RedisEntityStore (class in langchain.memory)
reduce_k_below_max_tokens (langchain.chains.RetrievalQAWithSourcesChain attribute)
(langchain.chains.VectorDBQAWithSourcesChain attribute)
reflection_threshold (langchain.experimental.GenerativeAgentMemory attribute)
regex (langchain.output_parsers.RegexParser attribute)
regex_pattern (langchain.output_parsers.RegexDictParser attribute)
region_name (langchain.embeddings.SagemakerEndpointEmbeddings attribute)
(langchain.llms.SagemakerEndpoint attribute)
relevancy_threshold (langchain.retrievers.SVMRetriever attribute)


relevancy_threshold (langchain.retrievers.SVMRetriever attribute)
remove_end_sequence (langchain.llms.NLPCloud attribute)
remove_input (langchain.llms.NLPCloud attribute)
repeat_last_n (langchain.llms.GPT4All attribute)
repeat_penalty (langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
repetition_penalties_include_completion (langchain.llms.AlephAlpha attribute)
repetition_penalties_include_prompt (langchain.llms.AlephAlpha attribute)
repetition_penalty (langchain.llms.ForefrontAI attribute)
(langchain.llms.NLPCloud attribute)
(langchain.llms.Writer attribute)
repo_id (langchain.embeddings.HuggingFaceHubEmbeddings attribute)
(langchain.llms.HuggingFaceHub attribute)
request_body (langchain.tools.APIOperation attribute)
request_timeout (langchain.chat_models.ChatOpenAI attribute)
(langchain.llms.AzureOpenAI attribute)
request_url (langchain.utilities.PowerBIDataset property)
requests (langchain.chains.OpenAPIEndpointChain attribute)
(langchain.utilities.TextRequestsWrapper property)
requests_per_second (langchain.document_loaders.WebBaseLoader attribute)
requests_wrapper (langchain.agents.agent_toolkits.OpenAPIToolkit attribute)
(langchain.chains.APIChain attribute)
(langchain.chains.LLMRequestsChain attribute)
response_key (langchain.retrievers.RemoteLangChainRetriever attribute)
response_schemas (langchain.output_parsers.StructuredOutputParser attribute)
results() (langchain.serpapi.SerpAPIWrapper method)
(langchain.utilities.BingSearchAPIWrapper method)
(langchain.utilities.GoogleSearchAPIWrapper method)
(langchain.utilities.searx_search.SearxSearchWrapper method)
(langchain.utilities.SearxSearchWrapper method)


(langchain.utilities.SearxSearchWrapper method)
(langchain.utilities.SerpAPIWrapper method)
retriever (langchain.chains.ConversationalRetrievalChain attribute)
(langchain.chains.RetrievalQA attribute)
(langchain.chains.RetrievalQAWithSourcesChain attribute)
(langchain.memory.VectorStoreRetrieverMemory attribute)
retry_chain (langchain.output_parsers.OutputFixingParser attribute)
(langchain.output_parsers.RetryOutputParser attribute)
(langchain.output_parsers.RetryWithErrorOutputParser attribute)
return_all (langchain.chains.SequentialChain attribute)
return_direct (langchain.chains.SQLDatabaseChain attribute)
(langchain.tools.BaseTool attribute)
return_docs (langchain.memory.VectorStoreRetrieverMemory attribute)
return_intermediate_steps (langchain.agents.AgentExecutor attribute)
(langchain.agents.MRKLChain attribute)
(langchain.agents.ReActChain attribute)
(langchain.agents.SelfAskWithSearchChain attribute)
(langchain.chains.OpenAPIEndpointChain attribute)
(langchain.chains.PALChain attribute)
(langchain.chains.SQLDatabaseChain attribute)
(langchain.chains.SQLDatabaseSequentialChain attribute)
return_pl_id (langchain.chat_models.PromptLayerChatOpenAI attribute)
return_stopped_response() (langchain.agents.Agent method)
(langchain.agents.BaseMultiActionAgent method)
(langchain.agents.BaseSingleActionAgent method)
return_values (langchain.agents.Agent property)
(langchain.agents.BaseMultiActionAgent property)
(langchain.agents.BaseSingleActionAgent property)
revised_answer_prompt (langchain.chains.LLMCheckerChain attribute)
revised_summary_prompt (langchain.chains.LLMSummarizationCheckerChain attribute)
revision_chain (langchain.chains.ConstitutionalChain attribute)


revision_chain (langchain.chains.ConstitutionalChain attribute)
RoamLoader (class in langchain.document_loaders)
root_dir (langchain.agents.agent_toolkits.FileManagementToolkit attribute)
run() (langchain.python.PythonREPL method)
(langchain.serpapi.SerpAPIWrapper method)
(langchain.tools.BaseTool method)
(langchain.utilities.ArxivAPIWrapper method)
(langchain.utilities.BashProcess method)
(langchain.utilities.BingSearchAPIWrapper method)
(langchain.utilities.GooglePlacesAPIWrapper method)
(langchain.utilities.GoogleSearchAPIWrapper method)
(langchain.utilities.GoogleSerperAPIWrapper method)
(langchain.utilities.LambdaWrapper method)
(langchain.utilities.OpenWeatherMapAPIWrapper method)
(langchain.utilities.PowerBIDataset method)
(langchain.utilities.PythonREPL method)
(langchain.utilities.searx_search.SearxSearchWrapper method)
(langchain.utilities.SearxSearchWrapper method)
(langchain.utilities.SerpAPIWrapper method)
(langchain.utilities.WikipediaAPIWrapper method)
(langchain.utilities.WolframAlphaAPIWrapper method)
rwkv_verbose (langchain.llms.RWKV attribute)
S
S3DirectoryLoader (class in langchain.document_loaders)
S3FileLoader (class in langchain.document_loaders)
sample_rows_in_table_info (langchain.utilities.PowerBIDataset attribute)
save() (langchain.agents.AgentExecutor method)
(langchain.agents.BaseMultiActionAgent method)
(langchain.agents.BaseSingleActionAgent method)
(langchain.llms.AI21 method)
(langchain.llms.AlephAlpha method)
(langchain.llms.Anthropic method)
(langchain.llms.AzureOpenAI method)
(langchain.llms.Banana method)
(langchain.llms.CerebriumAI method)


(langchain.llms.CerebriumAI method)
(langchain.llms.Cohere method)
(langchain.llms.DeepInfra method)
(langchain.llms.ForefrontAI method)
(langchain.llms.GooseAI method)
(langchain.llms.GPT4All method)
(langchain.llms.HuggingFaceEndpoint method)
(langchain.llms.HuggingFaceHub method)
(langchain.llms.HuggingFacePipeline method)
(langchain.llms.LlamaCpp method)
(langchain.llms.Modal method)
(langchain.llms.NLPCloud method)
(langchain.llms.OpenAI method)
(langchain.llms.OpenAIChat method)
(langchain.llms.Petals method)
(langchain.llms.PipelineAI method)
(langchain.llms.PredictionGuard method)
(langchain.llms.PromptLayerOpenAI method)
(langchain.llms.PromptLayerOpenAIChat method)
(langchain.llms.Replicate method)
(langchain.llms.RWKV method)
(langchain.llms.SagemakerEndpoint method)
(langchain.llms.SelfHostedHuggingFaceLLM method)
(langchain.llms.SelfHostedPipeline method)
(langchain.llms.StochasticAI method)
(langchain.llms.Writer method)
(langchain.prompts.BasePromptTemplate method)
(langchain.prompts.ChatPromptTemplate method)
save_agent() (langchain.agents.AgentExecutor method)
save_context() (langchain.experimental.GenerativeAgentMemory method)
(langchain.memory.CombinedMemory method)
(langchain.memory.ConversationEntityMemory method)
(langchain.memory.ConversationKGMemory method)
(langchain.memory.ConversationStringBufferMemory method)
(langchain.memory.ConversationSummaryBufferMemory method)
(langchain.memory.ConversationSummaryMemory method)
(langchain.memory.ConversationTokenBufferMemory method)


(langchain.memory.ConversationSummaryMemory method)
(langchain.memory.ConversationTokenBufferMemory method)
(langchain.memory.ReadOnlySharedMemory method)
(langchain.memory.SimpleMemory method)
(langchain.memory.VectorStoreRetrieverMemory method)
save_local() (langchain.vectorstores.Annoy method)
(langchain.vectorstores.FAISS method)
schemas (langchain.utilities.PowerBIDataset attribute)
scrape() (langchain.document_loaders.WebBaseLoader method)
scrape_all() (langchain.document_loaders.WebBaseLoader method)
scrape_page() (langchain.tools.ExtractHyperlinksTool static method)
search() (langchain.docstore.InMemoryDocstore method)
(langchain.docstore.Wikipedia method)
(langchain.vectorstores.VectorStore method)
search_kwargs (langchain.chains.ChatVectorDBChain attribute)
(langchain.chains.VectorDBQA attribute)
(langchain.chains.VectorDBQAWithSourcesChain attribute)
(langchain.retrievers.TimeWeightedVectorStoreRetriever attribute)
search_type (langchain.chains.VectorDBQA attribute)
searx_host (langchain.utilities.searx_search.SearxSearchWrapper attribute)
(langchain.utilities.SearxSearchWrapper attribute)
SearxResults (class in langchain.utilities.searx_search)
security (langchain.tools.OpenAPISpec attribute)
seed (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
select_examples() (langchain.prompts.example_selector.LengthBasedExampleSelector method)
(langchain.prompts.example_selector.MaxMarginalRelevanceExampleSelector method)
(langchain.prompts.example_selector.SemanticSimilarityExampleSelector method)
selected_tools (langchain.agents.agent_toolkits.FileManagementToolkit attribute)


selected_tools (langchain.agents.agent_toolkits.FileManagementToolkit attribute)
SeleniumURLLoader (class in langchain.document_loaders)
SELF_ASK_WITH_SEARCH (langchain.agents.AgentType attribute)
send_pdf() (langchain.document_loaders.MathpixPDFLoader method)
SentenceTransformerEmbeddings (in module langchain.embeddings)
sequential_chain (langchain.chains.LLMSummarizationCheckerChain attribute)
serpapi_api_key (langchain.serpapi.SerpAPIWrapper attribute)
(langchain.utilities.SerpAPIWrapper attribute)
serper_api_key (langchain.utilities.GoogleSerperAPIWrapper attribute)
servers (langchain.tools.OpenAPISpec attribute)
service_account_key (langchain.document_loaders.GoogleDriveLoader attribute)
service_account_path (langchain.document_loaders.GoogleApiClient attribute)
session_id (langchain.memory.RedisEntityStore attribute)
set() (langchain.memory.InMemoryEntityStore method)
(langchain.memory.RedisEntityStore method)
similarity_fn (langchain.document_transformers.EmbeddingsRedundantFilter attribute)
(langchain.retrievers.document_compressors.EmbeddingsFilter attribute)
similarity_search() (langchain.vectorstores.AnalyticDB method)
(langchain.vectorstores.Annoy method)
(langchain.vectorstores.AtlasDB method)
(langchain.vectorstores.Chroma method)
(langchain.vectorstores.DeepLake method)
(langchain.vectorstores.ElasticVectorSearch method)
(langchain.vectorstores.FAISS method)
(langchain.vectorstores.LanceDB method)
(langchain.vectorstores.Milvus method)
(langchain.vectorstores.MyScale method)
(langchain.vectorstores.OpenSearchVectorSearch method)
(langchain.vectorstores.Pinecone method)
(langchain.vectorstores.Qdrant method)
(langchain.vectorstores.Redis method)
(langchain.vectorstores.SupabaseVectorStore method)


(langchain.vectorstores.Redis method)
(langchain.vectorstores.SupabaseVectorStore method)
(langchain.vectorstores.Tair method)
(langchain.vectorstores.VectorStore method)
(langchain.vectorstores.Weaviate method)
similarity_search_by_index() (langchain.vectorstores.Annoy method)
similarity_search_by_vector() (langchain.vectorstores.AnalyticDB method)
(langchain.vectorstores.Annoy method)
(langchain.vectorstores.Chroma method)
(langchain.vectorstores.DeepLake method)
(langchain.vectorstores.FAISS method)
(langchain.vectorstores.Milvus method)
(langchain.vectorstores.MyScale method)
(langchain.vectorstores.SupabaseVectorStore method)
(langchain.vectorstores.VectorStore method)
(langchain.vectorstores.Weaviate method)
similarity_search_by_vector_returning_embeddings() (langchain.vectorstores.SupabaseVectorStore method)
similarity_search_by_vector_with_relevance_scores() (langchain.vectorstores.SupabaseVectorStore method)
similarity_search_limit_score() (langchain.vectorstores.Redis method)
similarity_search_with_relevance_scores() (langchain.vectorstores.MyScale method)
(langchain.vectorstores.SupabaseVectorStore method)
(langchain.vectorstores.VectorStore method)
similarity_search_with_score() (langchain.vectorstores.AnalyticDB method)
(langchain.vectorstores.Annoy method)
(langchain.vectorstores.Chroma method)
(langchain.vectorstores.DeepLake method)
(langchain.vectorstores.ElasticVectorSearch method)
(langchain.vectorstores.FAISS method)
(langchain.vectorstores.Milvus method)
(langchain.vectorstores.Pinecone method)
(langchain.vectorstores.Qdrant method)
(langchain.vectorstores.Redis method)
similarity_search_with_score_by_index() (langchain.vectorstores.Annoy method)


similarity_search_with_score_by_index() (langchain.vectorstores.Annoy method)
similarity_search_with_score_by_vector() (langchain.vectorstores.AnalyticDB method)
(langchain.vectorstores.Annoy method)
(langchain.vectorstores.FAISS method)
(langchain.vectorstores.Milvus method)
similarity_threshold (langchain.document_transformers.EmbeddingsRedundantFilter attribute)
(langchain.retrievers.document_compressors.EmbeddingsFilter attribute)
SitemapLoader (class in langchain.document_loaders)
siterestrict (langchain.utilities.GoogleSearchAPIWrapper attribute)
SlackDirectoryLoader (class in langchain.document_loaders)
SpacyTextSplitter (class in langchain.text_splitter)
sparse_encoder (langchain.retrievers.PineconeHybridSearchRetriever attribute)
spec (langchain.agents.agent_toolkits.JsonToolkit attribute)
split_documents() (langchain.text_splitter.TextSplitter method)
split_text() (langchain.text_splitter.CharacterTextSplitter method)
(langchain.text_splitter.NLTKTextSplitter method)
(langchain.text_splitter.RecursiveCharacterTextSplitter method)
(langchain.text_splitter.SpacyTextSplitter method)
(langchain.text_splitter.TextSplitter method)
(langchain.text_splitter.TokenTextSplitter method)
sql_chain (langchain.chains.SQLDatabaseSequentialChain attribute)
SRTLoader (class in langchain.document_loaders)
status (langchain.experimental.GenerativeAgent attribute)
stop (langchain.agents.LLMSingleActionAgent attribute)
(langchain.chains.PALChain attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
(langchain.llms.Writer attribute)
stop_sequences (langchain.llms.AlephAlpha attribute)


stop_sequences (langchain.llms.AlephAlpha attribute)
store (langchain.memory.InMemoryEntityStore attribute)
strategy (langchain.llms.RWKV attribute)
stream() (langchain.llms.Anthropic method)
(langchain.llms.AzureOpenAI method)
(langchain.llms.LlamaCpp method)
(langchain.llms.OpenAI method)
(langchain.llms.PromptLayerOpenAI method)
streaming (langchain.chat_models.ChatOpenAI attribute)
(langchain.llms.Anthropic attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
(langchain.llms.OpenAIChat attribute)
(langchain.llms.PromptLayerOpenAIChat attribute)
strip_outputs (langchain.chains.SimpleSequentialChain attribute)
StripeLoader (class in langchain.document_loaders)
suffix (langchain.llms.LlamaCpp attribute)
(langchain.prompts.FewShotPromptTemplate attribute)
(langchain.prompts.FewShotPromptWithTemplates attribute)
summarize_related_memories() (langchain.experimental.GenerativeAgent method)
summary (langchain.experimental.GenerativeAgent attribute)
summary_message_cls (langchain.memory.ConversationKGMemory attribute)
summary_refresh_seconds (langchain.experimental.GenerativeAgent attribute)
SupabaseVectorStore (class in langchain.vectorstores)
sync_browser (langchain.agents.agent_toolkits.PlayWrightBrowserToolkit attribute)
T
table (langchain.vectorstores.MyScaleSettings attribute)
table_info (langchain.utilities.PowerBIDataset property)
table_name (langchain.vectorstores.SupabaseVectorStore attribute)
table_names (langchain.utilities.PowerBIDataset attribute)
tags (langchain.tools.OpenAPISpec attribute)
Tair (class in langchain.vectorstores)


Tair (class in langchain.vectorstores)
task (langchain.embeddings.HuggingFaceHubEmbeddings attribute)
(langchain.llms.HuggingFaceEndpoint attribute)
(langchain.llms.HuggingFaceHub attribute)
(langchain.llms.SelfHostedHuggingFaceLLM attribute)
TelegramChatLoader (class in langchain.document_loaders)
temp (langchain.llms.GPT4All attribute)
temperature (langchain.chat_models.ChatOpenAI attribute)
(langchain.llms.AI21 attribute)
(langchain.llms.AlephAlpha attribute)
(langchain.llms.Anthropic attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.Cohere attribute)
(langchain.llms.ForefrontAI attribute)
(langchain.llms.GooseAI attribute)
(langchain.llms.LlamaCpp attribute)
(langchain.llms.NLPCloud attribute)
(langchain.llms.Petals attribute)
(langchain.llms.PredictionGuard attribute)
(langchain.llms.RWKV attribute)
(langchain.llms.Writer attribute)
template (langchain.prompts.PromptTemplate attribute)
template_format (langchain.prompts.FewShotPromptTemplate attribute)
(langchain.prompts.FewShotPromptWithTemplates attribute)
(langchain.prompts.PromptTemplate attribute)
text_length (langchain.chains.LLMRequestsChain attribute)
text_splitter (langchain.chains.AnalyzeDocumentChain attribute)
(langchain.chains.MapReduceChain attribute)
(langchain.chains.QAGenerationChain attribute)
TextLoader (class in langchain.document_loaders)
texts (langchain.retrievers.SVMRetriever attribute)
TextSplitter (class in langchain.text_splitter)
tfidf_array (langchain.retrievers.TFIDFRetriever attribute)


tfidf_array (langchain.retrievers.TFIDFRetriever attribute)
to_typescript() (langchain.tools.APIOperation method)
token (langchain.utilities.PowerBIDataset attribute)
token_path (langchain.document_loaders.GoogleApiClient attribute)
(langchain.document_loaders.GoogleDriveLoader attribute)
tokenizer (langchain.llms.Petals attribute)
tokens (langchain.llms.AlephAlpha attribute)
tokens_path (langchain.llms.RWKV attribute)
tokens_to_generate (langchain.llms.Writer attribute)
TokenTextSplitter (class in langchain.text_splitter)
tool() (in module langchain.agents)
tool_run_logging_kwargs() (langchain.agents.Agent method)
(langchain.agents.BaseMultiActionAgent method)
(langchain.agents.BaseSingleActionAgent method)
(langchain.agents.LLMSingleActionAgent method)
tools (langchain.agents.agent_toolkits.JiraToolkit attribute)
(langchain.agents.agent_toolkits.ZapierToolkit attribute)
(langchain.agents.AgentExecutor attribute)
(langchain.agents.MRKLChain attribute)
(langchain.agents.ReActChain attribute)
(langchain.agents.SelfAskWithSearchChain attribute)
top_k (langchain.chains.SQLDatabaseChain attribute)
(langchain.llms.AlephAlpha attribute)
(langchain.llms.Anthropic attribute)
(langchain.llms.ForefrontAI attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
(langchain.llms.NLPCloud attribute)
(langchain.llms.Petals attribute)
(langchain.llms.Writer attribute)
(langchain.retrievers.ChatGPTPluginRetriever attribute)
(langchain.retrievers.DataberryRetriever attribute)


(langchain.retrievers.DataberryRetriever attribute)
(langchain.retrievers.PineconeHybridSearchRetriever attribute)
top_k_docs_for_context (langchain.chains.ChatVectorDBChain attribute)
top_k_results (langchain.utilities.ArxivAPIWrapper attribute)
(langchain.utilities.GooglePlacesAPIWrapper attribute)
(langchain.utilities.WikipediaAPIWrapper attribute)
top_p (langchain.llms.AlephAlpha attribute)
(langchain.llms.Anthropic attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.ForefrontAI attribute)
(langchain.llms.GooseAI attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
(langchain.llms.NLPCloud attribute)
(langchain.llms.Petals attribute)
(langchain.llms.RWKV attribute)
(langchain.llms.Writer attribute)
topP (langchain.llms.AI21 attribute)
traits (langchain.experimental.GenerativeAgent attribute)
transform (langchain.chains.TransformChain attribute)
transform_documents() (langchain.document_transformers.EmbeddingsRedundantFilter method)
(langchain.text_splitter.TextSplitter method)
transformers (langchain.retrievers.document_compressors.DocumentCompressorPipeline attribute)
truncate (langchain.embeddings.CohereEmbeddings attribute)
(langchain.llms.Cohere attribute)
ts_type_from_python() (langchain.tools.APIOperation static method)
ttl (langchain.memory.RedisEntityStore attribute)
TwitterTweetLoader (class in langchain.document_loaders)
U
unsecure (langchain.utilities.searx_search.SearxSearchWrapper attribute)
(langchain.utilities.SearxSearchWrapper attribute)
UnstructuredEmailLoader (class in langchain.document_loaders)
UnstructuredEPubLoader (class in langchain.document_loaders)


UnstructuredEPubLoader (class in langchain.document_loaders)
UnstructuredFileIOLoader (class in langchain.document_loaders)
UnstructuredFileLoader (class in langchain.document_loaders)
UnstructuredHTMLLoader (class in langchain.document_loaders)
UnstructuredImageLoader (class in langchain.document_loaders)
UnstructuredMarkdownLoader (class in langchain.document_loaders)
UnstructuredPDFLoader (class in langchain.document_loaders)
UnstructuredPowerPointLoader (class in langchain.document_loaders)
UnstructuredRTFLoader (class in langchain.document_loaders)
UnstructuredURLLoader (class in langchain.document_loaders)
UnstructuredWordDocumentLoader (class in langchain.document_loaders)
update_document() (langchain.vectorstores.Chroma method)
update_forward_refs() (langchain.llms.AI21 class method)
(langchain.llms.AlephAlpha class method)
(langchain.llms.Anthropic class method)
(langchain.llms.AzureOpenAI class method)
(langchain.llms.Banana class method)
(langchain.llms.CerebriumAI class method)
(langchain.llms.Cohere class method)
(langchain.llms.DeepInfra class method)
(langchain.llms.ForefrontAI class method)
(langchain.llms.GooseAI class method)
(langchain.llms.GPT4All class method)
(langchain.llms.HuggingFaceEndpoint class method)
(langchain.llms.HuggingFaceHub class method)
(langchain.llms.HuggingFacePipeline class method)
(langchain.llms.LlamaCpp class method)
(langchain.llms.Modal class method)
(langchain.llms.NLPCloud class method)
(langchain.llms.OpenAI class method)
(langchain.llms.OpenAIChat class method)


(langchain.llms.OpenAI class method)
(langchain.llms.OpenAIChat class method)
(langchain.llms.Petals class method)
(langchain.llms.PipelineAI class method)
(langchain.llms.PredictionGuard class method)
(langchain.llms.PromptLayerOpenAI class method)
(langchain.llms.PromptLayerOpenAIChat class method)
(langchain.llms.Replicate class method)
(langchain.llms.RWKV class method)
(langchain.llms.SagemakerEndpoint class method)
(langchain.llms.SelfHostedHuggingFaceLLM class method)
(langchain.llms.SelfHostedPipeline class method)
(langchain.llms.StochasticAI class method)
(langchain.llms.Writer class method)
upsert_messages() (langchain.memory.CosmosDBChatMessageHistory method)
url (langchain.document_loaders.MathpixPDFLoader property)
(langchain.retrievers.ChatGPTPluginRetriever attribute)
(langchain.retrievers.RemoteLangChainRetriever attribute)
(langchain.tools.IFTTTWebhook attribute)
urls (langchain.document_loaders.PlaywrightURLLoader attribute)
(langchain.document_loaders.SeleniumURLLoader attribute)
use_mlock (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
use_mmap (langchain.llms.LlamaCpp attribute)
use_multiplicative_presence_penalty (langchain.llms.AlephAlpha attribute)
username (langchain.vectorstores.MyScaleSettings attribute)
V
validate_channel_or_videoIds_is_set() (langchain.document_loaders.GoogleApiClient class method)
(langchain.document_loaders.GoogleApiYoutubeLoader class method)
validate_init_args() (langchain.document_loaders.ConfluenceLoader static method)


validate_init_args() (langchain.document_loaders.ConfluenceLoader static method)
validate_template (langchain.prompts.FewShotPromptTemplate attribute)
(langchain.prompts.FewShotPromptWithTemplates attribute)
(langchain.prompts.PromptTemplate attribute)
vectorizer (langchain.retrievers.TFIDFRetriever attribute)
VectorStore (class in langchain.vectorstores)
vectorstore (langchain.agents.agent_toolkits.VectorStoreInfo attribute)
(langchain.chains.ChatVectorDBChain attribute)
(langchain.chains.VectorDBQA attribute)
(langchain.chains.VectorDBQAWithSourcesChain attribute)
(langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute)
(langchain.retrievers.TimeWeightedVectorStoreRetriever attribute)
(langchain.tools.VectorStoreQATool attribute)
(langchain.tools.VectorStoreQAWithSourcesTool attribute)
vectorstore_info (langchain.agents.agent_toolkits.VectorStoreToolkit attribute)
vectorstores (langchain.agents.agent_toolkits.VectorStoreRouterToolkit attribute)
verbose (langchain.agents.MRKLChain attribute)
(langchain.agents.ReActChain attribute)
(langchain.agents.SelfAskWithSearchChain attribute)
(langchain.chat_models.ChatAnthropic attribute)
(langchain.llms.AzureOpenAI attribute)
(langchain.llms.OpenAI attribute)
(langchain.llms.OpenAIChat attribute)
(langchain.tools.BaseTool attribute)
VespaRetriever (class in langchain.retrievers)
video_ids (langchain.document_loaders.GoogleApiYoutubeLoader attribute)
vocab_only (langchain.embeddings.LlamaCppEmbeddings attribute)
(langchain.llms.GPT4All attribute)
(langchain.llms.LlamaCpp attribute)
W
wait_for_processing() (langchain.document_loaders.MathpixPDFLoader method)


W
wait_for_processing() (langchain.document_loaders.MathpixPDFLoader method)
Weaviate (class in langchain.vectorstores)
WeaviateHybridSearchRetriever (class in langchain.retrievers)
WeaviateHybridSearchRetriever.Config (class in langchain.retrievers)
web_path (langchain.document_loaders.WebBaseLoader property)
web_paths (langchain.document_loaders.AZLyricsLoader attribute)
(langchain.document_loaders.CollegeConfidentialLoader attribute)
(langchain.document_loaders.GitbookLoader attribute)
(langchain.document_loaders.HNLoader attribute)
(langchain.document_loaders.IMSDbLoader attribute)
(langchain.document_loaders.SitemapLoader attribute)
(langchain.document_loaders.WebBaseLoader attribute)
WebBaseLoader (class in langchain.document_loaders)
webhooks (langchain.tools.OpenAPISpec attribute)
WhatsAppChatLoader (class in langchain.document_loaders)
Wikipedia (class in langchain.docstore)
wolfram_alpha_appid (langchain.utilities.WolframAlphaAPIWrapper attribute)
Y
YoutubeLoader (class in langchain.document_loaders)
Z
zapier_description (langchain.tools.ZapierNLARunAction attribute)
ZERO_SHOT_REACT_DESCRIPTION (langchain.agents.AgentType attribute)
Zilliz (class in langchain.vectorstores)
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


Search
Error
Please activate JavaScript to enable the search functionality.
Ctrl+K
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.md
.pdf
YouTube
 Contents
Introduction to LangChain with Harrison Chase, creator of LangChain
Tutorials
Videos (sorted by views)
YouTube#
This is a collection of LangChain tutorials and videos on YouTube.
Introduction to LangChain with Harrison Chase, creator of LangChain#
Building the Future with LLMs, LangChain, & Pinecone by Pinecone
LangChain and Weaviate with Harrison Chase and Bob van Luijt - Weaviate Podcast #36 by Weaviate • Vector Database
LangChain Demo + Q&A with Harrison Chase by Full Stack Deep Learning
Tutorials#
LangChain Crash Course - Build apps with language models by Patrick Loeber
LangChain for Gen AI and LLMs by James Briggs:
#1 Getting Started with GPT-3 vs. Open Source LLMs
#2 Prompt Templates for GPT 3.5 and other LLMs
#3 LLM Chains using GPT 3.5 and other LLMs
#4 Chatbot Memory for Chat-GPT, Davinci + other LLMs
#5 Chat with OpenAI in LangChain
#6 LangChain Agents Deep Dive with GPT 3.5
Prompt Engineering with OpenAI’s GPT-3 and other LLMs
LangChain 101 by Data Independent:
What Is LangChain? - LangChain + ChatGPT Overview
Quickstart Guide
Beginner Guide To 7 Essential Concepts
OpenAI + Wolfram Alpha
Ask Questions On Your Custom (or Private) Files
Connect Google Drive Files To OpenAI
YouTube Transcripts + OpenAI
Question A 300 Page Book (w/ OpenAI + Pinecone)
Workaround OpenAI's Token Limit With Chain Types
Build Your Own OpenAI + LangChain Web App in 23 Minutes
Working With The New ChatGPT API


Working With The New ChatGPT API
OpenAI + LangChain Wrote Me 100 Custom Sales Emails
Structured Output From OpenAI (Clean Dirty Data)
Connect OpenAI To +5,000 Tools (LangChain + Zapier)
Use LLMs To Extract Data From Text (Expert Mode)
LangChain How to and guides by Sam Witteveen:
LangChain Basics - LLMs & PromptTemplates with Colab
LangChain Basics - Tools and Chains
ChatGPT API Announcement & Code Walkthrough with LangChain
Conversations with Memory (explanation & code walkthrough)
Chat with Flan20B
Using Hugging Face Models locally (code walkthrough)
PAL : Program-aided Language Models with LangChain code
Building a Summarization System with LangChain and GPT-3 - Part 1
Building a Summarization System with LangChain and GPT-3 - Part 2
Microsoft’s Visual ChatGPT using LangChain
LangChain Agents - Joining Tools and Chains with Decisions
Comparing LLMs with LangChain
Using Constitutional AI in LangChain
Talking to Alpaca with LangChain - Creating an Alpaca Chatbot
Talk to your CSV & Excel with LangChain
BabyAGI: Discover the Power of Task-Driven Autonomous Agents!
Improve your BabyAGI with LangChain
LangChain by Prompt Engineering:
LangChain Crash Course - All You Need to Know to Build Powerful Apps with LLMs
Working with MULTIPLE PDF Files in LangChain: ChatGPT for your Data
ChatGPT for YOUR OWN PDF files with LangChain
Talk to YOUR DATA without OpenAI APIs: LangChain
LangChain by Chat with data
LangChain Beginner’s Tutorial for Typescript/Javascript
GPT-4 Tutorial: How to Chat With Multiple PDF Files (~1000 pages of Tesla’s 10-K Annual Reports)


GPT-4 & LangChain Tutorial: How to Chat With A 56-Page PDF Document (w/Pinecone)
Videos (sorted by views)#
Building AI LLM Apps with LangChain (and more?) - LIVE STREAM by Nicholas Renotte
First look - ChatGPT + WolframAlpha (GPT-3.5 and Wolfram|Alpha via LangChain by James Weaver) by Dr Alan D. Thompson
LangChain explained - The hottest new Python framework by AssemblyAI
Chatbot with INFINITE MEMORY using OpenAI & Pinecone - GPT-3, Embeddings, ADA, Vector DB, Semantic by David Shapiro ~ AI
LangChain for LLMs is… basically just an Ansible playbook by David Shapiro ~ AI
Build your own LLM Apps with LangChain & GPT-Index by 1littlecoder
BabyAGI - New System of Autonomous AI Agents with LangChain by 1littlecoder
Run BabyAGI with Langchain Agents (with Python Code) by 1littlecoder
How to Use Langchain With Zapier | Write and Send Email with GPT-3 | OpenAI API Tutorial by StarMorph AI
Use Your Locally Stored Files To Get Response From GPT - OpenAI | Langchain | Python by Shweta Lodha
Langchain JS | How to Use GPT-3, GPT-4 to Reference your own Data | OpenAI Embeddings Intro by StarMorph AI
The easiest way to work with large language models | Learn LangChain in 10min by Sophia Yang
4 Autonomous AI Agents: “Westworld” simulation BabyAGI, AutoGPT, Camel, LangChain by Sophia Yang
AI CAN SEARCH THE INTERNET? Langchain Agents + OpenAI ChatGPT by tylerwhatsgood
Weaviate + LangChain for LLM apps presented by Erika Cardenas by Weaviate • Vector Database


Analyze Custom CSV Data with GPT-4 using Langchain by Venelin Valkov
Langchain Overview - How to Use Langchain & ChatGPT by Python In Office
Custom langchain Agent & Tools with memory. Turn any Python function into langchain tool with Gpt 3 by echohive
ChatGPT with any YouTube video using langchain and chromadb by echohive
How to Talk to a PDF using LangChain and ChatGPT by Automata Learning Lab
Langchain Document Loaders Part 1: Unstructured Files by Merk
LangChain - Prompt Templates (what all the best prompt engineers use) by Nick Daigler
LangChain. Crear aplicaciones Python impulsadas por GPT by Jesús Conde
Easiest Way to Use GPT In Your Products | LangChain Basics Tutorial by Rachel Woods
BabyAGI + GPT-4 Langchain Agent with Internet Access by tylerwhatsgood
Learning LLM Agents. How does it actually work? LangChain, AutoGPT & OpenAI by Arnoldas Kemeklis
Get Started with LangChain in Node.js by Developers Digest
LangChain + OpenAI tutorial: Building a Q&A system w/ own text data by Samuel Chan
Langchain + Zapier Agent by Merk
Connecting the Internet with ChatGPT (LLMs) using Langchain And Answers Your Questions by Kamalraj M M
Build More Powerful LLM Applications for Business’s with LangChain (Beginners Guide) by No Code Blackbox
previous
Tracing
 Contents

Introduction to LangChain with Harrison Chase, creator of LangChain
Tutorials
Videos (sorted by views)
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.ipynb
.pdf
Model Comparison
Model Comparison#
Constructing your language model application will likely involved choosing between many different options of prompts, models, and even chains to use. When doing so, you will want to compare these different options on different inputs in an easy, flexible, and intuitive way.
LangChain provides the concept of a ModelLaboratory to test out and try different models.
from langchain import LLMChain, OpenAI, Cohere, HuggingFaceHub, PromptTemplate
from langchain.model_laboratory import ModelLaboratory
llms = [
    OpenAI(temperature=0),
    Cohere(model="command-xlarge-20221108", max_tokens=20, temperature=0),
    HuggingFaceHub(repo_id="google/flan-t5-xl", model_kwargs={"temperature":1})
]
model_lab = ModelLaboratory.from_llms(llms)
model_lab.compare("What color is a flamingo?")
Input:
What color is a flamingo?
OpenAI
Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1}
Flamingos are pink.
Cohere
Params: {'model': 'command-xlarge-20221108', 'max_tokens': 20, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0}
Pink
HuggingFaceHub
Params: {'repo_id': 'google/flan-t5-xl', 'temperature': 1}
pink


pink
prompt = PromptTemplate(template="What is the capital of {state}?", input_variables=["state"])
model_lab_with_prompt = ModelLaboratory.from_llms(llms, prompt=prompt)
model_lab_with_prompt.compare("New York")
Input:
New York
OpenAI
Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1}
The capital of New York is Albany.
Cohere
Params: {'model': 'command-xlarge-20221108', 'max_tokens': 20, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0}
The capital of New York is Albany.
HuggingFaceHub
Params: {'repo_id': 'google/flan-t5-xl', 'temperature': 1}
st john s
from langchain import SelfAskWithSearchChain, SerpAPIWrapper
open_ai_llm = OpenAI(temperature=0)
search = SerpAPIWrapper()
self_ask_with_search_openai = SelfAskWithSearchChain(llm=open_ai_llm, search_chain=search, verbose=True)
cohere_llm = Cohere(temperature=0, model="command-xlarge-20221108")
search = SerpAPIWrapper()
self_ask_with_search_cohere = SelfAskWithSearchChain(llm=cohere_llm, search_chain=search, verbose=True)
chains = [self_ask_with_search_openai, self_ask_with_search_cohere]
names = [str(open_ai_llm), str(cohere_llm)]


names = [str(open_ai_llm), str(cohere_llm)]
model_lab = ModelLaboratory(chains, names=names)
model_lab.compare("What is the hometown of the reigning men's U.S. Open champion?")
Input:
What is the hometown of the reigning men's U.S. Open champion?
OpenAI
Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1}
> Entering new chain...
What is the hometown of the reigning men's U.S. Open champion?
Are follow up questions needed here: Yes.
Follow up: Who is the reigning men's U.S. Open champion?
Intermediate answer: Carlos Alcaraz.
Follow up: Where is Carlos Alcaraz from?
Intermediate answer: El Palmar, Spain.
So the final answer is: El Palmar, Spain
> Finished chain.
So the final answer is: El Palmar, Spain
Cohere
Params: {'model': 'command-xlarge-20221108', 'max_tokens': 256, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0}
> Entering new chain...
What is the hometown of the reigning men's U.S. Open champion?
Are follow up questions needed here: Yes.
Follow up: Who is the reigning men's U.S. Open champion?
Intermediate answer: Carlos Alcaraz.
So the final answer is:
Carlos Alcaraz
> Finished chain.
So the final answer is:
Carlos Alcaraz
By Harrison Chase


So the final answer is:
Carlos Alcaraz
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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 01, 2023.


.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
previous
Embeddings
next
Docstore
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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 01, 2023.


.md
.pdf
Integrations
Integrations#
Besides the installation of this python package, you will also need to install packages and set environment variables depending on which chains you want to use.
Note: the reason these packages are not included in the dependencies by default is that as we imagine scaling this package, we do not want to force dependencies that are not needed.
The following use cases require specific installs and api keys:
OpenAI:
Install requirements with pip install openai
Get an OpenAI api key and either set it as an environment variable (OPENAI_API_KEY) or pass it to the LLM constructor as openai_api_key.
Cohere:
Install requirements with pip install cohere
Get a Cohere api key and either set it as an environment variable (COHERE_API_KEY) or pass it to the LLM constructor as cohere_api_key.
GooseAI:
Install requirements with pip install openai
Get an GooseAI api key and either set it as an environment variable (GOOSEAI_API_KEY) or pass it to the LLM constructor as gooseai_api_key.
Hugging Face Hub
Install requirements with pip install huggingface_hub
Get a Hugging Face Hub api token and either set it as an environment variable (HUGGINGFACEHUB_API_TOKEN) or pass it to the LLM constructor as huggingfacehub_api_token.
Petals:
Install requirements with pip install petals
Get an GooseAI api key and either set it as an environment variable (HUGGINGFACE_API_KEY) or pass it to the LLM constructor as huggingface_api_key.
CerebriumAI:
Install requirements with pip install cerebrium
Get a Cerebrium api key and either set it as an environment variable (CEREBRIUMAI_API_KEY) or pass it to the LLM constructor as cerebriumai_api_key.


PromptLayer:
Install requirements with pip install promptlayer (be sure to be on version 0.1.62 or higher)
Get an API key from promptlayer.com and set it using promptlayer.api_key=<API KEY>
SerpAPI:
Install requirements with pip install google-search-results
Get a SerpAPI api key and either set it as an environment variable (SERPAPI_API_KEY) or pass it to the LLM constructor as serpapi_api_key.
GoogleSearchAPI:
Install requirements with pip install google-api-python-client
Get a Google api key and either set it as an environment variable (GOOGLE_API_KEY) or pass it to the LLM constructor as google_api_key. You will also need to set the GOOGLE_CSE_ID environment variable to your custom search engine id. You can pass it to the LLM constructor as google_cse_id as well.
WolframAlphaAPI:
Install requirements with pip install wolframalpha
Get a Wolfram Alpha api key and either set it as an environment variable (WOLFRAM_ALPHA_APPID) or pass it to the LLM constructor as wolfram_alpha_appid.
NatBot:
Install requirements with pip install playwright
Wikipedia:
Install requirements with pip install wikipedia
Elasticsearch:
Install requirements with pip install elasticsearch
Set up Elasticsearch backend. If you want to do locally, this is a good guide.
FAISS:
Install requirements with pip install faiss for Python 3.7 and pip install faiss-cpu for Python 3.10+.
MyScale
Install requirements with pip install clickhouse-connect. For documentations, please refer to this document.
Manifest:
Install requirements with pip install manifest-ml (Note: this is only available in Python 3.8+ currently).
OpenSearch:
Install requirements with pip install opensearch-py


OpenSearch:
Install requirements with pip install opensearch-py
If you want to set up OpenSearch on your local, here
DeepLake:
Install requirements with pip install deeplake
LlamaCpp:
Install requirements with pip install llama-cpp-python
Download model and convert following llama.cpp instructions
Milvus:
Install requirements with pip install pymilvus
In order to setup a local cluster, take a look here.
Zilliz:
Install requirements with pip install pymilvus
To get up and running, take a look here.
If you are using the NLTKTextSplitter or the SpacyTextSplitter, you will also need to install the appropriate models. For example, if you want to use the SpacyTextSplitter, you will need to install the en_core_web_sm model with python -m spacy download en_core_web_sm. Similarly, if you want to use the NLTKTextSplitter, you will need to install the punkt model with python -m nltk.downloader punkt.
previous
Installation
next
API References
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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 with various model providers, datastores, etc.
By default, the dependencies needed to do that are NOT installed.
However, there are two other ways to install LangChain that do bring in those dependencies.
To install modules needed for the common LLM providers, run:
pip install langchain[llms]
To install all modules needed for all integrations, run:
pip install langchain[all]
Note that if you are using zsh, you’ll need to quote square brackets when passing them as an argument to a command, for example:
pip install 'langchain[all]'
Installing from source#
If you want to install from source, you can do so by cloning the repo and running:
pip install -e .
previous
SQL Question Answering Benchmarking: Chinook
next
Integrations
 Contents

Official Releases
Installing from source
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.rst
.pdf
Agents
Agents#
Reference guide for Agents and associated abstractions.
Agents
Tools
Agent Toolkits
previous
Memory
next
Agents
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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.format(variable1="foo")
abstract format_messages(**kwargs: Any) → List[langchain.schema.BaseMessage][source]#
Format kwargs into a list of messages.
format_prompt(**kwargs: Any) → langchain.schema.PromptValue[source]#
Create Chat Messages.
pydantic model langchain.prompts.BasePromptTemplate[source]#
Base class for all prompt templates, returning a prompt.
field input_variables: List[str] [Required]#
A list of the names of the variables the prompt template expects.
field output_parser: Optional[langchain.schema.BaseOutputParser] = None#
How to parse the output of calling an LLM on this formatted prompt.
dict(**kwargs: Any) → Dict[source]#
Return dictionary representation of prompt.
abstract 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.format(variable1="foo")
abstract format_prompt(**kwargs: Any) → langchain.schema.PromptValue[source]#
Create Chat Messages.
partial(**kwargs: Union[str, Callable[[], str]]) → langchain.prompts.base.BasePromptTemplate[source]#
Return a partial of the prompt template.
save(file_path: Union[pathlib.Path, str]) → None[source]#
Save the prompt.
Parameters
file_path – Path to directory to save prompt to.
Example:
.. code-block:: python


file_path – Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=”path/prompt.yaml”)
pydantic model langchain.prompts.ChatPromptTemplate[source]#
format(**kwargs: Any) → str[source]#
Format the prompt with the inputs.
Parameters
kwargs – Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.format(variable1="foo")
format_messages(**kwargs: Any) → List[langchain.schema.BaseMessage][source]#
Format kwargs into a list of messages.
partial(**kwargs: Union[str, Callable[[], str]]) → langchain.prompts.base.BasePromptTemplate[source]#
Return a partial of the prompt template.
save(file_path: Union[pathlib.Path, str]) → None[source]#
Save the prompt.
Parameters
file_path – Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=”path/prompt.yaml”)
pydantic model langchain.prompts.FewShotPromptTemplate[source]#
Prompt template that contains few shot examples.
field example_prompt: langchain.prompts.prompt.PromptTemplate [Required]#
PromptTemplate used to format an individual example.
field example_selector: Optional[langchain.prompts.example_selector.base.BaseExampleSelector] = None#
ExampleSelector to choose the examples to format into the prompt.
Either this or examples should be provided.
field example_separator: str = '\n\n'#
String separator used to join the prefix, the examples, and suffix.
field examples: Optional[List[dict]] = None#
Examples to format into the prompt.
Either this or example_selector should be provided.
field input_variables: List[str] [Required]#
A list of the names of the variables the prompt template expects.


A list of the names of the variables the prompt template expects.
field prefix: str = ''#
A prompt template string to put before the examples.
field suffix: str [Required]#
A prompt template string to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: ‘f-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(**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.format(variable1="foo")
pydantic model langchain.prompts.FewShotPromptWithTemplates[source]#
Prompt template that contains few shot examples.
field example_prompt: langchain.prompts.prompt.PromptTemplate [Required]#
PromptTemplate used to format an individual example.
field example_selector: Optional[langchain.prompts.example_selector.base.BaseExampleSelector] = None#
ExampleSelector to choose the examples to format into the prompt.
Either this or examples should be provided.
field example_separator: str = '\n\n'#
String separator used to join the prefix, the examples, and suffix.
field examples: Optional[List[dict]] = None#
Examples to format into the prompt.
Either this or example_selector should be provided.
field input_variables: List[str] [Required]#
A list of the names of the variables the prompt template expects.
field prefix: Optional[langchain.prompts.base.StringPromptTemplate] = None#
A PromptTemplate to put before the examples.
field suffix: langchain.prompts.base.StringPromptTemplate [Required]#


field suffix: langchain.prompts.base.StringPromptTemplate [Required]#
A PromptTemplate to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: ‘f-string’, ‘jinja2’.
field validate_template: bool = True#
Whether or not to try validating the template.
dict(**kwargs: Any) → Dict[source]#
Return a dictionary of the prompt.
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.format(variable1="foo")
pydantic model langchain.prompts.MessagesPlaceholder[source]#
Prompt template that assumes variable is already list of messages.
format_messages(**kwargs: Any) → List[langchain.schema.BaseMessage][source]#
To a BaseMessage.
property input_variables: List[str]#
Input variables for this prompt template.
langchain.prompts.Prompt#
alias of langchain.prompts.prompt.PromptTemplate
pydantic model langchain.prompts.PromptTemplate[source]#
Schema to represent a prompt for an LLM.
Example
from langchain import PromptTemplate
prompt = PromptTemplate(input_variables=["foo"], template="Say {foo}")
field input_variables: List[str] [Required]#
A list of the names of the variables the prompt template expects.
field template: str [Required]#
The prompt template.
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.
format(**kwargs: Any) → str[source]#
Format the prompt with the inputs.
Parameters


Format the prompt with the inputs.
Parameters
kwargs – Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.format(variable1="foo")
classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwargs: Any) → langchain.prompts.prompt.PromptTemplate[source]#
Take examples in list format with prefix and suffix to create a prompt.
Intended to be used as a way to dynamically create a prompt from examples.
Parameters
examples – List of examples to use in the prompt.
suffix – String to go after the list of examples. Should generally
set up the user’s input.
input_variables – A list of variable names the final prompt template
will expect.
example_separator – The separator to use in between examples. Defaults
to two new line characters.
prefix – String that should go before any examples. Generally includes
examples. Default to an empty string.
Returns
The final prompt generated.
classmethod from_file(template_file: Union[str, pathlib.Path], input_variables: List[str], **kwargs: Any) → langchain.prompts.prompt.PromptTemplate[source]#
Load a prompt from a file.
Parameters
template_file – The path to the file containing the prompt template.
input_variables – A list of variable names the final prompt template
will expect.
Returns
The prompt loaded from the file.
classmethod from_template(template: str, **kwargs: Any) → langchain.prompts.prompt.PromptTemplate[source]#
Load a prompt template from a template.
pydantic model langchain.prompts.StringPromptTemplate[source]#
String prompt should expose the format method, returning a prompt.
format_prompt(**kwargs: Any) → langchain.schema.PromptValue[source]#
Create Chat Messages.


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 updated on May 01, 2023.


.rst
.pdf
Embeddings
Embeddings#
Wrappers around embedding modules.
pydantic model langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding[source]#
Wrapper for Aleph Alpha’s Asymmetric Embeddings
AA provides you with an endpoint to embed a document and a query.
The models were optimized to make the embeddings of documents and
the query for a document as similar as possible.
To learn more, check out: https://docs.aleph-alpha.com/docs/tasks/semantic_embed/
Example
from aleph_alpha import AlephAlphaAsymmetricSemanticEmbedding
embeddings = AlephAlphaSymmetricSemanticEmbedding()
document = "This is a content of the document"
query = "What is the content of the document?"
doc_result = embeddings.embed_documents([document])
query_result = embeddings.embed_query(query)
field compress_to_size: Optional[int] = 128#
Should the returned embeddings come back as an original 5120-dim vector,
or should it be compressed to 128-dim.
field contextual_control_threshold: Optional[int] = None#
Attention control parameters only apply to those tokens that have
explicitly been set in the request.
field control_log_additive: Optional[bool] = True#
Apply controls on prompt items by adding the log(control_factor)
to attention scores.
field hosting: Optional[str] = 'https://api.aleph-alpha.com'#
Optional parameter that specifies which datacenters may process the request.
field model: Optional[str] = 'luminous-base'#
Model name to use.
field normalize: Optional[bool] = True#
Should returned embeddings be normalized
embed_documents(texts: List[str]) → List[List[float]][source]#
Call out to Aleph Alpha’s asymmetric Document endpoint.
Parameters
texts – The list of texts to embed.
Returns


Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Call out to Aleph Alpha’s asymmetric, query embedding endpoint
:param text: The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.AlephAlphaSymmetricSemanticEmbedding[source]#
The symmetric version of the Aleph Alpha’s semantic embeddings.
The main difference is that here, both the documents and
queries are embedded with a SemanticRepresentation.Symmetric
.. rubric:: Example
embed_documents(texts: List[str]) → List[List[float]][source]#
Call out to Aleph Alpha’s Document endpoint.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Call out to Aleph Alpha’s asymmetric, query embedding endpoint
:param text: The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.CohereEmbeddings[source]#
Wrapper around Cohere embedding models.
To use, you should have the cohere python package installed, and the
environment variable COHERE_API_KEY set with your API key or pass it
as a named parameter to the constructor.
Example
from langchain.embeddings import CohereEmbeddings
cohere = CohereEmbeddings(model="medium", cohere_api_key="my-api-key")
field model: str = 'large'#
Model name to use.
field truncate: Optional[str] = None#
Truncate embeddings that are too long from start or end (“NONE”|”START”|”END”)
embed_documents(texts: List[str]) → List[List[float]][source]#


embed_documents(texts: List[str]) → List[List[float]][source]#
Call out to Cohere’s embedding endpoint.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Call out to Cohere’s embedding endpoint.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.FakeEmbeddings[source]#
embed_documents(texts: List[str]) → List[List[float]][source]#
Embed search docs.
embed_query(text: str) → List[float][source]#
Embed query text.
pydantic model langchain.embeddings.HuggingFaceEmbeddings[source]#
Wrapper around sentence_transformers embedding models.
To use, you should have the sentence_transformers python package installed.
Example
from langchain.embeddings import HuggingFaceEmbeddings
model_name = "sentence-transformers/all-mpnet-base-v2"
model_kwargs = {'device': 'cpu'}
hf = HuggingFaceEmbeddings(model_name=model_name, model_kwargs=model_kwargs)
field cache_folder: Optional[str] = None#
Path to store models.
Can be also set by SENTENCE_TRANSFORMERS_HOME enviroment variable.
field model_kwargs: Dict[str, Any] [Optional]#
Key word arguments to pass to the model.
field model_name: str = 'sentence-transformers/all-mpnet-base-v2'#
Model name to use.
embed_documents(texts: List[str]) → List[List[float]][source]#
Compute doc embeddings using a HuggingFace transformer model.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#


embed_query(text: str) → List[float][source]#
Compute query embeddings using a HuggingFace transformer model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.HuggingFaceHubEmbeddings[source]#
Wrapper around HuggingFaceHub embedding models.
To use, you should have the huggingface_hub python package installed, and the
environment variable HUGGINGFACEHUB_API_TOKEN set with your API token, or pass
it as a named parameter to the constructor.
Example
from langchain.embeddings import HuggingFaceHubEmbeddings
repo_id = "sentence-transformers/all-mpnet-base-v2"
hf = HuggingFaceHubEmbeddings(
    repo_id=repo_id,
    task="feature-extraction",
    huggingfacehub_api_token="my-api-key",
)
field model_kwargs: Optional[dict] = None#
Key word arguments to pass to the model.
field repo_id: str = 'sentence-transformers/all-mpnet-base-v2'#
Model name to use.
field task: Optional[str] = 'feature-extraction'#
Task to call the model with.
embed_documents(texts: List[str]) → List[List[float]][source]#
Call out to HuggingFaceHub’s embedding endpoint for embedding search docs.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Call out to HuggingFaceHub’s embedding endpoint for embedding query text.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.HuggingFaceInstructEmbeddings[source]#
Wrapper around sentence_transformers embedding models.


Wrapper around sentence_transformers embedding models.
To use, you should have the sentence_transformers
and InstructorEmbedding python package installed.
Example
from langchain.embeddings import HuggingFaceInstructEmbeddings
model_name = "hkunlp/instructor-large"
model_kwargs = {'device': 'cpu'}
hf = HuggingFaceInstructEmbeddings(
    model_name=model_name, model_kwargs=model_kwargs
)
field cache_folder: Optional[str] = None#
Path to store models.
Can be also set by SENTENCE_TRANSFORMERS_HOME enviroment variable.
field embed_instruction: str = 'Represent the document for retrieval: '#
Instruction to use for embedding documents.
field model_kwargs: Dict[str, Any] [Optional]#
Key word arguments to pass to the model.
field model_name: str = 'hkunlp/instructor-large'#
Model name to use.
field query_instruction: str = 'Represent the question for retrieving supporting documents: '#
Instruction to use for embedding query.
embed_documents(texts: List[str]) → List[List[float]][source]#
Compute doc embeddings using a HuggingFace instruct model.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Compute query embeddings using a HuggingFace instruct model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.LlamaCppEmbeddings[source]#
Wrapper around llama.cpp embedding models.
To use, you should have the llama-cpp-python library installed, and provide the
path to the Llama model as a named parameter to the constructor.
Check out: abetlen/llama-cpp-python
Example
from langchain.embeddings import LlamaCppEmbeddings


Example
from langchain.embeddings import LlamaCppEmbeddings
llama = LlamaCppEmbeddings(model_path="/path/to/model.bin")
field f16_kv: bool = False#
Use half-precision for key/value cache.
field logits_all: bool = False#
Return logits for all tokens, not just the last token.
field n_batch: Optional[int] = 8#
Number of tokens to process in parallel.
Should be a number between 1 and n_ctx.
field n_ctx: int = 512#
Token context window.
field n_parts: int = -1#
Number of parts to split the model into.
If -1, the number of parts is automatically determined.
field n_threads: Optional[int] = None#
Number of threads to use. If None, the number
of threads is automatically determined.
field seed: int = -1#
Seed. If -1, a random seed is used.
field use_mlock: bool = False#
Force system to keep model in RAM.
field vocab_only: bool = False#
Only load the vocabulary, no weights.
embed_documents(texts: List[str]) → List[List[float]][source]#
Embed a list of documents using the Llama model.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Embed a query using the Llama model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.OpenAIEmbeddings[source]#
Wrapper around OpenAI embedding models.
To use, you should have the openai python package installed, and the
environment variable OPENAI_API_KEY set with your API key or pass it


environment variable OPENAI_API_KEY set with your API key or pass it
as a named parameter to the constructor.
Example
from langchain.embeddings import OpenAIEmbeddings
openai = OpenAIEmbeddings(openai_api_key="my-api-key")
In order to use the library with Microsoft Azure endpoints, you need to set
the OPENAI_API_TYPE, OPENAI_API_BASE, OPENAI_API_KEY and optionally and
API_VERSION.
The OPENAI_API_TYPE must be set to ‘azure’ and the others correspond to
the properties of your endpoint.
In addition, the deployment name must be passed as the model parameter.
Example
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"
from langchain.embeddings.openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
    deployment="your-embeddings-deployment-name",
    model="your-embeddings-model-name"
)
text = "This is a test query."
query_result = embeddings.embed_query(text)
field chunk_size: int = 1000#
Maximum number of texts to embed in each batch
field max_retries: int = 6#
Maximum number of retries to make when generating.
embed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]][source]#
Call out to OpenAI’s embedding endpoint for embedding search docs.
Parameters
texts – The list of texts to embed.
chunk_size – The chunk size of embeddings. If None, will use the chunk size
specified by the class.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#


embed_query(text: str) → List[float][source]#
Call out to OpenAI’s embedding endpoint for embedding query text.
Parameters
text – The text to embed.
Returns
Embedding for the text.
pydantic model langchain.embeddings.SagemakerEndpointEmbeddings[source]#
Wrapper around custom Sagemaker Inference Endpoints.
To use, you must supply the endpoint name from your deployed
Sagemaker model & the region where it is deployed.
To authenticate, the AWS client uses the following methods to
automatically load credentials:
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
If a specific credential profile should be used, you must pass
the name of the profile from the ~/.aws/credentials file that is to be used.
Make sure the credentials / roles used have the required policies to
access the Sagemaker endpoint.
See: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html
field content_handler: langchain.embeddings.sagemaker_endpoint.EmbeddingsContentHandler [Required]#
The content handler class that provides an input and
output transform functions to handle formats between LLM
and the endpoint.
field credentials_profile_name: Optional[str] = None#
The name of the profile in the ~/.aws/credentials or ~/.aws/config files, which
has either access keys or role information specified.
If not specified, the default credential profile or, if on an EC2 instance,
credentials from IMDS will be used.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
field endpoint_kwargs: Optional[Dict] = None#
Optional attributes passed to the invoke_endpoint
function. See `boto3`_. docs for more info.


function. See `boto3`_. docs for more info.
.. _boto3: <https://boto3.amazonaws.com/v1/documentation/api/latest/index.html>
field endpoint_name: str = ''#
The name of the endpoint from the deployed Sagemaker model.
Must be unique within an AWS Region.
field model_kwargs: Optional[Dict] = None#
Key word arguments to pass to the model.
field region_name: str = ''#
The aws region where the Sagemaker model is deployed, eg. us-west-2.
embed_documents(texts: List[str], chunk_size: int = 64) → List[List[float]][source]#
Compute doc embeddings using a SageMaker Inference Endpoint.
Parameters
texts – The list of texts to embed.
chunk_size – The chunk size defines how many input texts will
be grouped together as request. If None, will use the
chunk size specified by the class.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Compute query embeddings using a SageMaker inference endpoint.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.SelfHostedEmbeddings[source]#
Runs custom embedding models on self-hosted remote hardware.
Supported hardware includes auto-launched instances on AWS, GCP, Azure,
and Lambda, as well as servers specified
by IP address and SSH credentials (such as on-prem, or another
cloud like Paperspace, Coreweave, etc.).
To use, you should have the runhouse python package installed.
Example using a model load function:from langchain.embeddings import SelfHostedEmbeddings
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import runhouse as rh


from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import runhouse as rh
gpu = rh.cluster(name="rh-a10x", instance_type="A100:1")
def get_pipeline():
    model_id = "facebook/bart-large"
    tokenizer = AutoTokenizer.from_pretrained(model_id)
    model = AutoModelForCausalLM.from_pretrained(model_id)
    return pipeline("feature-extraction", model=model, tokenizer=tokenizer)
embeddings = SelfHostedEmbeddings(
    model_load_fn=get_pipeline,
    hardware=gpu
    model_reqs=["./", "torch", "transformers"],
)
Example passing in a pipeline path:from langchain.embeddings import SelfHostedHFEmbeddings
import runhouse as rh
from transformers import pipeline
gpu = rh.cluster(name="rh-a10x", instance_type="A100:1")
pipeline = pipeline(model="bert-base-uncased", task="feature-extraction")
rh.blob(pickle.dumps(pipeline),
    path="models/pipeline.pkl").save().to(gpu, path="models")
embeddings = SelfHostedHFEmbeddings.from_pipeline(
    pipeline="models/pipeline.pkl",
    hardware=gpu,
    model_reqs=["./", "torch", "transformers"],
)
Validators
raise_deprecation » all fields
set_verbose » verbose
field inference_fn: Callable = <function _embed_documents>#
Inference function to extract the embeddings on the remote hardware.
field inference_kwargs: Any = None#
Any kwargs to pass to the model’s inference function.
embed_documents(texts: List[str]) → List[List[float]][source]#
Compute doc embeddings using a HuggingFace transformer model.
Parameters
texts – The list of texts to embed.s
Returns
List of embeddings, one for each text.


Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Compute query embeddings using a HuggingFace transformer model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
pydantic model langchain.embeddings.SelfHostedHuggingFaceEmbeddings[source]#
Runs sentence_transformers embedding models on self-hosted remote hardware.
Supported hardware includes auto-launched instances on AWS, GCP, Azure,
and Lambda, as well as servers specified
by IP address and SSH credentials (such as on-prem, or another cloud
like Paperspace, Coreweave, etc.).
To use, you should have the runhouse python package installed.
Example
from langchain.embeddings import SelfHostedHuggingFaceEmbeddings
import runhouse as rh
model_name = "sentence-transformers/all-mpnet-base-v2"
gpu = rh.cluster(name="rh-a10x", instance_type="A100:1")
hf = SelfHostedHuggingFaceEmbeddings(model_name=model_name, hardware=gpu)
Validators
raise_deprecation » all fields
set_verbose » verbose
field hardware: Any = None#
Remote hardware to send the inference function to.
field inference_fn: Callable = <function _embed_documents>#
Inference function to extract the embeddings.
field load_fn_kwargs: Optional[dict] = None#
Key word arguments to pass to the model load function.
field model_id: str = 'sentence-transformers/all-mpnet-base-v2'#
Model name to use.
field model_load_fn: Callable = <function load_embedding_model>#
Function to load the model remotely on the server.
field model_reqs: List[str] = ['./', 'sentence_transformers', 'torch']#
Requirements to install on hardware to inference the model.


Requirements to install on hardware to inference the model.
pydantic model langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings[source]#
Runs InstructorEmbedding embedding models on self-hosted remote hardware.
Supported hardware includes auto-launched instances on AWS, GCP, Azure,
and Lambda, as well as servers specified
by IP address and SSH credentials (such as on-prem, or another
cloud like Paperspace, Coreweave, etc.).
To use, you should have the runhouse python package installed.
Example
from langchain.embeddings import SelfHostedHuggingFaceInstructEmbeddings
import runhouse as rh
model_name = "hkunlp/instructor-large"
gpu = rh.cluster(name='rh-a10x', instance_type='A100:1')
hf = SelfHostedHuggingFaceInstructEmbeddings(
    model_name=model_name, hardware=gpu)
Validators
raise_deprecation » all fields
set_verbose » verbose
field embed_instruction: str = 'Represent the document for retrieval: '#
Instruction to use for embedding documents.
field model_id: str = 'hkunlp/instructor-large'#
Model name to use.
field model_reqs: List[str] = ['./', 'InstructorEmbedding', 'torch']#
Requirements to install on hardware to inference the model.
field query_instruction: str = 'Represent the question for retrieving supporting documents: '#
Instruction to use for embedding query.
embed_documents(texts: List[str]) → List[List[float]][source]#
Compute doc embeddings using a HuggingFace instruct model.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Compute query embeddings using a HuggingFace instruct model.
Parameters


Compute query embeddings using a HuggingFace instruct model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
langchain.embeddings.SentenceTransformerEmbeddings#
alias of langchain.embeddings.huggingface.HuggingFaceEmbeddings
pydantic model langchain.embeddings.TensorflowHubEmbeddings[source]#
Wrapper around tensorflow_hub embedding models.
To use, you should have the tensorflow_text python package installed.
Example
from langchain.embeddings import TensorflowHubEmbeddings
url = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3"
tf = TensorflowHubEmbeddings(model_url=url)
field model_url: str = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/3'#
Model name to use.
embed_documents(texts: List[str]) → List[List[float]][source]#
Compute doc embeddings using a TensorflowHub embedding model.
Parameters
texts – The list of texts to embed.
Returns
List of embeddings, one for each text.
embed_query(text: str) → List[float][source]#
Compute query embeddings using a TensorflowHub embedding model.
Parameters
text – The text to embed.
Returns
Embeddings for the text.
previous
Chat Models
next
Indexes
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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.
pydantic model langchain.output_parsers.GuardrailsOutputParser[source]#
field guard: Any = None#
classmethod from_rail(rail_file: str, num_reasks: int = 1) → langchain.output_parsers.rail_parser.GuardrailsOutputParser[source]#
classmethod from_rail_string(rail_str: str, num_reasks: int = 1) → langchain.output_parsers.rail_parser.GuardrailsOutputParser[source]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(text: str) → Dict[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters
text – output of language model
Returns
structured output
pydantic model langchain.output_parsers.ListOutputParser[source]#
Class to parse the output of an LLM call to a list.
abstract parse(text: str) → List[str][source]#
Parse the output of an LLM call.
pydantic model langchain.output_parsers.OutputFixingParser[source]#
Wraps a parser and tries to fix parsing errors.
field parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T] [Required]#
field retry_chain: langchain.chains.llm.LLMChain [Required]#


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', 'instructions'], output_parser=None, partial_variables={}, template='Instructions:\n--------------\n{instructions}\n--------------\nCompletion:\n--------------\n{completion}\n--------------\n\nAbove, the Completion did not satisfy the constraints given in the Instructions.\nError:\n--------------\n{error}\n--------------\n\nPlease try again. Please only respond with an answer that satisfies the constraints laid out in the Instructions:', template_format='f-string', validate_template=True)) → langchain.output_parsers.fix.OutputFixingParser[langchain.output_parsers.fix.T][source]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(completion: str) → langchain.output_parsers.fix.T[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters
text – output of language model
Returns
structured output
pydantic model langchain.output_parsers.PydanticOutputParser[source]#
field pydantic_object: Type[langchain.output_parsers.pydantic.T] [Required]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(text: str) → langchain.output_parsers.pydantic.T[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters


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 regex_pattern: str = "{}:\\s?([^.'\\n']*)\\.?"#
parse(text: str) → Dict[str, str][source]#
Parse the output of an LLM call.
pydantic model langchain.output_parsers.RegexParser[source]#
Class to parse the output into a dictionary.
field default_output_key: Optional[str] = None#
field output_keys: List[str] [Required]#
field regex: str [Required]#
parse(text: str) → Dict[str, str][source]#
Parse the output of an LLM call.
pydantic model langchain.output_parsers.ResponseSchema[source]#
field description: str [Required]#
field name: str [Required]#
pydantic model langchain.output_parsers.RetryOutputParser[source]#
Wraps a parser and tries to fix parsing errors.
Does this by passing the original prompt and the completion to another
LLM, and telling it the completion did not satisfy criteria in the prompt.
field parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T] [Required]#
field retry_chain: langchain.chains.llm.LLMChain [Required]#


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'], output_parser=None, partial_variables={}, template='Prompt:\n{prompt}\nCompletion:\n{completion}\n\nAbove, the Completion did not satisfy the constraints given in the Prompt.\nPlease try again:', template_format='f-string', validate_template=True)) → langchain.output_parsers.retry.RetryOutputParser[langchain.output_parsers.retry.T][source]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(completion: str) → langchain.output_parsers.retry.T[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters
text – output of language model
Returns
structured output
parse_with_prompt(completion: str, prompt_value: langchain.schema.PromptValue) → langchain.output_parsers.retry.T[source]#
Optional method to parse the output of an LLM call with a prompt.
The prompt is largely provided in the event the OutputParser 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.RetryWithErrorOutputParser[source]#
Wraps a parser and tries to fix parsing errors.
Does this by passing the original prompt, the completion, AND the error
that was raised to another language and telling it that the completion


that was raised to another language 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.schema.BaseOutputParser[langchain.output_parsers.retry.T] [Required]#
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', 'error', 'prompt'], output_parser=None, partial_variables={}, template='Prompt:\n{prompt}\nCompletion:\n{completion}\n\nAbove, the Completion did not satisfy the constraints given in the Prompt.\nDetails: {error}\nPlease try again:', template_format='f-string', validate_template=True)) → langchain.output_parsers.retry.RetryWithErrorOutputParser[langchain.output_parsers.retry.T][source]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(completion: str) → langchain.output_parsers.retry.T[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters
text – output of language model
Returns
structured output
parse_with_prompt(completion: str, prompt_value: langchain.schema.PromptValue) → langchain.output_parsers.retry.T[source]#
Optional method to parse the output of an LLM call with a prompt.
The prompt is largely provided in the event the OutputParser wants


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[source]#
field response_schemas: List[langchain.output_parsers.structured.ResponseSchema] [Required]#
classmethod from_response_schemas(response_schemas: List[langchain.output_parsers.structured.ResponseSchema]) → langchain.output_parsers.structured.StructuredOutputParser[source]#
get_format_instructions() → str[source]#
Instructions on how the LLM output should be formatted.
parse(text: str) → Any[source]#
Parse the output of an LLM call.
A method which takes in a string (assumed output of language model )
and parses it into some structure.
Parameters
text – output of language model
Returns
structured output
previous
Example Selector
next
Chat Prompt Template
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.rst
.pdf
SerpAPI
SerpAPI#
For backwards compatiblity.
pydantic model langchain.serpapi.SerpAPIWrapper[source]#
Wrapper around SerpAPI.
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.client.ClientSession] = None#
field params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}#
field serpapi_api_key: Optional[str] = None#
async aresults(query: str) → dict[source]#
Use aiohttp to run query through SerpAPI and return the results async.
async arun(query: str, **kwargs: Any) → str[source]#
Run query through SerpAPI and parse result async.
get_params(query: str) → Dict[str, str][source]#
Get parameters for SerpAPI.
results(query: str) → dict[source]#
Run query through SerpAPI and return the raw result.
run(query: str, **kwargs: Any) → str[source]#
Run query through SerpAPI and parse result.
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.rst
.pdf
Docstore
Docstore#
Wrappers on top of docstores.
class langchain.docstore.InMemoryDocstore(_dict: Dict[str, langchain.schema.Document])[source]#
Simple in memory docstore in the form of a dict.
add(texts: Dict[str, langchain.schema.Document]) → None[source]#
Add texts to in memory dictionary.
search(search: str) → Union[str, langchain.schema.Document][source]#
Search via direct lookup.
class langchain.docstore.Wikipedia[source]#
Wrapper around wikipedia API.
search(search: str) → Union[str, langchain.schema.Document][source]#
Try to search for wiki page.
If page exists, return the page summary, and a PageWithLookups object.
If page does not exist, return similar entries.
previous
Indexes
next
Text Splitter
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on May 01, 2023.


.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.prompt.PromptTemplate [Required]#
Prompt template used to format the examples.
field examples: List[dict] [Required]#
A list of the examples that the prompt template expects.
field get_text_length: Callable[[str], int] = <function _get_length_based>#
Function to measure prompt length. Defaults to word count.
field max_length: int = 2048#
Max length for the prompt, beyond which examples are cut.
add_example(example: Dict[str, str]) → None[source]#
Add new example to list.
select_examples(input_variables: Dict[str, str]) → List[dict][source]#
Select which examples to use based on the input lengths.
pydantic model langchain.prompts.example_selector.MaxMarginalRelevanceExampleSelector[source]#
ExampleSelector that selects examples based on Max Marginal Relevance.
This was shown to improve performance in this paper:
https://arxiv.org/pdf/2211.13892.pdf
field fetch_k: int = 20#
Number of examples to fetch to rerank.
classmethod from_examples(examples: List[dict], embeddings: langchain.embeddings.base.Embeddings, vectorstore_cls: Type[langchain.vectorstores.base.VectorStore], k: int = 4, input_keys: Optional[List[str]] = None, fetch_k: int = 20, **vectorstore_cls_kwargs: Any) → langchain.prompts.example_selector.semantic_similarity.MaxMarginalRelevanceExampleSelector[source]#
Create k-shot example selector using example list and embeddings.


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. FAISS.
k – Number of examples to select
input_keys – If provided, the search is based on the input variables
instead of all variables.
vectorstore_cls_kwargs – optional kwargs containing url for vector store
Returns
The ExampleSelector instantiated, backed by a vector store.
select_examples(input_variables: Dict[str, str]) → List[dict][source]#
Select which examples to use based on semantic similarity.
pydantic model langchain.prompts.example_selector.SemanticSimilarityExampleSelector[source]#
Example selector that selects examples based on SemanticSimilarity.
field example_keys: Optional[List[str]] = None#
Optional keys to filter examples to.
field input_keys: Optional[List[str]] = None#
Optional keys to filter input to. If provided, the search is based on
the input variables instead of all variables.
field k: int = 4#
Number of examples to select.
field vectorstore: langchain.vectorstores.base.VectorStore [Required]#
VectorStore than contains information about examples.
add_example(example: Dict[str, str]) → str[source]#
Add new example to vectorstore.
classmethod from_examples(examples: List[dict], embeddings: langchain.embeddings.base.Embeddings, vectorstore_cls: Type[langchain.vectorstores.base.VectorStore], k: int = 4, input_keys: Optional[List[str]] = None, **vectorstore_cls_kwargs: Any) → langchain.prompts.example_selector.semantic_similarity.SemanticSimilarityExampleSelector[source]#