It should be for {audience} audience.    (Max 15 words)    """    passawait write_me_short_post(topic="old movies")Simplified streamingIf we want to leverage streaming:we need to define prompt as async function turn on the streaming on the decorator, or we can define PromptType with streaming oncapture the stream using StreamingContextThis way we just mark which prompt should be streamed, not needing to tinker with what LLM should we use, passing around the creating and distribute streaming handler into particular part of our chain... just turn the streaming on/off on prompt/prompt type...The streaming will happen only if we call it in streaming context ... there we can define a simple function to handle the stream# this code example is complete and should run as it isfrom langchain_decorators import StreamingContext, llm_prompt# this will mark the prompt for streaming (useful if we want stream just some prompts in our app... but don't want to pass distribute the callback handlers)# note that only async functions can be streamed (will get an error if it's not)@llm_prompt(capture_stream=True) async def write_me_short_post(topic:str, platform:str="twitter", audience:str = "developers"):    """    Write me a short header for my post about {topic} for {platform} platform.     It should be for {audience} audience.    (Max 15 words)    """    pass# just an arbitrary  function to demonstrate the streaming... will be some websockets code in the real worldtokens=[]def capture_stream_func(new_token:str):    tokens.append(new_token)# if we want to capture the stream, we need to wrap the execution into StreamingContext... # this will allow us to capture the stream even if the prompt call is hidden inside higher level method# only the prompts marked with


capture the stream even if the prompt call is hidden inside higher level method# only the prompts marked with capture_stream will be captured herewith StreamingContext(stream_to_stdout=True, callback=capture_stream_func):    result = await run_prompt()    print("Stream finished ... we can distinguish tokens thanks to alternating colors")print("\nWe've captured",len(tokens),"tokensğŸ�‰\n")print("Here is the result:")print(result)Prompt declarationsBy default the prompt is is the whole function docs, unless you mark your prompt Documenting your promptâ€‹We can specify what part of our docs is the prompt definition, by specifying a code block with <prompt> language tag@llm_promptdef write_me_short_post(topic:str, platform:str="twitter", audience:str = "developers"):    """    Here is a good way to write a prompt as part of a function docstring, with additional documentation for devs.    It needs to be a code block, marked as a `<prompt>` language    ```<prompt>    Write me a short header for my post about {topic} for {platform} platform.     It should be for {audience} audience.    (Max 15 words)    ```    Now only to code block above will be used as a prompt, and the rest of the docstring will be used as a description for developers.    (It has also a nice benefit that IDE (like VS code) will display the prompt properly (not trying to parse it as markdown, and thus not showing new lines properly))    """    return Chat messages promptâ€‹For chat models is very useful to define prompt as a set of message templates... here is how to do it:@llm_promptdef simulate_conversation(human_input:str, agent_role:str="a pirate"):


simulate_conversation(human_input:str, agent_role:str="a pirate"):    """    ## System message     - note the `:system` sufix inside the <prompt:_role_> tag         ```<prompt:system>    You are a {agent_role} hacker. You mus act like one.    You reply always in code, using python or javascript code block...    for example:        ... do not reply with anything else.. just with code - respecting your role.    ```    # human message     (we are using the real role that are enforced by the LLM - GPT supports system, assistant, user)    ``` <prompt:user>    Helo, who are you    ```    a reply:        ``` <prompt:assistant>    \``` python <<- escaping inner code block with \ that should be part of the prompt    def hello():        print("Argh... hello you pesky pirate")    \```    ```        we can also add some history using placeholder    ```<prompt:placeholder>    {history}    ```    ```<prompt:user>    {human_input}    ```    Now only to code block above will be used as a prompt, and the rest of the docstring will be used as a description for developers.    (It has also a nice benefit that IDE (like VS code) will display the prompt properly (not trying to parse it as markdown, and thus not showing new lines properly))    """    passthe roles here are model native roles (assistant, user, system


"""    passthe roles here are model native roles (assistant, user, system for chatGPT)Optional sectionsyou can define a whole sections of your prompt that should be optionalif any input in the section is missing, the whole section won't be renderedthe syntax for this is as follows:@llm_promptdef prompt_with_optional_partials():    """    this text will be rendered always, but    {? anything inside this block will be rendered only if all the {value}s parameters are not empty (None | "")   ?}    you can also place it in between the words    this too will be rendered{? , but        this  block will be rendered only if {this_value} and {this_value}        is not empty?} !    """Output parsersllm_prompt decorator natively tries to detect the best output parser based on the output type. (if not set, it returns the raw string)list, dict and pydantic outputs are also supported natively (automatically)# this code example is complete and should run as it isfrom langchain_decorators import llm_prompt@llm_promptdef write_name_suggestions(company_business:str, count:int)->list:    """ Write me {count} good name suggestions for company that {company_business}    """    passwrite_name_suggestions(company_business="sells cookies", count=5)More complex structuresâ€‹for dict / pydantic you need to specify the formatting instructions...


this can be tedious, that's why you can let the output parser gegnerate you the instructions based on the model (pydantic)from langchain_decorators import llm_promptfrom pydantic import BaseModel, Fieldclass TheOutputStructureWeExpect(BaseModel):    name:str = Field (description="The name of the company")    headline:str = Field( description="The description of the company (for landing page)")    employees:list[str] = Field(description="5-8 fake employee names with their positions")@llm_prompt()def fake_company_generator(company_business:str)->TheOutputStructureWeExpect:    """ Generate a fake company that {company_business}    {FORMAT_INSTRUCTIONS}    """    returncompany = fake_company_generator(company_business="sells cookies")# print the result nicely formattedprint("Company name: ",company.name)print("company headline: ",company.headline)print("company employees: ",company.employees)Binding the prompt to an objectfrom pydantic import BaseModelfrom langchain_decorators import llm_promptclass AssistantPersonality(BaseModel):    assistant_name:str    assistant_role:str    field:str    @property    def a_property(self):        return "whatever"    def hello_world(self, function_kwarg:str=None):        """        We can reference any {field} or {a_property} inside our prompt... and combine it with {function_kwarg} in the method        """        @llm_prompt    def introduce_your_self(self)->str:        """        ```Â <prompt:system>        You are an


```Â <prompt:system>        You are an assistant named {assistant_name}.         Your role is to act as {assistant_role}        ```        ```<prompt:user>        Introduce your self (in less than 20 words)        ```        """    personality = AssistantPersonality(assistant_name="John", assistant_role="a pirate")print(personality.introduce_your_self(personality))More examples:these and few more examples are also available in the colab notebook hereincluding the ReAct Agent re-implementation using purely langchain decoratorsPreviousLanceDBNextLlama.cppInstallationExamplesPassing a memory and/or callbacks:Documenting your promptChat messages promptMore complex structuresCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Unstructured | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerUnstructuredOn this pageUnstructuredThe unstructured package from


Unstructured.IO extracts clean text from raw source documents like
PDFs and Word documents.
This page covers how to use the unstructured
ecosystem within LangChain.Installation and Setupâ€‹If you are using a loader that runs locally, use the following steps to get unstructured and
its dependencies running locally.Install the Python SDK with pip install "unstructured[local-inference]"Install the following system dependencies if they are not already available on your system.
Depending on what document types you're parsing, you may not need all of these.libmagic-dev (filetype detection)poppler-utils (images and PDFs)tesseract-ocr(images and PDFs)libreoffice (MS Office docs)pandoc (EPUBs)If you want to get up and running with less set up, you can
simply run pip install unstructured and use UnstructuredAPIFileLoader or
UnstructuredAPIFileIOLoader. That will process your document using the hosted Unstructured API.The Unstructured API requires API keys to make requests.
You can generate a free API key here and start using it today!
Checkout the README here here to get started making API calls.
We'd love to hear your feedback, let us know how it goes in our community slack.
And stay tuned for improvements to both quality and performance!
Check out the instructions
here if you'd like to self-host the Unstructured API or run it locally.Wrappersâ€‹Data Loadersâ€‹The primary unstructured wrappers within langchain are data loaders. The following
shows how to use the most basic unstructured data loader. There are other file-specific


shows how to use the most basic unstructured data loader. There are other file-specific
data loaders available in the langchain.document_loaders module.from langchain.document_loaders import UnstructuredFileLoaderloader = UnstructuredFileLoader("state_of_the_union.txt")loader.load()If you instantiate the loader with UnstructuredFileLoader(mode="elements"), the loader
will track additional metadata like the page number and text type (i.e. title, narrative text)
when that information is available.PreviousTypesenseNextVectaraInstallation and SetupWrappersData LoadersCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Azure Cognitive Search | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerAzure Cognitive SearchOn this pageAzure Cognitive SearchAzure Cognitive Search (formerly known as Azure Search) is a cloud search service that gives developers infrastructure, APIs, and tools for building a rich search experience over private, heterogeneous content in web, mobile, and enterprise applications.Search is foundational to any app that surfaces text to users, where common scenarios include catalog or document search, online retail apps, or data exploration over proprietary content. When you create a search service, you'll work with the following capabilities:A search engine for full text search over a search index containing user-owned contentRich indexing, with lexical analysis and optional AI enrichment for content extraction and transformationRich query syntax for text search, fuzzy search, autocomplete, geo-search and moreProgrammability through REST APIs and client libraries in Azure SDKsAzure integration at the data layer, machine learning layer, and AI (Cognitive Services)Installation and Setupâ€‹See set up instructions.Retrieverâ€‹See a usage example.from langchain.retrievers import AzureCognitiveSearchRetrieverPreviousAzure Blob StorageNextAzure OpenAIInstallation and SetupRetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Modal | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerModalOn this pageModalThis page covers how to use the Modal ecosystem to run LangChain custom LLMs.


It is broken into two parts: Modal installation and web endpoint deploymentUsing deployed web endpoint with LLM wrapper class.Installation and Setupâ€‹Install with pip install modalRun modal token newDefine your Modal Functions and Webhooksâ€‹You must include a prompt. There is a rigid response structure:class Item(BaseModel):    prompt: str@stub.function()@modal.web_endpoint(method="POST")def get_text(item: Item):    return {"prompt": run_gpt2.call(item.prompt)}The following is an example with the GPT2 model:from pydantic import BaseModelimport modalCACHE_PATH = "/root/model_cache"class Item(BaseModel):    prompt: strstub = modal.Stub(name="example-get-started-with-langchain")def download_model():    from transformers import GPT2Tokenizer, GPT2LMHeadModel    tokenizer = GPT2Tokenizer.from_pretrained('gpt2')    model = GPT2LMHeadModel.from_pretrained('gpt2')    tokenizer.save_pretrained(CACHE_PATH)    model.save_pretrained(CACHE_PATH)# Define a container image for the LLM function below, which# downloads and stores the GPT-2 model.image = modal.Image.debian_slim().pip_install(    "tokenizers", "transformers", "torch", "accelerate").run_function(download_model)@stub.function(    gpu="any",    image=image,    retries=3,)def run_gpt2(text: str):    from transformers import GPT2Tokenizer, GPT2LMHeadModel    tokenizer = GPT2Tokenizer.from_pretrained(CACHE_PATH)    model = GPT2LMHeadModel.from_pretrained(CACHE_PATH)    encoded_input = tokenizer(text, return_tensors='pt').input_ids


encoded_input = tokenizer(text, return_tensors='pt').input_ids    output = model.generate(encoded_input, max_length=50, do_sample=True)    return tokenizer.decode(output[0], skip_special_tokens=True)@stub.function()@modal.web_endpoint(method="POST")def get_text(item: Item):    return {"prompt": run_gpt2.call(item.prompt)}Deploy the web endpointâ€‹Deploy the web endpoint to Modal cloud with the modal deploy CLI command.


Your web endpoint will acquire a persistent URL under the modal.run domain.LLM wrapper around Modal web endpointâ€‹The  Modal LLM wrapper class which will accept your deployed web endpoint's URL.from langchain.llms import Modalendpoint_url = "https://ecorp--custom-llm-endpoint.modal.run"  # REPLACE ME with your deployed Modal web endpoint's URLllm = Modal(endpoint_url=endpoint_url)llm_chain = LLMChain(prompt=prompt, llm=llm)question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"llm_chain.run(question)PreviousMLflowNextModelScopeInstallation and SetupDefine your Modal Functions and WebhooksDeploy the web endpointLLM wrapper around Modal web endpointCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


ArangoDB | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerArangoDBOn this pageArangoDBArangoDB is a scalable graph database system to drive value from connected data, faster. Native graphs, an integrated search engine, and JSON support, via a single query language. ArangoDB runs on-prem, in the cloud â€“ anywhere.Dependenciesâ€‹Install the ArangoDB Python Driver package withpip install python-arangoGraph QA Chainâ€‹Connect your ArangoDB Database with a Chat Model to get insights on your data. See the notebook example here.from arango import ArangoClientfrom langchain.graphs import ArangoGraphfrom langchain.chains import ArangoGraphQAChainPreviousApifyNextArgillaDependenciesGraph QA ChainCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Weather | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerWeatherOn this pageWeatherOpenWeatherMap is an open source weather service provider.Installation and Setupâ€‹pip install pyowmWe must set up the OpenWeatherMap API token.Document Loaderâ€‹See a usage example.from langchain.document_loaders import WeatherDataLoaderPreviousWeights & BiasesNextWeaviateInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Helicone | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerHeliconeOn this pageHeliconeThis page covers how to use the Helicone ecosystem within LangChain.What is Helicone?â€‹Helicone is an open source observability platform that proxies your OpenAI traffic and provides you key insights into your spend, latency and usage.Quick startâ€‹With your LangChain environment you can just add the following parameter.export OPENAI_API_BASE="https://oai.hconeai.com/v1"Now head over to helicone.ai to create your account, and add your OpenAI API key within our dashboard to view your logs.How to enable Helicone cachingâ€‹from langchain.llms import OpenAIimport openaiopenai.api_base = "https://oai.hconeai.com/v1"llm = OpenAI(temperature=0.9, headers={"Helicone-Cache-Enabled": "true"})text = "What is a helicone?"print(llm(text))Helicone caching docsHow to use Helicone custom propertiesâ€‹from langchain.llms import OpenAIimport openaiopenai.api_base = "https://oai.hconeai.com/v1"llm = OpenAI(temperature=0.9, headers={        "Helicone-Property-Session": "24",        "Helicone-Property-Conversation": "support_issue_2",        "Helicone-Property-App":


"Helicone-Property-App": "mobile",      })text = "What is a helicone?"print(llm(text))Helicone property docsPreviousHazy ResearchNextHologresWhat is Helicone?Quick startHow to enable Helicone cachingHow to use Helicone custom propertiesCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Motherduck | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerMotherduckOn this pageMotherduckMotherduck is a managed DuckDB-in-the-cloud service.Installation and Setupâ€‹First, you need to install duckdb python package.pip install duckdbYou will also need to sign up for an account at MotherduckAfter that, you should set up a connection string - we mostly integrate with Motherduck through SQLAlchemy.


The connection string is likely in the form:token="..."conn_str = f"duckdb:///md:{token}@my_db"SQLChainâ€‹You can use the SQLChain to query data in your Motherduck instance in natural language.from langchain import OpenAI, SQLDatabase, SQLDatabaseChaindb = SQLDatabase.from_uri(conn_str)db_chain = SQLDatabaseChain.from_llm(OpenAI(temperature=0), db, verbose=True)From here, see the SQL Chain documentation on how to use.LLMCacheâ€‹You can also easily use Motherduck to cache LLM requests.
Once again this is done through the SQLAlchemy wrapper.import sqlalchemyeng = sqlalchemy.create_engine(conn_str)langchain.llm_cache = SQLAlchemyCache(engine=eng)From here, see the LLM Caching documentation on how to use.PreviousMomentoNextMyScaleInstallation and SetupSQLChainLLMCacheCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


AnalyticDB | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerAnalyticDBOn this pageAnalyticDBThis page covers how to use the AnalyticDB ecosystem within LangChain.VectorStoreâ€‹There exists a wrapper around AnalyticDB, allowing you to use it as a vectorstore,


whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores import AnalyticDBFor a more detailed walkthrough of the AnalyticDB wrapper, see this notebookPreviousAmazon API GatewayNextAnnoyVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Milvus | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerMilvusOn this pageMilvusThis page covers how to use the Milvus ecosystem within LangChain.


It is broken into two parts: installation and setup, and then references to specific Milvus wrappers.Installation and Setupâ€‹Install the Python SDK with pip install pymilvusWrappersâ€‹VectorStoreâ€‹There exists a wrapper around Milvus indexes, allowing you to use it as a vectorstore,
whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores import MilvusFor a more detailed walkthrough of the Miluvs wrapper, see this notebookPreviousMicrosoft WordNextMLflow AI GatewayInstallation and SetupWrappersVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Momento | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerMomentoOn this pageMomentoMomento Cache is the world's first truly serverless caching service. It provides instant elasticity, scale-to-zero


capability, and blazing-fast performance.
With Momento Cache, you grab the SDK, you get an end point, input a few lines into your code, and you're off and running.This page covers how to use the Momento ecosystem within LangChain.Installation and Setupâ€‹Sign up for a free account here and get an auth tokenInstall the Momento Python SDK with pip install momentoCacheâ€‹The Cache wrapper allows for Momento to be used as a serverless, distributed, low-latency cache for LLM prompts and responses.The standard cache is the go-to use case for Momento users in any environment.Import the cache as follows:from langchain.cache import MomentoCacheAnd set up like so:from datetime import timedeltafrom momento import CacheClient, Configurations, CredentialProviderimport langchain# Instantiate the Momento clientcache_client = CacheClient(    Configurations.Laptop.v1(),    CredentialProvider.from_environment_variable("MOMENTO_AUTH_TOKEN"),    default_ttl=timedelta(days=1))# Choose a Momento cache name of your choicecache_name = "langchain"# Instantiate the LLM cachelangchain.llm_cache = MomentoCache(cache_client, cache_name)Memoryâ€‹Momento can be used as a distributed memory store for LLMs.Chat Message History Memoryâ€‹See this notebook for a walkthrough of how to use Momento as a memory store for chat message history.PreviousModern TreasuryNextMotherduckInstallation and SetupCacheMemoryChat Message History MemoryCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


CerebriumAI | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerCerebriumAIOn this pageCerebriumAIThis page covers how to use the CerebriumAI ecosystem within LangChain.


It is broken into two parts: installation and setup, and then references to specific CerebriumAI wrappers.Installation and Setupâ€‹Install with pip install cerebriumGet an CerebriumAI api key and set it as an environment variable (CEREBRIUMAI_API_KEY)Wrappersâ€‹LLMâ€‹There exists an CerebriumAI LLM wrapper, which you can access with from langchain.llms import CerebriumAIPreviousCassandraNextChaindeskInstallation and SetupWrappersLLMCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


2Markdown | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by provider2MarkdownOn this page2Markdown2markdown service transforms website content into structured markdown files.Installation and Setupâ€‹We need the API key. See instructions how to get it.Document Loaderâ€‹See a usage example.from langchain.document_loaders import ToMarkdownLoaderPreviousTigrisNextTrelloInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Writer | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerWriterOn this pageWriterThis page covers how to use the Writer ecosystem within LangChain.


It is broken into two parts: installation and setup, and then references to specific Writer wrappers.Installation and Setupâ€‹Get an Writer api key and set it as an environment variable (WRITER_API_KEY)Wrappersâ€‹LLMâ€‹There exists an Writer LLM wrapper, which you can access with from langchain.llms import WriterPreviousWolfram AlphaNextYeager.aiInstallation and SetupWrappersLLMCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Replicate | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerReplicateOn this pageReplicateThis page covers how to run models on Replicate within LangChain.Installation and Setupâ€‹Create a Replicate account. Get your API key and set it as an environment variable (REPLICATE_API_TOKEN)Install the Replicate python client with pip install replicateCalling a modelâ€‹Find a model on the Replicate explore page, and then paste in the model name and version in this format: owner-name/model-name:versionFor example, for this dolly model, click on the API tab. The model name/version would be: "replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5"Only the model param is required, but any other model parameters can also be passed in with the format input={model_param: value, ...}For example, if we were running stable diffusion and wanted to change the image dimensions:Replicate(model="stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", input={'image_dimensions': '512x512'})Note that only the first output of a model will be returned.


From here, we can initialize our model:llm = Replicate(model="replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5")And run it:prompt = """Answer the following yes/no question by reasoning step by step.Can a dog drive a car?"""llm(prompt)We can call any Replicate model (not just LLMs) using this syntax. For example, we can call Stable Diffusion:text2image = Replicate(model="stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", input={'image_dimensions':'512x512'})image_output = text2image("A cat riding a motorcycle by Picasso")PreviousRedisNextRoamInstallation and SetupCalling a modelCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Wolfram Alpha | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerWolfram AlphaOn this pageWolfram AlphaWolframAlpha is an answer engine developed by Wolfram Research.


It answers factual queries by computing answers from externally sourced data.This page covers how to use the Wolfram Alpha API within LangChain.Installation and Setupâ€‹Install requirements with pip install wolframalphaGo to wolfram alpha and sign up for a developer account hereCreate an app and get your APP IDSet your APP ID as an environment variable WOLFRAM_ALPHA_APPIDWrappersâ€‹Utilityâ€‹There exists a WolframAlphaAPIWrapper utility which wraps this API. To import this utility:from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapperFor a more detailed walkthrough of this wrapper, see this notebook.Toolâ€‹You can also easily load this wrapper as a Tool (to use with an Agent).
You can do this with:from langchain.agents import load_toolstools = load_tools(["wolfram-alpha"])For more information on tools, see this page.PreviousWikipediaNextWriterInstallation and SetupWrappersUtilityToolCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Deep Lake | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerDeep LakeOn this pageDeep LakeThis page covers how to use the Deep Lake ecosystem within LangChain.Why Deep Lake?â€‹More than just a (multi-modal) vector store. You can later use the dataset to fine-tune your own LLM models.Not only stores embeddings, but also the original data with automatic version control.Truly serverless. Doesn't require another service and can be used with major cloud providers (AWS S3, GCS, etc.)More Resourcesâ€‹Ultimate Guide to LangChain & Deep Lake: Build ChatGPT to Answer Questions on Your Financial DataTwitter the-algorithm codebase analysis with Deep LakeHere is whitepaper and academic paper for Deep LakeHere is a set of additional resources available for review: Deep Lake, Get started andÂ TutorialsInstallation and Setupâ€‹Install the Python package with pip install deeplakeWrappersâ€‹VectorStoreâ€‹There exists a wrapper around Deep Lake, a data lake for Deep Learning applications, allowing you to use it as a vector store (for now), whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores import DeepLakeFor a more detailed walkthrough of the Deep Lake wrapper, see this notebookPreviousDeepInfraNextDiffbotWhy Deep Lake?More ResourcesInstallation and SetupWrappersVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


PipelineAI | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerPipelineAIOn this pagePipelineAIThis page covers how to use the PipelineAI ecosystem within LangChain.


It is broken into two parts: installation and setup, and then references to specific PipelineAI wrappers.Installation and Setupâ€‹Install with pip install pipeline-aiGet a Pipeline Cloud api key and set it as an environment variable (PIPELINE_API_KEY)Wrappersâ€‹LLMâ€‹There exists a PipelineAI LLM wrapper, which you can access withfrom langchain.llms import PipelineAIPreviousPineconeNextPortkeyInstallation and SetupWrappersLLMCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


GPT4All | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerGPT4AllOn this pageGPT4AllThis page covers how to use the GPT4All wrapper within LangChain. The tutorial is divided into two parts: installation and setup, followed by usage with an example.Installation and Setupâ€‹Install the Python package with pip install pyllamacppDownload a GPT4All model and place it in your desired directoryUsageâ€‹GPT4Allâ€‹To use the GPT4All wrapper, you need to provide the path to the pre-trained model file and the model's configuration.from langchain.llms import GPT4All# Instantiate the model. Callbacks support token-wise streamingmodel = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8)# Generate textresponse = model("Once upon a time, ")You can also customize the generation parameters, such as n_predict, temp, top_p, top_k, and others.To stream the model's predictions, add in a CallbackManager.from langchain.llms import GPT4Allfrom langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler# There are many CallbackHandlers supported, such as# from langchain.callbacks.streamlit import StreamlitCallbackHandlercallbacks = [StreamingStdOutCallbackHandler()]model = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8)# Generate text. Tokens are streamed through the callback manager.model("Once upon


n_threads=8)# Generate text. Tokens are streamed through the callback manager.model("Once upon a time, ", callbacks=callbacks)Model Fileâ€‹You can find links to model file downloads in the pyllamacpp repository.For a more detailed walkthrough of this, see this notebookPreviousGooseAINextGraphsignalInstallation and SetupUsageGPT4AllModel FileCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


College Confidential | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerCollege ConfidentialOn this pageCollege ConfidentialCollege Confidential gives information on 3,800+ colleges and universities.Installation and Setupâ€‹There isn't any special setup for it.Document Loaderâ€‹See a usage example.from langchain.document_loaders import CollegeConfidentialLoaderPreviousCohereNextCometInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Twitter | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerTwitterOn this pageTwitterTwitter is an online social media and social networking service.Installation and Setupâ€‹pip install tweepyWe must initialize the loader with the Twitter API token, and we need to set up the Twitter username.Document Loaderâ€‹See a usage example.from langchain.document_loaders import TwitterTweetLoaderPreviousTruLensNextTypesenseInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Azure OpenAI | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerAzure OpenAIOn this pageAzure OpenAIMicrosoft Azure, often referred to as Azure is a cloud computing platform run by Microsoft, which offers access, management, and development of applications and services through global data centers. It provides a range of capabilities, including software as a service (SaaS), platform as a service (PaaS), and infrastructure as a service (IaaS). Microsoft Azure supports many programming languages, tools, and frameworks, including Microsoft-specific and third-party software and systems.Azure OpenAI is an Azure service with powerful language models from OpenAI including the GPT-3, Codex and Embeddings model series for content generation, summarization, semantic search, and natural language to code translation.Installation and Setupâ€‹pip install openaipip install tiktokenSet the environment variables to get access to the Azure OpenAI service.import osos.environ["OPENAI_API_TYPE"] = "azure"os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/"os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"os.environ["OPENAI_API_VERSION"] = "2023-05-15"LLMâ€‹See a usage example.from langchain.llms import AzureOpenAIText Embedding Modelsâ€‹See a usage examplefrom langchain.embeddings import OpenAIEmbeddingsChat Modelsâ€‹See a usage examplefrom langchain.chat_models import AzureChatOpenAIPreviousAzure Cognitive


a usage examplefrom langchain.chat_models import AzureChatOpenAIPreviousAzure Cognitive SearchNextBananaInstallation and SetupLLMText Embedding ModelsChat ModelsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Llama.cpp | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerLlama.cppOn this pageLlama.cppThis page covers how to use llama.cpp within LangChain.


It is broken into two parts: installation and setup, and then references to specific Llama-cpp wrappers.Installation and Setupâ€‹Install the Python package with pip install llama-cpp-pythonDownload one of the supported models and convert them to the llama.cpp format per the instructionsWrappersâ€‹LLMâ€‹There exists a LlamaCpp LLM wrapper, which you can access with from langchain.llms import LlamaCppFor a more detailed walkthrough of this, see this notebookEmbeddingsâ€‹There exists a LlamaCpp Embeddings wrapper, which you can access with from langchain.embeddings import LlamaCppEmbeddingsFor a more detailed walkthrough of this, see this notebookPreviousLangChain Decorators âœ¨NextMarqoInstallation and SetupWrappersLLMEmbeddingsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Modern Treasury | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerModern TreasuryOn this pageModern TreasuryModern Treasury simplifies complex payment operations. It is a unified platform to power products and processes that move money.Connect to banks and payment systemsTrack transactions and balances in real-timeAutomate payment operations for scaleInstallation and Setupâ€‹There isn't any special setup for it.Document Loaderâ€‹See a usage example.from langchain.document_loaders import ModernTreasuryLoaderPreviousModelScopeNextMomentoInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Git | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerGitOn this pageGitGit is a distributed version control system that tracks changes in any set of computer files, usually used for coordinating work among programmers collaboratively developing source code during software development.Installation and Setupâ€‹First, you need to install GitPython python package.pip install GitPythonDocument Loaderâ€‹See a usage example.from langchain.document_loaders import GitLoaderPreviousForefrontAINextGitBookInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Tair | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerTairOn this pageTairThis page covers how to use the Tair ecosystem within LangChain.Installation and Setupâ€‹Install Tair Python SDK with pip install tair.Wrappersâ€‹VectorStoreâ€‹There exists a wrapper around TairVector, allowing you to use it as a vectorstore,


whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores import TairFor a more detailed walkthrough of the Tair wrapper, see this notebookPreviousStripeNextTelegramInstallation and SetupWrappersVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Flyte | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerFlyteOn this pageFlyteFlyte is an open-source orchestrator that facilitates building production-grade data and ML pipelines.


It is built for scalability and reproducibility, leveraging Kubernetes as its underlying platform.The purpose of this notebook is to demonstrate the integration of a FlyteCallback into your Flyte task, enabling you to effectively monitor and track your LangChain experiments.Installation & Setupâ€‹Install the Flytekit library by running the command pip install flytekit.Install the Flytekit-Envd plugin by running the command pip install flytekitplugins-envd.Install LangChain by running the command pip install langchain.Install Docker on your system.Flyte Tasksâ€‹A Flyte task serves as the foundational building block of Flyte.
To execute LangChain experiments, you need to write Flyte tasks that define the specific steps and operations involved.NOTE: The getting started guide offers detailed, step-by-step instructions on installing Flyte locally and running your initial Flyte pipeline.First, import the necessary dependencies to support your LangChain experiments.import osfrom flytekit import ImageSpec, taskfrom langchain.agents import AgentType, initialize_agent, load_toolsfrom langchain.callbacks import FlyteCallbackHandlerfrom langchain.chains import LLMChainfrom langchain.chat_models import ChatOpenAIfrom langchain.prompts import PromptTemplatefrom langchain.schema import HumanMessageSet up the necessary environment variables to utilize the OpenAI API and Serp API:# Set OpenAI API keyos.environ["OPENAI_API_KEY"] = "<your_openai_api_key>"# Set Serp API keyos.environ["SERPAPI_API_KEY"] = "<your_serp_api_key>"Replace <your_openai_api_key> and <your_serp_api_key> with your respective API keys obtained from OpenAI and Serp API.To guarantee reproducibility of your pipelines, Flyte tasks are containerized.


Each Flyte task must be associated with an image, which can either be shared across the entire Flyte workflow or provided separately for each task.To streamline the process of supplying the required dependencies for each Flyte task, you can initialize an ImageSpec object.
This approach automatically triggers a Docker build, alleviating the need for users to manually create a Docker image.custom_image = ImageSpec(    name="langchain-flyte",    packages=[        "langchain",        "openai",        "spacy",        "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz",        "textstat",        "google-search-results",    ],    registry="<your-registry>",)You have the flexibility to push the Docker image to a registry of your preference.


Docker Hub or GitHub Container Registry (GHCR) is a convenient option to begin with.Once you have selected a registry, you can proceed to create Flyte tasks that log the LangChain metrics to Flyte Deck.The following examples demonstrate tasks related to OpenAI LLM, chains and agent with tools:LLMâ€‹@task(disable_deck=False, container_image=custom_image)def langchain_llm() -> str:    llm = ChatOpenAI(        model_name="gpt-3.5-turbo",        temperature=0.2,        callbacks=[FlyteCallbackHandler()],    )    return llm([HumanMessage(content="Tell me a joke")]).contentChainâ€‹@task(disable_deck=False, container_image=custom_image)def langchain_chain() -> list[dict[str, str]]:    template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.Title: {title}Playwright: This is a synopsis for the above play:"""    llm = ChatOpenAI(        model_name="gpt-3.5-turbo",        temperature=0,        callbacks=[FlyteCallbackHandler()],    )    prompt_template = PromptTemplate(input_variables=["title"], template=template)    synopsis_chain = LLMChain(        llm=llm, prompt=prompt_template, callbacks=[FlyteCallbackHandler()]    )    test_prompts = [        {            "title": "documentary about good video games that


"title": "documentary about good video games that push the boundary of game design"        },    ]    return synopsis_chain.apply(test_prompts)Agentâ€‹@task(disable_deck=False, container_image=custom_image)def langchain_agent() -> str:    llm = OpenAI(        model_name="gpt-3.5-turbo",        temperature=0,        callbacks=[FlyteCallbackHandler()],    )    tools = load_tools(        ["serpapi", "llm-math"], llm=llm, callbacks=[FlyteCallbackHandler()]    )    agent = initialize_agent(        tools,        llm,        agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,        callbacks=[FlyteCallbackHandler()],        verbose=True,    )    return agent.run(        "Who is Leonardo DiCaprio's girlfriend? Could you calculate her current age and raise it to the power of 0.43?"    )These tasks serve as a starting point for running your LangChain experiments within Flyte.Execute the Flyte Tasks on Kubernetesâ€‹To execute the Flyte tasks on the configured Flyte backend, use the following command:pyflyte run --image <your-image> langchain_flyte.py langchain_llmThis command will initiate the execution of the langchain_llm task on the Flyte backend. You can trigger the remaining two tasks in a similar manner.The metrics will be displayed on the Flyte


You can trigger the remaining two tasks in a similar manner.The metrics will be displayed on the Flyte UI as follows:PreviousFigmaNextForefrontAIInstallation & SetupFlyte TasksLLMChainAgentExecute the Flyte Tasks on KubernetesCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Notion DB | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerNotion DBOn this pageNotion DBNotion is a collaboration platform with modified Markdown support that integrates kanban


boards, tasks, wikis and databases. It is an all-in-one workspace for notetaking, knowledge and data management,
and project and task management.Installation and Setupâ€‹All instructions are in examples below.Document Loaderâ€‹We have two different loaders: NotionDirectoryLoader and NotionDBLoader.See a usage example for the NotionDirectoryLoader.from langchain.document_loaders import NotionDirectoryLoaderSee a usage example for the NotionDBLoader.from langchain.document_loaders import NotionDBLoaderPreviousNLPCloudNextObsidianInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


OpenAI | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerOpenAIOn this pageOpenAIOpenAI is American artificial intelligence (AI) research laboratory


consisting of the non-profit OpenAI Incorporated
and its for-profit subsidiary corporation OpenAI Limited Partnership.
OpenAI conducts AI research with the declared intention of promoting and developing a friendly AI.
OpenAI systems run on an Azure-based supercomputing platform from Microsoft.The OpenAI API is powered by a diverse set of models with different capabilities and price points.ChatGPT is the Artificial Intelligence (AI) chatbot developed by OpenAI.Installation and Setupâ€‹Install the Python SDK withpip install openaiGet an OpenAI api key and set it as an environment variable (OPENAI_API_KEY)If you want to use OpenAI's tokenizer (only available for Python 3.9+), install itpip install tiktokenLLMâ€‹from langchain.llms import OpenAIIf you are using a model hosted on Azure, you should use different wrapper for that:from langchain.llms import AzureOpenAIFor a more detailed walkthrough of the Azure wrapper, see this notebookText Embedding Modelâ€‹from langchain.embeddings import OpenAIEmbeddingsFor a more detailed walkthrough of this, see this notebookTokenizerâ€‹There are several places you can use the tiktoken tokenizer. By default, it is used to count tokens


for OpenAI LLMs.You can also use it to count tokens when splitting documents with from langchain.text_splitter import CharacterTextSplitterCharacterTextSplitter.from_tiktoken_encoder(...)For a more detailed walkthrough of this, see this notebookChainâ€‹See a usage example.from langchain.chains import OpenAIModerationChainDocument Loaderâ€‹See a usage example.from langchain.document_loaders.chatgpt import ChatGPTLoaderRetrieverâ€‹See a usage example.from langchain.retrievers import ChatGPTPluginRetrieverPreviousObsidianNextOpenLLMInstallation and SetupLLMText Embedding ModelTokenizerChainDocument LoaderRetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


AwaDB | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerAwaDBOn this pageAwaDBAwaDB is an AI Native database for the search and storage of embedding vectors used by LLM Applications.Installation and Setupâ€‹pip install awadbVectorStoreâ€‹There exists a wrapper around AwaDB vector databases, allowing you to use it as a vectorstore,


whether for semantic search or example selection.from langchain.vectorstores import AwaDBFor a more detailed walkthrough of the AwaDB wrapper, see here.PreviousAtlasDBNextAWS S3 DirectoryInstallation and SetupVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Arxiv | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerArxivOn this pageArxivarXiv is an open-access archive for 2 million scholarly articles in the fields of physics,


mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and
systems science, and economics.Installation and Setupâ€‹First, you need to install arxiv python package.pip install arxivSecond, you need to install PyMuPDF python package which transforms PDF files downloaded from the arxiv.org site into the text format.pip install pymupdfDocument Loaderâ€‹See a usage example.from langchain.document_loaders import ArxivLoaderRetrieverâ€‹See a usage example.from langchain.retrievers import ArxivRetrieverPreviousArthurNextAtlasDBInstallation and SetupDocument LoaderRetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Tigris | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerTigrisOn this pageTigrisTigris is an open source Serverless NoSQL Database and Search Platform designed to simplify building high-performance vector search applications.


Tigris eliminates the infrastructure complexity of managing, operating, and synchronizing multiple tools, allowing you to focus on building great applications instead.Installation and Setupâ€‹pip install tigrisdb openapi-schema-pydantic openai tiktokenVector Storeâ€‹See a usage example.from langchain.vectorstores import TigrisPreviousTelegramNext2MarkdownInstallation and SetupVector StoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


MediaWikiDump | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerMediaWikiDumpOn this pageMediaWikiDumpMediaWiki XML Dumps contain the content of a wiki


(wiki pages with all their revisions), without the site-related data. A XML dump does not create a full backup
of the wiki database, the dump does not contain user accounts, images, edit logs, etc.Installation and Setupâ€‹We need to install several python packages.The mediawiki-utilities supports XML schema 0.11 in unmerged branches.pip install -qU git+https://github.com/mediawiki-utilities/python-mwtypes@updates_schema_0.11The mediawiki-utilities mwxml has a bug, fix PR pending.pip install -qU git+https://github.com/gdedrouas/python-mwxml@xml_format_0.11pip install -qU mwparserfromhellDocument Loaderâ€‹See a usage example.from langchain.document_loaders import MWDumpLoaderPreviousMarqoNextMetalInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Vespa | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerVespaOn this pageVespaVespa is a fully featured search engine and vector database.


It supports vector search (ANN), lexical search, and search in structured data, all in the same query.Installation and Setupâ€‹pip install pyvespaRetrieverâ€‹See a usage example.from langchain.retrievers import VespaRetrieverPreviousVectara Text GenerationNextWeights & BiasesInstallation and SetupRetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Datadog Tracing | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerDatadog TracingOn this pageDatadog Tracingddtrace is a Datadog application performance monitoring (APM) library which provides an integration to monitor your LangChain application.Key features of the ddtrace integration for LangChain:Traces: Capture LangChain requests, parameters, prompt-completions, and help visualize LangChain operations.Metrics: Capture LangChain request latency, errors, and token/cost usage (for OpenAI LLMs and Chat Models).Logs: Store prompt completion data for each LangChain operation.Dashboard: Combine metrics, logs, and trace data into a single plane to monitor LangChain requests.Monitors: Provide alerts in response to spikes in LangChain request latency or error rate.Note: The ddtrace LangChain integration currently provides tracing for LLMs, Chat Models, Text Embedding Models, Chains, and Vectorstores.Installation and Setupâ€‹Enable APM and StatsD in your Datadog Agent, along with a Datadog API key. For example, in Docker:docker run -d --cgroupns host \              --pid host \              -v /var/run/docker.sock:/var/run/docker.sock:ro \              -v /proc/:/host/proc/:ro \


\              -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \              -e DD_API_KEY=<DATADOG_API_KEY> \              -p 127.0.0.1:8126:8126/tcp \              -p 127.0.0.1:8125:8125/udp \              -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \              -e DD_APM_ENABLED=true \              gcr.io/datadoghq/agent:latestInstall the Datadog APM Python library.pip install ddtrace>=1.17The LangChain integration can be enabled automatically when you prefix your LangChain Python application command with ddtrace-run:DD_SERVICE="my-service" DD_ENV="staging" DD_API_KEY=<DATADOG_API_KEY> ddtrace-run python <your-app>.pyNote: If the Agent is using a non-default hostname or port, be sure to also set DD_AGENT_HOST, DD_TRACE_AGENT_PORT, or DD_DOGSTATSD_PORT.Additionally, the LangChain integration can be enabled programmatically by adding patch_all() or patch(langchain=True) before the first import of langchain in your application.Note that using ddtrace-run or patch_all() will also enable the requests and aiohttp integrations which trace HTTP requests to LLM providers, as well as the openai integration which traces requests to the OpenAI library.from ddtrace import config, patch# Note: be sure to configure the integration before calling ``patch()``!#


config, patch# Note: be sure to configure the integration before calling ``patch()``!# eg. config.langchain["logs_enabled"] = Truepatch(langchain=True)# to trace synchronous HTTP requests# patch(langchain=True, requests=True)# to trace asynchronous HTTP requests (to the OpenAI library)# patch(langchain=True, aiohttp=True)# to include underlying OpenAI spans from the OpenAI integration# patch(langchain=True, openai=True)patch_allSee the [APM Python library documentation][https://ddtrace.readthedocs.io/en/stable/installation_quickstart.html] for more advanced usage.Configurationâ€‹See the [APM Python library documentation][https://ddtrace.readthedocs.io/en/stable/integrations.html#langchain] for all the available configuration options.Log Prompt & Completion Samplingâ€‹To enable log prompt and completion sampling, set the DD_LANGCHAIN_LOGS_ENABLED=1 environment variable. By default, 10% of traced requests will emit logs containing the prompts and completions.To adjust the log sample rate, see the [APM library documentation][https://ddtrace.readthedocs.io/en/stable/integrations.html#langchain].Note: Logs submission requires DD_API_KEY to be specified when running ddtrace-run.Troubleshootingâ€‹Need help? Create an issue on ddtrace or contact [Datadog support][https://docs.datadoghq.com/help/].PreviousDatabricksNextDatadog LogsInstallation and SetupConfigurationLog Prompt & Completion SamplingTroubleshootingCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Cohere | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerCohereOn this pageCohereCohere is a Canadian startup that provides natural language processing models


that help companies improve human-machine interactions.Installation and Setupâ€‹Install the Python SDK :pip install cohereGet a Cohere api key and set it as an environment variable (COHERE_API_KEY)LLMâ€‹There exists an Cohere LLM wrapper, which you can access with
See a usage example.from langchain.llms import CohereText Embedding Modelâ€‹There exists an Cohere Embedding model, which you can access with from langchain.embeddings import CohereEmbeddingsFor a more detailed walkthrough of this, see this notebookRetrieverâ€‹See a usage example.from langchain.retrievers.document_compressors import CohereRerankPreviousCnosDBNextCollege ConfidentialInstallation and SetupLLMText Embedding ModelRetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Golden | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerGoldenOn this pageGoldenGolden provides a set of natural language APIs for querying and enrichment using the Golden Knowledge Graph e.g. queries such as: Products from OpenAI, Generative ai companies with series a funding, and rappers who invest can be used to retrieve relevant structured data about relevant entities.The golden-query langchain tool is a wrapper on top of the Golden Query API which enables programmatic access to these results.


See the Golden Query API docs for more information.Installation and Setupâ€‹Go to the Golden API docs to get an overview about the Golden API.Get your API key from the Golden API Settings page.Save your API key into GOLDEN_API_KEY env variableWrappersâ€‹Utilityâ€‹There exists a GoldenQueryAPIWrapper utility which wraps this API. To import this utility:from langchain.utilities.golden_query import GoldenQueryAPIWrapperFor a more detailed walkthrough of this wrapper, see this notebook.Toolâ€‹You can also easily load this wrapper as a Tool (to use with an Agent).
You can do this with:from langchain.agents import load_toolstools = load_tools(["golden-query"])For more information on tools, see this page.PreviousGitBookNextGoogle BigQueryInstallation and SetupWrappersUtilityToolCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Blackboard | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerBlackboardOn this pageBlackboardBlackboard Learn (previously the Blackboard Learning Management System)


is a web-based virtual learning environment and learning management system developed by Blackboard Inc.
The software features course management, customizable open architecture, and scalable design that allows
integration with student information systems and authentication protocols. It may be installed on local servers,
hosted by Blackboard ASP Solutions, or provided as Software as a Service hosted on Amazon Web Services.
Its main purposes are stated to include the addition of online elements to courses traditionally delivered
face-to-face and development of completely online courses with few or no face-to-face meetings.Installation and Setupâ€‹There isn't any special setup for it.Document Loaderâ€‹See a usage example.from langchain.document_loaders import BlackboardLoaderPreviousBiliBiliNextBrave SearchInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Datadog Logs | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerDatadog LogsOn this pageDatadog LogsDatadog is a monitoring and analytics platform for cloud-scale applications.Installation and Setupâ€‹pip install datadog_api_clientWe must initialize the loader with the Datadog API key and APP key, and we need to set up the query to extract the desired logs.Document Loaderâ€‹See a usage example.from langchain.document_loaders import DatadogLogsLoaderPreviousDatadog TracingNextDataForSEOInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


PGVector | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerPGVectorOn this pagePGVectorThis page covers how to use the Postgres PGVector ecosystem within LangChain


It is broken into two parts: installation and setup, and then references to specific PGVector wrappers.Installationâ€‹Install the Python package with pip install pgvectorSetupâ€‹The first step is to create a database with the pgvector extension installed.Follow the steps at PGVector Installation Steps to install the database and the extension. The docker image is the easiest way to get started.Wrappersâ€‹VectorStoreâ€‹There exists a wrapper around Postgres vector databases, allowing you to use it as a vectorstore,
whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores.pgvector import PGVectorUsageâ€‹For a more detailed walkthrough of the PGVector Wrapper, see this notebookPreviousPetalsNextPineconeInstallationSetupWrappersVectorStoreUsageCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Discord | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerDiscordOn this pageDiscordDiscord is a VoIP and instant messaging social platform. Users have the ability to communicate


with voice calls, video calls, text messaging, media and files in private chats or as part of communities called
"servers". A server is a collection of persistent chat rooms and voice channels which can be accessed via invite links.Installation and Setupâ€‹pip install pandasFollow these steps to download your Discord data:Go to your User SettingsThen go to Privacy and SafetyHead over to the Request all of my Data and click on Request Data buttonIt might take 30 days for you to receive your data. You'll receive an email at the address which is registered
with Discord. That email will have a download button using which you would be able to download your personal Discord data.Document Loaderâ€‹See a usage example.from langchain.document_loaders import DiscordChatLoaderPreviousDiffbotNextDocugamiInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


OpenWeatherMap | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerOpenWeatherMapOn this pageOpenWeatherMapOpenWeatherMap provides all essential weather data for a specific location:Current weatherMinute forecast for 1 hourHourly forecast for 48 hoursDaily forecast for 8 daysNational weather alertsHistorical weather data for 40+ years backThis page covers how to use the OpenWeatherMap API within LangChain.Installation and Setupâ€‹Install requirements withpip install pyowmGo to OpenWeatherMap and sign up for an account to get your API key hereSet your API key as OPENWEATHERMAP_API_KEY environment variableWrappersâ€‹Utilityâ€‹There exists a OpenWeatherMapAPIWrapper utility which wraps this API. To import this utility:from langchain.utilities.openweathermap import OpenWeatherMapAPIWrapperFor a more detailed walkthrough of this wrapper, see this notebook.Toolâ€‹You can also easily load this wrapper as a Tool (to use with an Agent).


You can do this with:from langchain.agents import load_toolstools = load_tools(["openweathermap-api"])For more information on tools, see this page.PreviousOpenSearchNextPetalsInstallation and SetupWrappersUtilityToolCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


SageMaker Endpoint | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerSageMaker EndpointOn this pageSageMaker EndpointAmazon SageMaker is a system that can build, train, and deploy machine learning (ML) models with fully managed infrastructure, tools, and workflows.We use SageMaker to host our model and expose it as the SageMaker Endpoint.Installation and Setupâ€‹pip install boto3For instructions on how to expose model as a SageMaker Endpoint, please see here. Note: In order to handle batched requests, we need to adjust the return line in the predict_fn() function within the custom inference.py script:Change fromreturn {"vectors": sentence_embeddings[0].tolist()}to:return {"vectors": sentence_embeddings.tolist()}We have to set up following required parameters of the SagemakerEndpoint call:endpoint_name: The name of the endpoint from the deployed Sagemaker model.


Must be unique within an AWS Region.credentials_profile_name: 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 this guide.LLMâ€‹See a usage example.from langchain import SagemakerEndpointfrom langchain.llms.sagemaker_endpoint import LLMContentHandlerText Embedding Modelsâ€‹See a usage example.from langchain.embeddings import SagemakerEndpointEmbeddingsfrom langchain.llms.sagemaker_endpoint import ContentHandlerBasePreviousRWKV-4NextSearxNG Search APIInstallation and SetupLLMText Embedding ModelsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


DuckDB | ğŸ¦œï¸�ğŸ”— Langchain


Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAgent toolkitsToolsVector storesGrouped by providerWandB TracingAI21 LabsAimAirbyteAirtableAleph AlphaAlibaba Cloud OpensearchAmazon API GatewayAnalyticDBAnnoyAnyscaleApifyArangoDBArgillaArthurArxivAtlasDBAwaDBAWS S3 DirectoryAZLyricsAzure Blob StorageAzure Cognitive SearchAzure OpenAIBananaBasetenBeamBedrockBiliBiliBlackboardBrave SearchCassandraCerebriumAIChaindeskChromaClarifaiClearMLCnosDBCohereCollege ConfidentialCometConfluenceC TransformersDatabricksDatadog TracingDatadog LogsDataForSEODeepInfraDeep LakeDiffbotDiscordDocugamiDuckDBElasticsearchEverNoteFacebook ChatFigmaFlyteForefrontAIGitGitBookGoldenGoogle BigQueryGoogle Cloud StorageGoogle DriveGoogle SearchGoogle SerperGooseAIGPT4AllGraphsignalGrobidGutenbergHacker NewsHazy ResearchHeliconeHologresHugging FaceiFixitIMSDbInfinoJinaLanceDBLangChain Decorators âœ¨Llama.cppMarqoMediaWikiDumpMetalMicrosoft OneDriveMicrosoft PowerPointMicrosoft WordMilvusMLflow AI GatewayMLflowModalModelScopeModern TreasuryMomentoMotherduckMyScaleNLPCloudNotion DBObsidianOpenAIOpenLLMOpenSearchOpenWeatherMapPetalsPGVectorPineconePipelineAIPortkeyPredibasePrediction GuardPromptLayerPsychicQdrantRay ServeRebuffRedditRedisReplicateRoamRocksetRunhouseRWKV-4SageMaker EndpointSearxNG Search APISerpAPIShale


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerDuckDBOn this pageDuckDBDuckDB is an in-process SQL OLAP database management system.Installation and Setupâ€‹First, you need to install duckdb python package.pip install duckdbDocument Loaderâ€‹See a usage example.from langchain.document_loaders import DuckDBLoaderPreviousDocugamiNextElasticsearchInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Figma | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerFigmaOn this pageFigmaFigma is a collaborative web application for interface design.Installation and Setupâ€‹The Figma API requires an access token, node_ids, and a file key.The file key can be pulled from the URL.  https://www.figma.com/file/{filekey}/sampleFilenameNode IDs are also available in the URL. Click on anything and look for the '?node-id={node_id}' param.Access token instructions.Document Loaderâ€‹See a usage example.from langchain.document_loaders import FigmaFileLoaderPreviousFacebook ChatNextFlyteInstallation and SetupDocument LoaderCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Hologres | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerHologresOn this pageHologresHologres is a unified real-time data warehousing service developed by Alibaba Cloud. You can use Hologres to write, update, process, and analyze large amounts of data in real time.


Hologres supports standard SQL syntax, is compatible with PostgreSQL, and supports most PostgreSQL functions. Hologres supports online analytical processing (OLAP) and ad hoc analysis for up to petabytes of data, and provides high-concurrency and low-latency online data services. Hologres provides vector database functionality by adopting Proxima.
Proxima is a high-performance software library developed by Alibaba DAMO Academy. It allows you to search for the nearest neighbors of vectors. Proxima provides higher stability and performance than similar open source software such as Faiss. Proxima allows you to search for similar text or image embeddings with high throughput and low latency. Hologres is deeply integrated with Proxima to provide a high-performance vector search service.Installation and Setupâ€‹Click here to fast deploy a Hologres cloud instance.pip install psycopg2Vector Storeâ€‹See a usage example.from langchain.vectorstores import HologresPreviousHeliconeNextHugging FaceInstallation and SetupVector StoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Vectara | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraChat Over Documents with VectaraVectara Text GenerationVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerVectaraOn this pageVectaraWhat is Vectara?Vectara Overview:Vectara is developer-first API platform for building GenAI applicationsTo use Vectara - first sign up and create an account. Then create a corpus and an API key for indexing and searching.You can use Vectara's indexing API to add documents into Vectara's indexYou can use Vectara's Search API to query Vectara's index (which also supports Hybrid search implicitly).You can use Vectara's integration with LangChain as a Vector store or using the Retriever abstraction.Installation and Setupâ€‹To use Vectara with LangChain no special installation steps are required. You just have to provide your customer_id, corpus ID, and an API key created within the Vectara console to enable indexing and searching.Alternatively these can be provided as environment variablesexport VECTARA_CUSTOMER_ID="your_customer_id"export VECTARA_CORPUS_ID="your_corpus_id"export VECTARA_API_KEY="your-vectara-api-key"Usageâ€‹VectorStoreâ€‹There exists a wrapper around the Vectara platform, allowing you to use it as a vectorstore, whether for semantic search or example selection.To import this vectorstore:from langchain.vectorstores import VectaraTo create an instance of the Vectara vectorstore:vectara = Vectara(    vectara_customer_id=customer_id,


= Vectara(    vectara_customer_id=customer_id,     vectara_corpus_id=corpus_id,     vectara_api_key=api_key)The customer_id, corpus_id and api_key are optional, and if they are not supplied will be read from the environment variables VECTARA_CUSTOMER_ID, VECTARA_CORPUS_ID and VECTARA_API_KEY, respectively.After you have the vectorstore, you can add_texts or add_documents as per the standard VectorStore interface, for example:vectara.add_texts(["to be or not to be", "that is the question"])Since Vectara supports file-upload, we also added the ability to upload files (PDF, TXT, HTML, PPT, DOC, etc) directly as file. When using this method, the file is uploaded directly to the Vectara backend, processed and chunked optimally there, so you don't have to use the LangChain document loader or chunking mechanism.As an example:vectara.add_files(["path/to/file1.pdf", "path/to/file2.pdf",...])To query the vectorstore, you can use the similarity_search method (or similarity_search_with_score), which takes a query string and returns a list of results:results = vectara.similarity_score("what is LangChain?")similarity_search_with_score also supports the following additional arguments:k: number of results to return (defaults to 5)lambda_val: the lexical matching factor for hybrid search (defaults to 0.025)filter: a filter to apply to the results (default None)n_sentence_context: number of sentences to include before/after the actual matching segment when returning results. This defaults to 0 so as to return the exact text segment that matches, but can be used with other values e.g. 2 or 3 to return adjacent text segments.The results are returned as a list of relevant documents, and a relevance score of each


adjacent text segments.The results are returned as a list of relevant documents, and a relevance score of each document.For a more detailed examples of using the Vectara wrapper, see one of these two sample notebooks:Chat Over Documents with VectaraVectara Text GenerationPreviousUnstructuredNextChat Over Documents with VectaraInstallation and SetupUsageVectorStoreCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Page Not Found | ğŸ¦œï¸�ğŸ”— Langchain

Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKPage Not FoundWe could not find what you were looking for.Please contact the owner of the site that linked you to the original URL and let them know their link is broken.CommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.


Chat Over Documents with Vectara | ğŸ¦œï¸�ğŸ”— Langchain


EndpointSearxNG Search APISerpAPIShale ProtocolSingleStoreDBscikit-learnSlackspaCySpreedlyStarRocksStochasticAIStripeTairTelegramTigris2MarkdownTrelloTruLensTwitterTypesenseUnstructuredVectaraChat Over Documents with VectaraVectara Text GenerationVespaWeights & BiasesWeatherWeaviateWhatsAppWhyLabsWikipediaWolfram AlphaWriterYeager.aiYouTubeZepZillizIntegrationsGrouped by providerVectaraChat Over Documents with VectaraOn this pageChat Over Documents with VectaraThis notebook is based on the chat_vector_db notebook, but using Vectara as the vector database.import osfrom langchain.vectorstores import Vectarafrom langchain.vectorstores.vectara import VectaraRetrieverfrom langchain.llms import OpenAIfrom langchain.chains import ConversationalRetrievalChainLoad in documents. You can replace this with a loader for whatever type of data you wantfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()We now split the documents, create embeddings for them, and put them in a vectorstore. This allows us to do semantic search over them.vectorstore = Vectara.from_documents(documents, embedding=None)We can now create a memory object, which is neccessary to track the inputs/outputs and hold a conversation.from langchain.memory import ConversationBufferMemorymemory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)We now initialize the ConversationalRetrievalChainopenai_api_key = os.environ["OPENAI_API_KEY"]llm = OpenAI(openai_api_key=openai_api_key, temperature=0)retriever = vectorstore.as_retriever(lambda_val=0.025, k=5, filter=None)d = retriever.get_relevant_documents(    "What did the president say about


= retriever.get_relevant_documents(    "What did the president say about Ketanji Brown Jackson")qa = ConversationalRetrievalChain.from_llm(llm, retriever, memory=memory)query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query})result["answer"]    " The president said that Ketanji Brown Jackson is one of the nation's top legal minds and that she will continue Justice Breyer's legacy of excellence."query = "Did he mention who she suceeded"result = qa({"question": query})result["answer"]    ' Justice Stephen Breyer'Pass in chat historyâ€‹In the above example, we used a Memory object to track chat history. We can also just pass it in explicitly. In order to do this, we need to initialize a chain without any memory object.qa = ConversationalRetrievalChain.from_llm(    OpenAI(temperature=0), vectorstore.as_retriever())Here's an example of asking a question with no chat historychat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})result["answer"]    " The president said that Ketanji Brown Jackson is one of the nation's top legal minds and that she will continue Justice Breyer's legacy of excellence."Here's an example of asking a question with some chat historychat_history = [(query, result["answer"])]query = "Did he mention who she suceeded"result = qa({"question": query, "chat_history": chat_history})result["answer"]    ' Justice Stephen Breyer'Return Source Documentsâ€‹You can also easily return source documents from the ConversationalRetrievalChain. This is useful for when you want to inspect


source documents from the ConversationalRetrievalChain. This is useful for when you want to inspect what documents were returned.qa = ConversationalRetrievalChain.from_llm(    llm, vectorstore.as_retriever(), return_source_documents=True)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})result["source_documents"][0]    Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while youâ€™re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, Iâ€™d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyerâ€”an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \n\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nationâ€™s top legal minds, who will continue Justice Breyerâ€™s legacy of excellence.', metadata={'source': '../../../state_of_the_union.txt'})ConversationalRetrievalChain with search_distanceâ€‹If you are using a vector store that supports filtering by search distance, you can add a threshold value parameter.vectordbkwargs = {"search_distance": 0.9}qa = ConversationalRetrievalChain.from_llm(    OpenAI(temperature=0), vectorstore.as_retriever(), return_source_documents=True)chat_history = []query = "What did the president say about Ketanji Brown


= []query = "What did the president say about Ketanji Brown Jackson"result = qa(    {"question": query, "chat_history": chat_history, "vectordbkwargs": vectordbkwargs})print(result["answer"])     The president said that Ketanji Brown Jackson is one of the nation's top legal minds and that she will continue Justice Breyer's legacy of excellence.ConversationalRetrievalChain with map_reduceâ€‹We can also use different types of combine document chains with the ConversationalRetrievalChain chain.from langchain.chains import LLMChainfrom langchain.chains.question_answering import load_qa_chainfrom langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPTquestion_generator = LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain = load_qa_chain(llm, chain_type="map_reduce")chain = ConversationalRetrievalChain(    retriever=vectorstore.as_retriever(),    question_generator=question_generator,    combine_docs_chain=doc_chain,)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = chain({"question": query, "chat_history": chat_history})result["answer"]    " The president said that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson, who he described as one of the nation's top legal minds, to continue Justice Breyer's legacy of excellence."ConversationalRetrievalChain with Question Answering with sourcesâ€‹You can also use this chain with the question answering with sources chain.from langchain.chains.qa_with_sources import load_qa_with_sources_chainquestion_generator = LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain =


LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain = load_qa_with_sources_chain(llm, chain_type="map_reduce")chain = ConversationalRetrievalChain(    retriever=vectorstore.as_retriever(),    question_generator=question_generator,    combine_docs_chain=doc_chain,)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = chain({"question": query, "chat_history": chat_history})result["answer"]    " The president said that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson, who he described as one of the nation's top legal minds, and that she will continue Justice Breyer's legacy of excellence.\nSOURCES: ../../../state_of_the_union.txt"ConversationalRetrievalChain with streaming to stdoutâ€‹Output from the chain will be streamed to stdout token by token in this example.from langchain.chains.llm import LLMChainfrom langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandlerfrom langchain.chains.conversational_retrieval.prompts import (    CONDENSE_QUESTION_PROMPT,    QA_PROMPT,)from langchain.chains.question_answering import load_qa_chain# Construct a ConversationalRetrievalChain with a streaming llm for combine docs# and a separate, non-streaming llm for question generationllm = OpenAI(temperature=0, openai_api_key=openai_api_key)streaming_llm = OpenAI(    streaming=True,    callbacks=[StreamingStdOutCallbackHandler()],    temperature=0,    openai_api_key=openai_api_key,)question_generator = LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain = load_qa_chain(streaming_llm,