id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
115
6b45712c382f-3
The play's setting of the beach at sunset adds a touch of poignancy and romanticism to the story, while the mysterious figure serves to keep the audience enthralled. Overall, Tragedy at Sunset on the Beach is an engaging and thought-provoking play that is sure to leave audiences feeling inspired and hopeful. Sequential...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
6b45712c382f-4
Play Synopsis: {synopsis} Review from a New York Times play critic of the above play:""" prompt_template = PromptTemplate(input_variables=["synopsis"], template=template) review_chain = LLMChain(llm=llm, prompt=prompt_template, output_key="review") # This is the overall chain where we run these two chains in sequence. ...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
6b45712c382f-5
'era': 'Victorian England', 'synopsis': "\n\nThe play follows the story of John, a young man from a wealthy Victorian family, who dreams of a better life for himself. He soon meets a beautiful young woman named Mary, who shares his dream. The two fall in love and decide to elope and start a new life together.\n\nOn th...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
6b45712c382f-6
'review': "\n\nThe latest production from playwright X is a powerful and heartbreaking story of love and loss set against the backdrop of 19th century England. The play follows John, a young man from a wealthy Victorian family, and Mary, a beautiful young woman with whom he falls in love. The two decide to elope and st...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
6b45712c382f-7
from langchain.memory import SimpleMemory llm = OpenAI(temperature=.7) template = """You are a social media manager for a theater company. Given the title of play, the era it is set in, the date,time and location, the synopsis of the play, and the review of the play, it is your job to write a social media post for tha...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
6b45712c382f-8
'location': 'Theater in the Park', 'social_post_text': "\nSpend your Christmas night with us at Theater in the Park and experience the heartbreaking story of love and loss that is 'A Walk on the Beach'. Set in Victorian England, this romantic tragedy follows the story of Frances and Edward, a young couple whose love i...
https://python.langchain.com/en/latest/modules/chains/generic/sequential_chains.html
b6c7fdd7bb76-0
.ipynb .pdf Serialization Contents Saving a chain to disk Loading a chain from disk Saving components separately Serialization# This notebook covers how to serialize chains to and from disk. The serialization format we use is json or yaml. Currently, only some chains support this type of serialization. We will grow t...
https://python.langchain.com/en/latest/modules/chains/generic/serialization.html
b6c7fdd7bb76-1
"best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" }, "output_key": "text", "_type": "llm_chain" } Loading a chain from disk# We can load a chain from disk by using the load_chain method. from langchain.chains import load_chain chain = load_chain("llm_chain.js...
https://python.langchain.com/en/latest/modules/chains/generic/serialization.html
b6c7fdd7bb76-2
"top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "n": 1, "best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" } config = { "memory": None, "verbose": True, "prompt_path": "prompt.json", "llm_path": "llm.json", "output_key": "text", "_ty...
https://python.langchain.com/en/latest/modules/chains/generic/serialization.html
a3e007a095d7-0
.ipynb .pdf Transformation Chain Transformation Chain# This notebook showcases using a generic transformation chain. As an example, we will create a dummy transformation that takes in a super long text, filters the text to only the first 3 paragraphs, and then passes that into an LLMChain to summarize those. from langc...
https://python.langchain.com/en/latest/modules/chains/generic/transformation.html
dd0d9e534db6-0
.ipynb .pdf Loading from LangChainHub Loading from LangChainHub# This notebook covers how to load chains from LangChainHub. from langchain.chains import load_chain chain = load_chain("lc://chains/llm-math/chain.json") chain.run("whats 2 raised to .12") > Entering new LLMMathChain chain... whats 2 raised to .12 Answer: ...
https://python.langchain.com/en/latest/modules/chains/generic/from_hub.html
dd0d9e534db6-1
query = "What did the president say about Ketanji Brown Jackson" chain.run(query) " The president said that Ketanji Brown Jackson is a Circuit Court of Appeals Judge, one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, has received a broad range of support ...
https://python.langchain.com/en/latest/modules/chains/generic/from_hub.html
747a5a991617-0
.rst .pdf Indexes Indexes# Indexes refer to ways to structure documents so that LLMs can best interact with them. LangChain has a number of modules that help you load, structure, store, and retrieve documents. Docstore Text Splitter Document Loaders Vector Stores Retrievers Document Compressors Document Transformers pr...
https://python.langchain.com/en/latest/reference/indexes.html
fe8d12337566-0
.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,...
https://python.langchain.com/en/latest/reference/integrations.html
fe8d12337566-1
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 var...
https://python.langchain.com/en/latest/reference/integrations.html
fe8d12337566-2
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 requi...
https://python.langchain.com/en/latest/reference/integrations.html
1296b966013f-0
.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 Apr 28, 2023.
https://python.langchain.com/en/latest/reference/agents.html
1cd208264953-0
.md .pdf Installation Contents Official Releases Installing from source Installation# Official Releases# LangChain is available on PyPi, so to it is easily installable with: pip install langchain That will install the bare minimum requirements of LangChain. A lot of the value of LangChain comes when integrating it wi...
https://python.langchain.com/en/latest/reference/installation.html
8b3dc8c42bee-0
.rst .pdf Prompts Prompts# The reference guides here all relate to objects for working with Prompts. PromptTemplates Example Selector Output Parsers previous How to serialize prompts next PromptTemplates By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/reference/prompts.html
9739042ee58f-0
.rst .pdf Models Models# LangChain provides interfaces and integrations for a number of different types of models. LLMs Chat Models Embeddings previous API References next Chat Models By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/reference/models.html
b92eac01ecd4-0
.rst .pdf Document Transformers Document Transformers# Transform documents pydantic model langchain.document_transformers.EmbeddingsRedundantFilter[source]# Filter that drops redundant documents by comparing their embeddings. field embeddings: langchain.embeddings.base.Embeddings [Required]# Embeddings to use for embed...
https://python.langchain.com/en/latest/reference/modules/document_transformers.html
e9b99ad44d58-0
.rst .pdf Retrievers Retrievers# pydantic model langchain.retrievers.ChatGPTPluginRetriever[source]# field aiosession: Optional[aiohttp.client.ClientSession] = None# field bearer_token: str [Required]# field filter: Optional[dict] = None# field top_k: int = 3# field url: str [Required]# async aget_relevant_documents(qu...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-1
Parameters query – string to find relevant documents for Returns Sequence of relevant documents class langchain.retrievers.DataberryRetriever(datastore_url: str, top_k: Optional[int] = None, api_key: Optional[str] = None)[source]# async aget_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get ...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-2
Click “Reset password” Follow the prompts to reset the password The format for Elastic Cloud URLs is https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243. add_texts(texts: Iterable[str], refresh_indices: bool = True) → List[str][source]# Run more texts through the embeddings and add to the retriver. Para...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-3
Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.PineconeHybridSearchRetriever[source]# field alpha: float = 0.5# field embeddings: langchain.embeddings.base.Embeddings [Required]# field index: Any = None# field sparse_encoder: Any = None# f...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-4
Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.SVMRetriever[source]# field embeddings: langchain.embeddings.base.Embeddings [Required]# field index: Any = None# field k: int = 4# field relevancy_threshold: Optional[float] = None# field tex...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-5
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.TimeWeightedVectorStoreRetriever[source]# Retriever combining embededing simil...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
e9b99ad44d58-6
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Return documents that are relevant to the query. get_salient_docs(query: str) → Dict[int, Tuple[langchain.schema.Document, float]][source]# Return documents that are salient to the query. class langchain.retrievers.WeaviateHybridSearchRetriev...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
4f019704c3f5-0
.rst .pdf Python REPL Python REPL# For backwards compatibility. pydantic model langchain.python.PythonREPL[source]# Simulates a standalone Python REPL. field globals: Optional[Dict] [Optional] (alias '_globals')# field locals: Optional[Dict] [Optional] (alias '_locals')# run(command: str) → str[source]# Run command wit...
https://python.langchain.com/en/latest/reference/modules/python.html
cf03a3709d0b-0
.rst .pdf Document Loaders Document Loaders# All different types of document loaders. class langchain.document_loaders.AZLyricsLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Loader that loads AZLyrics webpages. load() → List[langchain.schema.Document][source]# Load webpage. web...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-1
Loading logic for loading documents from Azure Blob Storage. load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.AzureBlobStorageFileLoader(conn_str: str, container: str, blob_name: str)[source]# Loading logic for loading documents from Azure Blob Storage. load() → List[la...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-2
load() → List[langchain.schema.Document][source]# Load from bilibili url. class langchain.document_loaders.BlackboardLoader(blackboard_course_url: str, bbrouter: str, load_all_recursively: bool = True, basic_auth: Optional[Tuple[str, str]] = None, cookies: Optional[dict] = None)[source]# Loader that loads all documents...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-3
Parameters url – Url to parse the filename from. Returns The filename. class langchain.document_loaders.BlockchainDocumentLoader(contract_address: str, blockchainType: langchain.document_loaders.blockchain.BlockchainType = BlockchainType.ETH_MAINNET, api_key: str = 'docs-demo', startToken: int = 0)[source]# Loads eleme...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-4
Output Example:column1: value1 column2: value2 column3: value3 load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.ChatGPTLoader(log_file: str, num_logs: int = - 1)[source]# Loader that loads conversations from exported ChatGPT data. load() → List[langchai...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-5
You can also specify a boolean include_attachments to include attachments, this is set to False by default, if set to True all attachments will be downloaded and ConfluenceReader will extract the text from the attachments and add it to the Document object. Currently supported attachment types are: PDF, PNG, JPEG/JPG, S...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-6
Raises ValueError – Errors while validating input ImportError – Required dependencies not installed. load(space_key: Optional[str] = None, page_ids: Optional[List[str]] = None, label: Optional[str] = None, cql: Optional[str] = None, include_attachments: bool = False, include_comments: bool = False, limit: Optional[int]...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-7
they only return the value from the results key. So here, the pagination starts from 0 and goes until the max_pages, getting the limit number of pages with each request. We have to manually check if there are more docs based on the length of the returned list of pages, rather than just checking for the presence of a ne...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-8
load() → List[langchain.schema.Document][source]# Extract text from Diffbot on all the URLs and return Document instances class langchain.document_loaders.DirectoryLoader(path: str, glob: str = '**/[!.]*', silent_errors: bool = False, load_hidden: bool = False, loader_cls: typing.Union[typing.Type[langchain.document_lo...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-9
load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.EverNoteLoader(file_path: str)[source]# Loader to load in EverNote files.. load() → List[langchain.schema.Document][source]# Load document from EverNote file. class langchain.document_loaders.FacebookChat...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-10
load() → List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.GitbookLoader(web_page: str, load_all_paths: bool = False, base_url: Optional[str] = None, content_selector: str = 'main')[source]# Load GitBook data. load from either a single page, or load all (relative...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-11
Validate that either folder_id or document_ids is set, but not both. class langchain.document_loaders.GoogleApiYoutubeLoader(google_api_client: langchain.document_loaders.youtube.GoogleApiClient, channel_name: Optional[str] = None, video_ids: Optional[List[str]] = None, add_video_info: bool = True, captions_language: s...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-12
Loader that loads Google Docs from Google Drive. Validators validate_credentials_path » credentials_path validate_folder_id_or_document_ids » all fields field credentials_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json')# field document_ids: Optional[List[str]] = None# field file_ids: Optional[...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-13
Load items from an HN page. web_paths: List[str]# class langchain.document_loaders.HuggingFaceDatasetLoader(path: str, page_content_column: str = 'text', name: Optional[str] = None, data_dir: Optional[str] = None, data_files: Optional[Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]]] = None, cache_dir...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-14
static load_suggestions(query: str = '', doc_type: str = 'all') → List[langchain.schema.Document][source]# class langchain.document_loaders.IMSDbLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Loader that loads IMSDb webpages. load() → List[langchain.schema.Document][source]# Lo...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-15
load_page(page_id: str) → langchain.schema.Document[source]# Read a page. class langchain.document_loaders.NotionDirectoryLoader(path: str)[source]# Loader that loads Notion directory dump. load() → List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.ObsidianLoader(path: str, encod...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-16
Load file. langchain.document_loaders.PagedPDFSplitter# alias of langchain.document_loaders.pdf.PyPDFLoader class langchain.document_loaders.PlaywrightURLLoader(urls: List[str], continue_on_failure: bool = True, headless: bool = True, remove_selectors: Optional[List[str]] = None)[source]# Loader that uses Playwright an...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-17
Load Python files, respecting any non-default encoding if specified. class langchain.document_loaders.ReadTheDocsLoader(path: str, encoding: Optional[str] = None, errors: Optional[str] = None, **kwargs: Optional[Any])[source]# Loader that loads ReadTheDocs documentation directory dump. load() → List[langchain.schema.Do...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-18
continue_on_failure# If True, continue loading other URLs on failure. Type bool browser# The browser to use, either ‘chrome’ or ‘firefox’. Type str executable_path# The path to the browser executable. Type Optional[str] headless# If True, the browser will run in headless mode. Type bool load() → List[langchain.schema.D...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-19
load() → List[langchain.schema.Document][source]# Load from file path. class langchain.document_loaders.TwitterTweetLoader(auth_handler: Union[OAuthHandler, OAuth2BearerHandler], twitter_users: Sequence[str], number_tweets: Optional[int] = 100)[source]# Twitter tweets loader. Read tweets of user twitter handle. First y...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-20
Loader that uses unstructured to load file IO objects. class langchain.document_loaders.UnstructuredFileLoader(file_path: str, mode: str = 'single', **unstructured_kwargs: Any)[source]# Loader that uses unstructured to load files. class langchain.document_loaders.UnstructuredHTMLLoader(file_path: str, mode: str = 'sing...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-21
load() → List[langchain.schema.Document][source]# Load file. class langchain.document_loaders.UnstructuredWordDocumentLoader(file_path: str, mode: str = 'single', **unstructured_kwargs: Any)[source]# Loader that uses unstructured to load word documents. class langchain.document_loaders.WebBaseLoader(web_path: Union[str...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
cf03a3709d0b-22
Loader that loads Youtube transcripts. classmethod from_youtube_url(youtube_url: str, **kwargs: Any) → langchain.document_loaders.youtube.YoutubeLoader[source]# Given youtube URL, load video. load() → List[langchain.schema.Document][source]# Load documents. previous Text Splitter next Vector Stores By Harrison Chase ...
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
9bfb44d476c3-0
.rst .pdf Output Parsers Output Parsers# pydantic model langchain.output_parsers.CommaSeparatedListOutputParser[source]# Parse out comma separated lists. get_format_instructions() → str[source]# Instructions on how the LLM output should be formatted. parse(text: str) → List[str][source]# Parse the output of an LLM call...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
9bfb44d476c3-1
field retry_chain: langchain.chains.llm.LLMChain [Required]# classmethod from_llm(llm: langchain.schema.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'error', 'instructions']...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
9bfb44d476c3-2
and parses it into some structure. Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.RegexDictParser[source]# Class to parse the output into a dictionary. field no_update_value: Optional[str] = None# field output_key_to_format: Dict[str, str] [Required]# field ...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
9bfb44d476c3-3
field retry_chain: langchain.chains.llm.LLMChain [Required]# classmethod from_llm(llm: langchain.schema.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'prompt'], output_pars...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
9bfb44d476c3-4
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...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
9bfb44d476c3-5
The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so. Parameters completion – output of language model prompt – prompt value Returns structured output pydantic model langchain.output_parsers.StructuredOutputParser[sourc...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
726f2b71f251-0
.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 param...
https://python.langchain.com/en/latest/reference/modules/serpapi.html
c3113bc64162-0
.rst .pdf Document Compressors Document Compressors# pydantic model langchain.retrievers.document_compressors.DocumentCompressorPipeline[source]# Document compressor that uses a pipeline of transformers. field transformers: List[Union[langchain.schema.BaseDocumentTransformer, langchain.retrievers.document_compressors.b...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
c3113bc64162-1
Filter down documents. compress_documents(documents: Sequence[langchain.schema.Document], query: str) → Sequence[langchain.schema.Document][source]# Filter documents based on similarity of their embeddings to the query. pydantic model langchain.retrievers.document_compressors.LLMChainExtractor[source]# field get_input:...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
c3113bc64162-2
The chain prompt is expected to have a BooleanOutputParser. async acompress_documents(documents: Sequence[langchain.schema.Document], query: str) → Sequence[langchain.schema.Document][source]# Filter down documents. compress_documents(documents: Sequence[langchain.schema.Document], query: str) → Sequence[langchain.sche...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
0bb97971419d-0
.rst .pdf Memory Memory# pydantic model langchain.memory.ChatMessageHistory[source]# field messages: List[langchain.schema.BaseMessage] = []# add_ai_message(message: str) → None[source]# Add an AI message to the store add_user_message(message: str) → None[source]# Add a user message to the store clear() → None[source]#...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-1
load_memory_variables(inputs: Dict[str, Any]) → Dict[str, str][source]# Return history buffer. property buffer: List[langchain.schema.BaseMessage]# String buffer of memory. pydantic model langchain.memory.ConversationEntityMemory[source]# Entity extractor & summarizer to memory. field ai_prefix: str = 'AI'# field chat_...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-2
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last l...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-3
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-4
field entity_store: langchain.memory.entity.BaseEntityStore [Optional]# field entity_summarization_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['entity', 'summary', 'history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant helping a human kee...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-5
Knowledge graph memory for storing conversation memory. Integrates with external knowledge graph to store and retrieve information about knowledge triples in the conversation. field ai_prefix: str = 'AI'#
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-6
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last l...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-7
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-8
field human_prefix: str = 'Human'# field k: int = 2# field kg: langchain.graphs.networkx_graph.NetworkxEntityGraph [Optional]#
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-9
field knowledge_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template="You are a networked intelligence helping a human track knowledge triples about all relevant people, things, concepts, etc. and integrati...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-10
It's also the number 1 producer of gold in the US.\n\nOutput: (Nevada, is a, state)<|>(Nevada, is in, US)<|>(Nevada, is the number 1 producer of, gold)\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: Hello.\nAI: Hi! How are you?\nPerson #1: I'm good. How are you?\nAI: I'm good too.\nLast line of conversat...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-11
huh. I know Descartes likes to drive antique scooters and play the mandolin.\nOutput: (Descartes, likes to drive, antique scooters)<|>(Descartes, plays, mandolin)\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:", template_f...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-12
field llm: langchain.schema.BaseLanguageModel [Required]# field summary_message_cls: Type[langchain.schema.BaseMessage] = <class 'langchain.schema.SystemMessage'># Number of previous utterances to include in the context. clear() → None[source]# Clear memory contents. get_current_entities(input_string: str) → List[str][...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-13
field memory_key: str = 'history'# field moving_summary_buffer: str = ''# clear() → None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) → Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) → None[source]# Save context from this con...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-14
property buffer: List[langchain.schema.BaseMessage]# String buffer of memory. class langchain.memory.CosmosDBChatMessageHistory(cosmos_endpoint: str, cosmos_database: str, cosmos_container: str, credential: Any, session_id: str, user_id: str, ttl: Optional[int] = None)[source]# Chat history backed by Azure CosmosDB. ad...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-15
Append the message to the record in DynamoDB clear() → None[source]# Clear session memory from DynamoDB property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from DynamoDB class langchain.memory.InMemoryEntityStore[source]# Basic in-memory entity store. clear() → None[source]# Delete all entities...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-16
clear() → None[source]# Nothing to clear, got a memory like a vault. load_memory_variables(inputs: Dict[str, Any]) → Dict[str, str][source]# Load memory variables from memory. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) → None[source]# Nothing should be saved or changed property memory_variables: List...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-17
delete(key: str) → None[source]# Delete entity value from store. exists(key: str) → bool[source]# Check if entity exists in store. property full_key_prefix: str# get(key: str, default: Optional[str] = None) → Optional[str][source]# Get entity value from store. key_prefix: str = 'memory_store'# recall_ttl: Optional[int]...
https://python.langchain.com/en/latest/reference/modules/memory.html
0bb97971419d-18
field retriever: langchain.vectorstores.base.VectorStoreRetriever [Required]# VectorStoreRetriever object to connect to. field return_docs: bool = False# Whether or not to return the result of querying the database directly. clear() → None[source]# Nothing to clear. load_memory_variables(inputs: Dict[str, Any]) → Dict[...
https://python.langchain.com/en/latest/reference/modules/memory.html
c2dab0b94abd-0
.rst .pdf Text Splitter Text Splitter# Functionality for splitting text. class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]# Implementation of splitting text that looks at characters. split_text(text: str) → List[str][source]# Split incoming text and return chunks. class...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
c2dab0b94abd-1
Split incoming text and return chunks. class langchain.text_splitter.TextSplitter(chunk_size: int = 4000, chunk_overlap: int = 200, length_function: typing.Callable[[str], int] = <built-in function len>)[source]# Interface for splitting text into chunks. async atransform_documents(documents: Sequence[langchain.schema.D...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
c2dab0b94abd-2
Transform sequence of documents by splitting them. class langchain.text_splitter.TokenTextSplitter(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any)[source]# Imp...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
eb217fa49633-0
.rst .pdf SearxNG Search Contents Quick Start Searching Engine Parameters Search Tips SearxNG Search# Utility for using SearxNG meta search API. SearxNG is a privacy-friendly free metasearch engine that aggregates results from multiple search engines and databases and supports the OpenSearch specification. More detai...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
eb217fa49633-1
# assuming the searx host is set as above or exported as an env variable s = SearxSearchWrapper(engines=['google', 'bing'], language='es') Search Tips# Searx offers a special search syntax that can also be used instead of passing engine parameters. For example the following query: s = SearxSearchWra...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
eb217fa49633-2
use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your own network as described here. For a list of public SearxNG instances see https://searx.space/ class langchain.utilities.searx_search.SearxResults(data: str)[source]# Dict like wrappe...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
eb217fa49633-3
field params: dict [Optional]# field query_suffix: Optional[str] = ''# field searx_host: str = ''# field unsecure: bool = False# async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) → List[Dict][source]# Asynchronously query with json results...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
eb217fa49633-4
Run query through Searx API and parse results. You can pass any other params to the searx query API. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra param...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
bc7f3e99024d-0
.rst .pdf Example Selector Example Selector# Logic for selecting examples to include in prompts. pydantic model langchain.prompts.example_selector.LengthBasedExampleSelector[source]# Select examples based on length. Validators calculate_example_text_lengths » example_text_lengths field example_prompt: langchain.prompts...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
bc7f3e99024d-1
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An iniialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g....
https://python.langchain.com/en/latest/reference/modules/example_selector.html
bc7f3e99024d-2
Create k-shot example selector using example list and embeddings. Reshuffles examples dynamically based on query similarity. Parameters examples – List of examples to use in the prompt. embeddings – An initialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls – A vector store DB interface class, e.g...
https://python.langchain.com/en/latest/reference/modules/example_selector.html
e180d6296d6b-0
.rst .pdf Embeddings Embeddings# Wrappers around embedding modules. pydantic model langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding[source]# Wrapper for Aleph Alpha’s Asymmetric Embeddings AA provides you with an endpoint to embed a document and a query. The models were optimized to make the embeddings of doc...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-1
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.AlephAlphaSymmet...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-2
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...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-3
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 hav...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-4
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 = HuggingFaceInstru...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-5
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 t...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-6
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, ...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
e180d6296d6b-7
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 m...
https://python.langchain.com/en/latest/reference/modules/embeddings.html