🗃 Document transformers
8 items


📄 AzureML Chat Online Endpoint
AzureML is a platform used to build, train, and deploy machine learning models. Users can explore the types of models to deploy in the Model Catalog, which provides Azure Foundation Models and OpenAI Models. Azure Foundation Models include various open-source models and popular Hugging Face models. Users can also import models of their liking into AzureML.


📄 Label Studio
Label Studio is an open-source data labeling platform that provides LangChain with flexibility when it comes to labeling data for fine-tuning large language models (LLMs). It also enables the preparation of custom training data and the collection and evaluation of responses through human feedback.


Chat loaders
Like document loaders, chat loaders are utilities designed to help load conversations from popular communication platforms such as Facebook, Slack, Discord, etc. These are loaded into memory as LangChain chat message objects. Such utilities facilitate tasks such as fine-tuning a language model to match your personal style or voice.
This brief guide will illustrate the process using OpenAI's fine-tuning API comprised of six steps:
Export your Facebook Messenger chat data in a compatible format for your intended chat loader.
Load the chat data into memory as LangChain chat message objects. (this is what is covered in each integration notebook in this section of the documentation).
Assign a person to the "AI" role and optionally filter, group, and merge messages.
Export these acquired messages in a format expected by the fine-tuning API.
Upload this data to OpenAI.
Fine-tune your model.
Implement the fine-tuned model in LangChain.
This guide is not wholly comprehensive but is designed to take you through the fundamentals of going from raw data to fine-tuned model.
We will demonstrate the procedure through an example of fine-tuning a gpt-3.5-turbo model on Facebook Messenger data.
1. Export your chat data
To export your Facebook messenger data, you can follow the instructions here.
JSON format
You must select "JSON format" (instead of HTML) when exporting your data to be compatible with the current loader.
OpenAI requires at least 10 examples to fine-tune your model, but they recommend between 50-100 for more optimal results. You can use the example data stored at this google drive link to test the process.
2. Load the chat
Once you've obtained your chat data, you can load it into memory as LangChain chat message objects. Here’s an example of loading data using the Python code:
from langchain.chat_loaders.facebook_messenger import FolderFacebookMessengerChatLoader

loader = FolderFacebookMessengerChatLoader(
path="./facebook_messenger_chats",
)


loader = FolderFacebookMessengerChatLoader(
path="./facebook_messenger_chats",
)

chat_sessions = loader.load()
In this snippet, we point the loader to a directory of Facebook chat dumps which are then loaded as multiple "sessions" of messages, one session per conversation file.
Once you've loaded the messages, you should decide which person you want to fine-tune the model to (usually yourself). You can also decide to merge consecutive messages from the same sender into a single chat message. For both of these tasks, you can use the chat_loaders utilities to do so:
from langchain.chat_loaders.utils import (
merge_chat_runs,
map_ai_messages,
)

merged_sessions = merge_chat_runs(chat_sessions)
alternating_sessions = list(map_ai_messages(merged_sessions, "My Name"))
3. Export messages to OpenAI format
Convert the chat messages to dictionaries using the convert_messages_for_finetuning function. Then, group the data into chunks for better context modeling and overlap management.
from langchain.adapters.openai import convert_messages_for_finetuning

openai_messages = convert_messages_for_finetuning(chat_sessions)
At this point, the data is ready for upload to OpenAI. You can choose to split up conversations into smaller chunks for training if you do not have enough conversations to train on. Feel free to play around with different chunk sizes or with adding system messages to the fine-tuning data.
chunk_size = 8
overlap = 2

message_groups = [
conversation_messages[i: i + chunk_size]
for conversation_messages in openai_messages
for i in range(
0, len(conversation_messages) - chunk_size + 1,
chunk_size - overlap)
]

len(message_groups)
# 9
4. Upload the data to OpenAI
Ensure you have set your OpenAI API key by following these instructions, then upload the training file. An audit is performed to ensure data compliance, so you may have to wait a few minutes for the dataset to become ready for use.
import time
import json
import io

import openai

my_file = io.BytesIO()
for group in message_groups:
my_file.write((json.dumps({"messages": group}) + "\n").encode('utf-8'))

my_file.seek(0)
training_file = openai.File.create(
file=my_file,
purpose='fine-tune'
)


# Wait while the file is processed
status = openai.File.retrieve(training_file.id).status
start_time = time.time()
while status != "processed":
print(f"Status=[{status}]... {time.time() - start_time:.2f}s", end="\r", flush=True)
time.sleep(5)
status = openai.File.retrieve(training_file.id).status
print(f"File {training_file.id} ready after {time.time() - start_time:.2f} seconds.")
Once this is done, you can proceed to the model training!
5. Fine-tune the model
Start the fine-tuning job with your chosen base model.
job = openai.FineTuningJob.create(
training_file=training_file.id,
model="gpt-3.5-turbo",
)
This might take a while. Check the status with openai.FineTuningJob.retrieve(job.id).status and wait for it to report succeeded.
# It may take 10-20+ minutes to complete training.
status = openai.FineTuningJob.retrieve(job.id).status
start_time = time.time()
while status != "succeeded":
print(f"Status=[{status}]... {time.time() - start_time:.2f}s", end="\r", flush=True)
time.sleep(5)
job = openai.FineTuningJob.retrieve(job.id)
status = job.status
6. Use the model in LangChain
You're almost there! Use the fine-tuned model in LangChain.
from langchain import chat_models

model_name = job.fine_tuned_model
# Example: ft:gpt-3.5-turbo-0613:personal::5mty86jblapsed
model = chat_models.ChatOpenAI(model=model_name)
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser

prompt = ChatPromptTemplate.from_messages(
[
("human", "{input}"),
]
)

chain = prompt | model | StrOutputParser()

for tok in chain.stream({"input": "What classes are you taking?"}):
print(tok, end="", flush=True)


# The usual - Potions, Transfiguration, Defense Against the Dark Arts. What about you?
And that's it! You've successfully fine-tuned a model and used it in LangChain.
Supported Chat Loaders
LangChain currently supports the following chat loaders. Feel free to contribute more!
📄 Discord
This notebook shows how to create your own chat loader that works on copy-pasted messages (from dms) to a list of LangChain messages.
📄 Facebook Messenger
This notebook shows how to load data from Facebook in a format you can finetune on. The overall steps are:
📄 GMail
This loader goes over how to load data from GMail. There are many ways you could want to load data from GMail. This loader is currently fairly opionated in how to do so. The way it does it is it first looks for all messages that you have sent. It then looks for messages where you are responding to a previous email. It then fetches that previous email, and creates a training example of that email, followed by your email.
📄 iMessage
This notebook shows how to use the iMessage chat loader. This class helps convert iMessage conversations to LangChain chat messages.
📄 Slack
This notebook shows how to use the Slack chat loader. This class helps map exported slack conversations to LangChain chat messages.
📄 Telegram
This notebook shows how to use the Telegram chat loader. This class helps map exported Telegram conversations to LangChain chat messages.
📄 Twitter (via Apify)
This notebook shows how to load chat messages from Twitter to finetune on. We do this by utilizing Apify.
📄 WhatsApp
This notebook shows how to use the WhatsApp chat loader. This class helps map exported Telegram conversations to LangChain chat messages.


📄 OpenAI Functions Metadata Tagger
It can often be useful to tag ingested documents with structured metadata, such as the title, tone, or length of a document, to allow for more targeted similarity search later. However, for large numbers of documents, performing this labelling process manually can be tedious.


📄 Amazon Textract
Amazon Textract is a machine learning (ML) service that automatically extracts text, handwriting, and data from scanned documents. It goes beyond simple optical character recognition (OCR) to identify, understand, and extract data from forms and tables. Today, many companies manually extract data from scanned documents such as PDFs, images, tables, and forms, or through simple OCR software that requires manual configuration (which often must be updated when the form changes). To overcome these manual and expensive processes, Textract uses ML to read and process any type of document, accurately extracting text, handwriting, tables, and other data with no manual effort. You can quickly automate document processing and act on the information extracted, whether you’re automating loans processing or extracting information from invoices and receipts. Textract can extract the data in minutes instead of hours or days.


📄 Cassandra Chat Message History
Apache Cassandra® is a NoSQL, row-oriented, highly scalable and highly available database, well suited for storing large amounts of data.


📄 NLP Cloud
The NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, blog post generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.


Retrievers
📄 Amazon Kendra
Amazon Kendra is an intelligent search service provided by Amazon Web Services (AWS). It utilizes advanced natural language processing (NLP) and machine learning algorithms to enable powerful search capabilities across various data sources within an organization. Kendra is designed to help users find the information they need quickly and accurately, improving productivity and decision-making.
📄 Arxiv
arXiv 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.
📄 Azure Cognitive Search
Azure 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.
📄 BM25
BM25 also known as the Okapi BM25, is a ranking function used in information retrieval systems to estimate the relevance of documents to a given search query.
📄 Chaindesk
Chaindesk platform brings data from anywhere (Datsources: Text, PDF, Word, PowerPpoint, Excel, Notion, Airtable, Google Sheets, etc..) into Datastores (container of multiple Datasources).
📄 ChatGPT Plugin
OpenAI plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT's capabilities and allowing it to perform a wide range of actions.
📄 Cohere Reranker
Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.
📄 DocArray Retriever
DocArray is a versatile, open-source tool for managing your multi-modal data. It lets you shape your data however you want, and offers the flexibility to store and search it using various document index backends. Plus, it gets even better - you can utilize your DocArray document index to create a DocArrayRetriever, and build awesome Langchain apps!
📄 ElasticSearch BM25
Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.


📄 Google Cloud Enterprise Search
Enterprise Search is a part of the Generative AI App Builder suite of tools offered by Google Cloud.
📄 Google Drive Retriever
This notebook covers how to retrieve documents from Google Drive.
📄 kNN
In statistics, the k-nearest neighbors algorithm (k-NN) is a non-parametric supervised learning method first developed by Evelyn Fix and Joseph Hodges in 1951, and later expanded by Thomas Cover. It is used for classification and regression.
📄 LOTR (Merger Retriever)
Lord of the Retrievers, also known as MergerRetriever, takes a list of retrievers as input and merges the results of their getrelevantdocuments() methods into a single list. The merged results will be a list of documents that are relevant to the query and that have been ranked by the different retrievers.
📄 Metal
Metal is a managed service for ML Embeddings.
📄 Pinecone Hybrid Search
Pinecone is a vector database with broad functionality.
📄 PubMed
PubMed® by The National Center for Biotechnology Information, National Library of Medicine comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web sites.
📄 RePhraseQueryRetriever
Simple retriever that applies an LLM between the user input and the query pass the to retriever.
📄 SVM
Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection.
📄 TF-IDF
TF-IDF means term-frequency times inverse document-frequency.
📄 Vespa
Vespa 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.
📄 Weaviate Hybrid Search
Weaviate is an open source vector database.
📄 Wikipedia
Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWiki. Wikipedia is the largest and most-read reference work in history.


📄 Zep
Retriever Example for Zep - A long-term memory store for LLM applications.


Text embedding models
📄 AwaEmbedding
This notebook explains how to use AwaEmbedding, which is included in awadb, to embedding texts in langchain.
📄 Aleph Alpha
There are two possible ways to use Aleph Alpha's semantic embeddings. If you have texts with a dissimilar structure (e.g. a Document and a Query) you would want to use asymmetric embeddings. Conversely, for texts with comparable structures, symmetric embeddings are the suggested approach.
📄 AzureOpenAI
Let's load the OpenAI Embedding class with environment variables set to indicate to use Azure endpoints.
📄 Bedrock Embeddings
📄 BGE Hugging Face Embeddings
This notebook shows how to use BGE Embeddings through Hugging Face
📄 Clarifai
Clarifai is an AI Platform that provides the full AI lifecycle ranging from data exploration, data labeling, model training, evaluation, and inference.
📄 Cohere
Let's load the Cohere Embedding class.
📄 DashScope
Let's load the DashScope Embedding class.
📄 DeepInfra
DeepInfra is a serverless inference as a service that provides access to a variety of LLMs and embeddings models. This notebook goes over how to use LangChain with DeepInfra for text embeddings.
📄 EDEN AI
Eden AI is revolutionizing the AI landscape by uniting the best AI providers, empowering users to unlock limitless possibilities and tap into the true potential of artificial intelligence. With an all-in-one comprehensive and hassle-free platform, it allows users to deploy AI features to production lightning fast, enabling effortless access to the full breadth of AI capabilities via a single API. (website//edenai.co/)
📄 Elasticsearch
Walkthrough of how to generate embeddings using a hosted embedding model in Elasticsearch
📄 Embaas
embaas is a fully managed NLP API service that offers features like embedding generation, document text extraction, document to embeddings and more. You can choose a variety of pre-trained models.
📄 ERNIE Embedding-V1
ERNIE Embedding-V1 is a text representation model based on Baidu Wenxin's large-scale model technology,
📄 Fake Embeddings


📄 Fake Embeddings
LangChain also provides a fake embedding class. You can use this to test your pipelines.
📄 Google Cloud Platform Vertex AI PaLM
Note: This is seperate from the Google PaLM integration, it exposes Vertex AI PaLM API on Google Cloud.
📄 GPT4All
GPT4All is a free-to-use, locally running, privacy-aware chatbot. There is no GPU or internet required. It features popular models and its own models such as GPT4All Falcon, Wizard, etc.
📄 Hugging Face Hub
Let's load the Hugging Face Embedding class.
📄 InstructEmbeddings
Let's load the HuggingFace instruct Embeddings class.
📄 Jina
Let's load the Jina Embedding class.
📄 Llama-cpp
This notebook goes over how to use Llama-cpp embeddings within LangChain
📄 LocalAI
Let's load the LocalAI Embedding class. In order to use the LocalAI Embedding class, you need to have the LocalAI service hosted somewhere and configure the embedding models. See the documentation at https//localai.io/features/embeddings/index.html.
📄 MiniMax
MiniMax offers an embeddings service.
📄 ModelScope
Let's load the ModelScope Embedding class.
📄 MosaicML embeddings
MosaicML offers a managed inference service. You can either use a variety of open source models, or deploy your own.
📄 NLP Cloud
NLP Cloud is an artificial intelligence platform that allows you to use the most advanced AI engines, and even train your own engines with your own data.
📄 OpenAI
Let's load the OpenAI Embedding class.
📄 SageMaker Endpoint Embeddings
Let's load the SageMaker Endpoints Embeddings class. The class can be used if you host, e.g. your own Hugging Face model on SageMaker.
📄 Self Hosted Embeddings
Let's load the SelfHostedEmbeddings, SelfHostedHuggingFaceEmbeddings, and SelfHostedHuggingFaceInstructEmbeddings classes.
📄 Sentence Transformers Embeddings


📄 Sentence Transformers Embeddings
SentenceTransformers embeddings are called using the HuggingFaceEmbeddings integration. We have also added an alias for SentenceTransformerEmbeddings for users who are more familiar with directly using that package.
📄 Spacy Embedding
Loading the Spacy embedding class to generate and query embeddings
📄 TensorflowHub
Let's load the TensorflowHub Embedding class.
📄 Xorbits inference (Xinference)
This notebook goes over how to use Xinference embeddings within LangChain


Agents & Toolkits
Agents and Toolkits are placed in the same directory because they are always used together.
📄 AINetwork
AI Network is a layer 1 blockchain designed to accommodate large-scale AI models, utilizing a decentralized GPU network powered by the $AIN token, enriching AI-driven NFTs (AINFTs).
📄 Airbyte Question Answering
This notebook shows how to do question answering over structured data, in this case using the AirbyteStripeLoader.
📄 Amadeus
This notebook walks you through connecting LangChain to the Amadeus travel information API
📄 Azure Cognitive Services
This toolkit is used to interact with the Azure Cognitive Services API to achieve some multimodal capabilities.
📄 CSV
This notebook shows how to use agents to interact with data in CSV format. It is mostly optimized for question answering.
📄 Document Comparison
This notebook shows how to use an agent to compare two documents.
📄 Github
The Github toolkit contains tools that enable an LLM agent to interact with a github repository.
📄 Gmail
This notebook walks through connecting a LangChain email to the Gmail API.
📄 Google Drive tool
This notebook walks through connecting a LangChain to the Google Drive API.
📄 Jira
This notebook goes over how to use the Jira toolkit.
📄 JSON
This notebook showcases an agent interacting with large JSON/dict objects.
📄 MultiOn
This notebook walks you through connecting LangChain to the MultiOn Client in your browser
📄 Office365
This notebook walks through connecting LangChain to Office365 email and calendar.
📄 OpenAPI
We can construct agents to consume arbitrary APIs, here APIs conformant to the OpenAPI/Swagger specification.
📄 Natural Language APIs
Natural Language API Toolkits (NLAToolkits) permit LangChain Agents to efficiently plan and combine calls across endpoints.
📄 Pandas Dataframe
This notebook shows how to use agents to interact with a Pandas DataFrame. It is mostly optimized for question answering.
📄 PlayWright Browser


📄 PlayWright Browser
This toolkit is used to interact with the browser. While other tools (like the Requests tools) are fine for static sites, PlayWright Browser toolkits let your agent navigate the web and interact with dynamically rendered sites.
📄 PowerBI Dataset
This notebook showcases an agent interacting with a Power BI Dataset. The agent is answering more general questions about a dataset, as well as recover from errors.
📄 Python
This notebook showcases an agent designed to write and execute Python code to answer a question.
📄 Spark Dataframe
This notebook shows how to use agents to interact with a Spark DataFrame and Spark Connect. It is mostly optimized for question answering.
📄 Spark SQL
This notebook shows how to use agents to interact with Spark SQL. Similar to SQL Database Agent, it is designed to address general inquiries about Spark SQL and facilitate error recovery.
📄 SQL Database
This notebook showcases an agent designed to interact with a SQL databases.
📄 Vectorstore
This notebook showcases an agent designed to retrieve information from one or more vectorstores, either with or without sources.
📄 Xorbits
This notebook shows how to use agents to interact with Xorbits Pandas dataframe and Xorbits Numpy ndarray. It is mostly optimized for question answering.


Tools
📄 Alpha Vantage
Alpha Vantage Alpha Vantage provides realtime and historical financial market data through a set of powerful and developer-friendly data APIs and spreadsheets.
📄 Apify
This notebook shows how to use the Apify integration for LangChain.
📄 ArXiv
This notebook goes over how to use the arxiv tool with an agent.
📄 AWS Lambda
Amazon AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS). It helps developers to build and run applications and services without provisioning or managing servers. This serverless architecture enables you to focus on writing and deploying code, while AWS automatically takes care of scaling, patching, and managing the infrastructure required to run your applications.
📄 Shell (bash)
Giving agents access to the shell is powerful (though risky outside a sandboxed environment).
📄 Bing Search
This notebook goes over how to use the bing search component.
📄 Brave Search
This notebook goes over how to use the Brave Search tool.
📄 ChatGPT Plugins
This example shows how to use ChatGPT Plugins within LangChain abstractions.
📄 Dall-E Image Generator
This notebook shows how you can generate images from a prompt synthesized using an OpenAI LLM. The images are generated using Dall-E, which uses the same OpenAI API key as the LLM.
📄 DataForSeo
This notebook demonstrates how to use the DataForSeo API to obtain search engine results. The DataForSeo API retrieves SERP from most popular search engines like Google, Bing, Yahoo. It also allows to get SERPs from different search engine types like Maps, News, Events, etc.
📄 DuckDuckGo Search
This notebook goes over how to use the duck-duck-go search component.
📄 Eden AI
This Jupyter Notebook demonstrates how to use Eden AI tools with an Agent.
📄 File System
LangChain provides tools for interacting with a local file system out of the box. This notebook walks through some of them.
📄 Golden Query


📄 Golden Query
Golden 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 structured data about relevant entities.
📄 Google Drive
This notebook walks through connecting a LangChain to the Google Drive API.
📄 Google Places
This notebook goes through how to use Google Places API
📄 Google Search
This notebook goes over how to use the google search component.
📄 Google Serper
This notebook goes over how to use the Google Serper component to search the web. First you need to sign up for a free account at serper.dev and get your api key.
📄 Gradio
There are many 1000s of Gradio apps on Hugging Face Spaces. This library puts them at the tips of your LLM's fingers 🦾
📄 GraphQL
GraphQL is a query language for APIs and a runtime for executing those queries against your data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
📄 HuggingFace Hub Tools
Huggingface Tools that supporting text I/O can be
📄 Human as a tool
Human are AGI so they can certainly be used as a tool to help out AI agent
📄 IFTTT WebHooks
This notebook shows how to use IFTTT Webhooks.
📄 Lemon Agent
Lemon Agent helps you build powerful AI assistants in minutes and automate workflows by allowing for accurate and reliable read and write operations in tools like Airtable, Hubspot, Discord, Notion, Slack and Github.
📄 Metaphor Search
Metaphor is a search engine fully designed to be used by LLMs. You can search and then get the contents for any page.
📄 Nuclia Understanding
Nuclia automatically indexes your unstructured data from any internal and external source, providing optimized search results and generative answers. It can handle video and audio transcription, image content extraction, and document parsing.
📄 OpenWeatherMap


📄 OpenWeatherMap
This notebook goes over how to use the OpenWeatherMap component to fetch weather information.
📄 PubMed
PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web sites.
📄 Requests
The web contains a lot of information that LLMs do not have access to. In order to easily let LLMs interact with that information, we provide a wrapper around the Python Requests module that takes in a URL and fetches data from that URL.
📄 SceneXplain
SceneXplain is an ImageCaptioning service accessible through the SceneXplain Tool.
📄 Search Tools
This notebook shows off usage of various search tools.
📄 SearxNG Search
This notebook goes over how to use a self hosted SearxNG search API to search the web.
📄 SerpAPI
This notebook goes over how to use the SerpAPI component to search the web.
📄 SQL Database Chain
This example demonstrates the use of the SQLDatabaseChain for answering questions over a SQL database.
📄 Twilio
This notebook goes over how to use the Twilio API wrapper to send a message through SMS or Twilio Messaging Channels.
📄 Wikipedia
Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWiki. Wikipedia is the largest and most-read reference work in history.
📄 Wolfram Alpha
This notebook goes over how to use the wolfram alpha component.
📄 Yahoo Finance News
This notebook goes over how to use the yahoofinancenews tool with an agent.
📄 YouTube
YouTube Search package searches YouTube videos avoiding using their heavily rate-limited API.
📄 Zapier Natural Language Actions
Zapier Natural Language Actions gives you access to the 5k+ apps, 20k+ actions on Zapier's platform through a natural language API interface.


Vector stores
📄 Activeloop Deep Lake
Activeloop Deep Lake as a Multi-Modal Vector Store that stores embeddings and their metadata including text, Jsons, images, audio, video, and more. It saves the data locally, in your cloud, or on Activeloop storage. It performs hybrid search including embeddings and their attributes.
📄 Alibaba Cloud OpenSearch
Alibaba Cloud Opensearch is a one-stop platform to develop intelligent search services. OpenSearch was built on the large-scale distributed search engine developed by Alibaba. OpenSearch serves more than 500 business cases in Alibaba Group and thousands of Alibaba Cloud customers. OpenSearch helps develop search services in different search scenarios, including e-commerce, O2O, multimedia, the content industry, communities and forums, and big data query in enterprises.
📄 AnalyticDB
AnalyticDB for PostgreSQL is a massively parallel processing (MPP) data warehousing service that is designed to analyze large volumes of data online.
📄 Annoy
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for points in space that are close to a given query point. It also creates large read-only file-based data structures that are mmapped into memory so that many processes may share the same data.
📄 Atlas
Atlas is a platform by Nomic made for interacting with both small and internet scale unstructured datasets. It enables anyone to visualize, search, and share massive datasets in their browser.
📄 AwaDB
AwaDB is an AI Native database for the search and storage of embedding vectors used by LLM Applications.
📄 Azure Cognitive Search
Azure 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.
📄 BagelDB
BagelDB (Open Vector Database for AI), is like GitHub for AI data.
📄 Cassandra
Apache Cassandra® is a NoSQL, row-oriented, highly scalable and highly available database.
📄 Chroma
Chroma is a AI-native open-source vector database focused on developer productivity and happiness. Chroma is licensed under Apache 2.0.
📄 ClickHouse


📄 ClickHouse
ClickHouse is the fastest and most resource efficient open-source database for real-time apps and analytics with full SQL support and a wide range of functions to assist users in writing analytical queries. Lately added data structures and distance search functions (like L2Distance) as well as approximate nearest neighbor search indexes enable ClickHouse to be used as a high performance and scalable vector database to store and search vectors with SQL.
📄 DashVector
DashVector is a fully-managed vectorDB service that supports high-dimension dense and sparse vectors, real-time insertion and filtered search. It is built to scale automatically and can adapt to different application requirements.
📄 Dingo
Dingo is a distributed multi-mode vector database, which combines the characteristics of data lakes and vector databases, and can store data of any type and size (Key-Value, PDF, audio, video, etc.). It has real-time low-latency processing capabilities to achieve rapid insight and response, and can efficiently conduct instant analysis and process multi-modal data.
📄 DocArray HnswSearch
DocArrayHnswSearch is a lightweight Document Index implementation provided by Docarray that runs fully locally and is best suited for small- to medium-sized datasets. It stores vectors on disk in hnswlib, and stores all other data in SQLite.
📄 DocArray InMemorySearch
DocArrayInMemorySearch is a document index provided by Docarray that stores documents in memory. It is a great starting point for small datasets, where you may not want to launch a database server.
📄 Elasticsearch
Elasticsearch is a distributed, RESTful search and analytics engine, capable of performing both vector and lexical search. It is built on top of the Apache Lucene library.
📄 Epsilla
Epsilla is an open-source vector database that leverages the advanced parallel graph traversal techniques for vector indexing. Epsilla is licensed under GPL-3.0.
📄 Faiss
Facebook AI Similarity Search (Faiss) is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. It also contains supporting code for evaluation and parameter tuning.
📄 Hologres


📄 Hologres
Hologres 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.
📄 LanceDB
LanceDB is an open-source database for vector-search built with persistent storage, which greatly simplifies retrevial, filtering and management of embeddings. Fully open source.
📄 Marqo
This notebook shows how to use functionality related to the Marqo vectorstore.
📄 Google Vertex AI MatchingEngine
This notebook shows how to use functionality related to the GCP Vertex AI MatchingEngine vector database.
📄 Meilisearch
Meilisearch is an open-source, lightning-fast, and hyper relevant search engine. It comes with great defaults to help developers build snappy search experiences.
📄 Milvus
Milvus is a database that stores, indexes, and manages massive embedding vectors generated by deep neural networks and other machine learning (ML) models.
📄 MongoDB Atlas
MongoDB Atlas is a fully-managed cloud database available in AWS, Azure, and GCP. It now has support for native Vector Search on your MongoDB document data.
📄 MyScale
MyScale is a cloud-based database optimized for AI applications and solutions, built on the open-source ClickHouse.
📄 Neo4j Vector Index
Neo4j is an open-source graph database with integrated support for vector similarity search
📄 OpenSearch
OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. OpenSearch is a distributed search and analytics engine based on Apache Lucene.
📄 Postgres Embedding
Postgres Embedding is an open-source vector similarity search for Postgres that uses Hierarchical Navigable Small Worlds (HNSW) for approximate nearest neighbor search.
📄 PGVector
PGVector is an open-source vector similarity search for Postgres
📄 Pinecone
Pinecone is a vector database with broad functionality.
📄 Qdrant


Pinecone is a vector database with broad functionality.
📄 Qdrant
Qdrant (read: quadrant ) is a vector similarity search engine. It provides a production-ready service with a convenient API to store, search, and manage points - vectors with an additional payload. Qdrant is tailored to extended filtering support. It makes it useful for all sorts of neural network or semantic-based matching, faceted search, and other applications.
📄 Redis
Redis vector database introduction and langchain integration guide.
📄 Rockset
Rockset is a real-time search and analytics database built for the cloud. Rockset uses a Converged Index™ with an efficient store for vector embeddings to serve low latency, high concurrency search queries at scale. Rockset has full support for metadata filtering and handles real-time ingestion for constantly updating, streaming data.
📄 ScaNN
ScaNN (Scalable Nearest Neighbors) is a method for efficient vector similarity search at scale.
📄 SingleStoreDB
SingleStoreDB is a high-performance distributed SQL database that supports deployment both in the cloud and on-premises. It provides vector storage, and vector functions including dotproduct and euclideandistance, thereby supporting AI applications that require text similarity matching.
📄 scikit-learn
scikit-learn is an open source collection of machine learning algorithms, including some implementations of the k nearest neighbors. SKLearnVectorStore wraps this implementation and adds the possibility to persist the vector store in json, bson (binary json) or Apache Parquet format.
📄 StarRocks
StarRocks is a High-Performance Analytical Database.
📄 Supabase (Postgres)
Supabase is an open source Firebase alternative. Supabase is built on top of PostgreSQL, which offers strong SQL querying capabilities and enables a simple interface with already-existing tools and frameworks.
📄 Tair
Tair is a cloud native in-memory database service developed by Alibaba Cloud.
📄 Tencent Cloud VectorDB


📄 Tencent Cloud VectorDB
Tencent Cloud VectorDB is a fully managed, self-developed, enterprise-level distributed database service designed for storing, retrieving, and analyzing multi-dimensional vector data. The database supports multiple index types and similarity calculation methods. A single index can support a vector scale of up to 1 billion and can support millions of QPS and millisecond-level query latency. Tencent Cloud Vector Database can not only provide an external knowledge base for large models to improve the accuracy of large model responses but can also be widely used in AI fields such as recommendation systems, NLP services, computer vision, and intelligent customer service.
📄 Tigris
Tigris is an open source Serverless NoSQL Database and Search Platform designed to simplify building high-performance vector search applications.
📄 Typesense
Typesense is an open source, in-memory search engine, that you can either self-host or run on Typesense Cloud.
📄 USearch
USearch is a Smaller & Faster Single-File Vector Search Engine
📄 Vectara
Vectara is a API platform for building GenAI applications. It provides an easy-to-use API for document indexing and querying that is managed by Vectara and is optimized for performance and accuracy.
📄 Weaviate
Weaviate is an open-source vector database. It allows you to store data objects and vector embeddings from your favorite ML-models, and scale seamlessly into billions of data objects.
📄 Xata
Xata is a serverless data platform, based on PostgreSQL. It provides a Python SDK for interacting with your database, and a UI for managing your data.
📄 Zep
Zep is an open source long-term memory store for LLM applications. Zep makes it easy to add relevant documents,
📄 Zilliz
Zilliz Cloud is a fully managed service on cloud for LF AI Milvus®,


Grouped by provider
📄 Activeloop Deep Lake
This page covers how to use the Deep Lake ecosystem within LangChain.
📄 AI21 Labs
This page covers how to use the AI21 ecosystem within LangChain.
📄 Aim
Aim makes it super easy to visualize and debug LangChain executions. Aim tracks inputs and outputs of LLMs and tools, as well as actions of agents.
📄 AINetwork
AI Network is a layer 1 blockchain designed to accommodate
📄 Airbyte
Airbyte is a data integration platform for ELT pipelines from APIs,
📄 Airtable
Airtable is a cloud collaboration service.
📄 Aleph Alpha
Aleph Alpha was founded in 2019 with the mission to research and build the foundational technology for an era of strong AI. The team of international scientists, engineers, and innovators researches, develops, and deploys transformative AI like large language and multimodal models and runs the fastest European commercial AI cluster.
📄 Alibaba Cloud Opensearch
Alibaba Cloud Opensearch OpenSearch is a one-stop platform to develop intelligent search services. OpenSearch was built based on the large-scale distributed search engine developed by Alibaba. OpenSearch serves more than 500 business cases in Alibaba Group and thousands of Alibaba Cloud customers. OpenSearch helps develop search services in different search scenarios, including e-commerce, O2O, multimedia, the content industry, communities and forums, and big data query in enterprises.
📄 Amazon API Gateway
Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the "front door" for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.
📄 AnalyticDB
This page covers how to use the AnalyticDB ecosystem within LangChain.
📄 Annoy


📄 Annoy
Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for points in space that are close to a given query point. It also creates large read-only file-based data structures that are mmapped into memory so that many processes may share the same data.
📄 Anyscale
This page covers how to use the Anyscale ecosystem within LangChain.
📄 Apify
This page covers how to use Apify within LangChain.
📄 ArangoDB
ArangoDB 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.
📄 Argilla
Argilla - Open-source data platform for LLMs
📄 Arthur
Arthur is a model monitoring and observability platform.
📄 Arxiv
arXiv is an open-access archive for 2 million scholarly articles in the fields of physics,
📄 Atlas
Nomic Atlas is a platform for interacting with both
📄 AwaDB
AwaDB is an AI Native database for the search and storage of embedding vectors used by LLM Applications.
📄 AWS S3 Directory
Amazon Simple Storage Service (Amazon S3) is an object storage service.
📄 AZLyrics
AZLyrics is a large, legal, every day growing collection of lyrics.
📄 Azure Blob Storage
Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob Storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that doesn't adhere to a particular data model or definition, such as text or binary data.
📄 Azure Cognitive Search
Azure 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.
📄 Azure OpenAI


📄 Azure OpenAI
Microsoft 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.
📄 BagelDB
BagelDB (Open Vector Database for AI), is like GitHub for AI data.
📄 Banana
This page covers how to use the Banana ecosystem within LangChain.
📄 Baseten
Learn how to use LangChain with models deployed on Baseten.
📄 Beam
This page covers how to use Beam within LangChain.
📄 Bedrock
Amazon Bedrock is a fully managed service that makes FMs from leading AI startups and Amazon available via an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case.
📄 BiliBili
Bilibili is one of the most beloved long-form video sites in China.
📄 NIBittensor
This page covers how to use the BittensorLLM inference runtime within LangChain.
📄 Blackboard
Blackboard Learn (previously the Blackboard Learning Management System)
📄 Brave Search
Brave Search is a search engine developed by Brave Software.
📄 Cassandra
Apache Cassandra® is a free and open-source, distributed, wide-column
📄 CerebriumAI
This page covers how to use the CerebriumAI ecosystem within LangChain.
📄 Chaindesk
Chaindesk is an open source document retrieval platform that helps to connect your personal data with Large Language Models.
📄 Chroma
Chroma is a database for building AI applications with embeddings.
📄 Clarifai


📄 Clarifai
Clarifai is one of first deep learning platforms having been founded in 2013. Clarifai provides an AI platform with the full AI lifecycle for data exploration, data labeling, model training, evaluation and inference around images, video, text and audio data. In the LangChain ecosystem, as far as we're aware, Clarifai is the only provider that supports LLMs, embeddings and a vector store in one production scale platform, making it an excellent choice to operationalize your LangChain implementations.
📄 ClearML
ClearML is a ML/DL development and production suite, it contains 5 main modules:
📄 ClickHouse
ClickHouse is the fast and resource efficient open-source database for real-time
📄 CnosDB
CnosDB is an open source distributed time series database with high performance, high compression rate and high ease of use.
📄 Cohere
Cohere is a Canadian startup that provides natural language processing models
📄 College Confidential
College Confidential gives information on 3,800+ colleges and universities.
📄 Comet
In this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with Comet.
📄 Confluence
Confluence is a wiki collaboration platform that saves and organizes all of the project-related material. Confluence is a knowledge base that primarily handles content management activities.
📄 C Transformers
This page covers how to use the C Transformers library within LangChain.
📄 DashVector
DashVector is a fully-managed vectorDB service that supports high-dimension dense and sparse vectors, real-time insertion and filtered search. It is built to scale automatically and can adapt to different application requirements.
📄 Databricks
This notebook covers how to connect to the Databricks runtimes and Databricks SQL using the SQLDatabase wrapper of LangChain.
📄 Datadog Tracing
ddtrace is a Datadog application performance monitoring (APM) library which provides an integration to monitor your LangChain application.
📄 Datadog Logs
Datadog is a monitoring and analytics platform for cloud-scale applications.
📄 DataForSEO


📄 DataForSEO
This page provides instructions on how to use the DataForSEO search APIs within LangChain.
📄 DeepInfra
This page covers how to use the DeepInfra ecosystem within LangChain.
📄 DeepSparse
This page covers how to use the DeepSparse inference runtime within LangChain.
📄 Diffbot
Diffbot is a service to read web pages. Unlike traditional web scraping tools,
📄 Dingo
This page covers how to use the Dingo ecosystem within LangChain.
📄 Discord
Discord is a VoIP and instant messaging social platform. Users have the ability to communicate
📄 DocArray
DocArray is a library for nested, unstructured, multimodal data in transit,
📄 Docugami
Docugami converts business documents into a Document XML Knowledge Graph, generating forests
📄 DuckDB
DuckDB is an in-process SQL OLAP database management system.
📄 Elasticsearch
Elasticsearch is a distributed, RESTful search and analytics engine.
📄 Epsilla
This page covers how to use Epsilla within LangChain.
📄 EverNote
EverNote is intended for archiving and creating notes in which photos, audio and saved web content can be embedded. Notes are stored in virtual "notebooks" and can be tagged, annotated, edited, searched, and exported.
📄 Facebook Chat
Messenger) is an American proprietary instant messaging app and
📄 Facebook Faiss
Facebook AI Similarity Search (Faiss)
📄 Figma
Figma is a collaborative web application for interface design.
📄 Fireworks
This page covers how to use the Fireworks models within Langchain.
📄 Flyte
Flyte is an open-source orchestrator that facilitates building production-grade data and ML pipelines.
📄 ForefrontAI
This page covers how to use the ForefrontAI ecosystem within LangChain.
📄 Git
Git 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.
📄 GitBook


📄 GitBook
GitBook is a modern documentation platform where teams can document everything from products to internal knowledge bases and APIs.
📄 Golden
Golden 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 structured data about relevant entities.
📄 Google BigQuery
Google BigQuery is a serverless and cost-effective enterprise data warehouse that works across clouds and scales with your data.
📄 Google Cloud Storage
Google Cloud Storage is a managed service for storing unstructured data.
📄 Google Drive
Google Drive is a file storage and synchronization service developed by Google.
📄 Google Search
This page covers how to use the Google Search API within LangChain.
📄 Google Serper
This page covers how to use the Serper Google Search API within LangChain. Serper is a low-cost Google Search API that can be used to add answer box, knowledge graph, and organic results data from Google Search.
📄 Google Vertex AI MatchingEngine
Google Vertex AI Matching Engine provides
📄 GooseAI
This page covers how to use the GooseAI ecosystem within LangChain.
📄 GPT4All
This 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.
📄 Graphsignal
This page covers how to use Graphsignal to trace and monitor LangChain. Graphsignal enables full visibility into your application. It provides latency breakdowns by chains and tools, exceptions with full context, data monitoring, compute/GPU utilization, OpenAI cost analytics, and more.
📄 Grobid
GROBID is a machine learning library for extracting, parsing, and re-structuring raw documents.
📄 Gutenberg
Project Gutenberg is an online library of free eBooks.
📄 Hacker News
Hacker News (sometimes abbreviated as HN) is a social news
📄 Hazy Research
This page covers how to use the Hazy Research ecosystem within LangChain.
📄 Helicone


📄 Helicone
This page covers how to use the Helicone ecosystem within LangChain.
📄 Hologres
Hologres 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.
📄 Hugging Face
This page covers how to use the Hugging Face ecosystem (including the Hugging Face Hub) within LangChain.
📄 iFixit
iFixit is the largest, open repair community on the web. The site contains nearly 100k
📄 IMSDb
IMSDb is the Internet Movie Script Database.
📄 Infino
Infino is an open-source observability platform that stores both metrics and application logs together.
📄 Jina
This page covers how to use the Jina ecosystem within LangChain.
📄 LanceDB
This page covers how to use LanceDB within LangChain.
📄 LangChain Decorators ✨
lanchchain decorators is a layer on the top of LangChain that provides syntactic sugar 🍭 for writing custom langchain prompts and chains
📄 Llama.cpp
This page covers how to use llama.cpp within LangChain.
📄 Log10
This page covers how to use the Log10 within LangChain.
📄 Marqo
This page covers how to use the Marqo ecosystem within LangChain.
📄 MediaWikiDump
MediaWiki XML Dumps contain the content of a wiki
📄 Meilisearch
Meilisearch is an open-source, lightning-fast, and hyper
📄 Metal
This page covers how to use Metal within LangChain.
📄 Microsoft OneDrive
Microsoft OneDrive (formerly SkyDrive) is a file-hosting service operated by Microsoft.
📄 Microsoft PowerPoint
Microsoft PowerPoint is a presentation program by Microsoft.
📄 Microsoft Word
Microsoft Word is a word processor developed by Microsoft.
📄 Milvus
This page covers how to use the Milvus ecosystem within LangChain.
📄 Minimax
Minimax is a Chinese startup that provides natural language processing models


📄 Minimax
Minimax is a Chinese startup that provides natural language processing models
📄 MLflow AI Gateway
The MLflow AI Gateway service is a powerful tool designed to streamline the usage and management of various large
📄 MLflow
MLflow is a versatile, expandable, open-source platform for managing workflows and artifacts across the machine learning lifecycle. It has built-in integrations with many popular ML libraries, but can be used with any library, algorithm, or deployment tool. It is designed to be extensible, so you can write plugins to support new workflows, libraries, and tools.
📄 Modal
This page covers how to use the Modal ecosystem to run LangChain custom LLMs.
📄 ModelScope
This page covers how to use the modelscope ecosystem within LangChain.
📄 Modern Treasury
Modern Treasury simplifies complex payment operations. It is a unified platform to power products and processes that move money.
📄 Momento
Momento Cache is the world's first truly serverless caching service. It provides instant elasticity, scale-to-zero
📄 MongoDB Atlas
MongoDB Atlas is a fully-managed cloud
📄 Motherduck
Motherduck is a managed DuckDB-in-the-cloud service.
📄 MyScale
This page covers how to use MyScale vector database within LangChain.
📄 Neo4j
This page covers how to use the Neo4j ecosystem within LangChain.
📄 NLPCloud
This page covers how to use the NLPCloud ecosystem within LangChain.
📄 Notion DB
Notion is a collaboration platform with modified Markdown support that integrates kanban
📄 Obsidian
Obsidian is a powerful and extensible knowledge base
📄 OpenAI
OpenAI is American artificial intelligence (AI) research laboratory
📄 OpenLLM
This page demonstrates how to use OpenLLM
📄 OpenSearch
This page covers how to use the OpenSearch ecosystem within LangChain.
📄 OpenWeatherMap
OpenWeatherMap provides all essential weather data for a specific location:
📄 Petals
This page covers how to use the Petals ecosystem within LangChain.
📄 Postgres Embedding


📄 Postgres Embedding
pgembedding is an open-source package for
📄 PGVector
This page covers how to use the Postgres PGVector ecosystem within LangChain
📄 Pinecone
This page covers how to use the Pinecone ecosystem within LangChain.
📄 PipelineAI
This page covers how to use the PipelineAI ecosystem within LangChain.
🗃 Portkey
1 items
📄 Predibase
Learn how to use LangChain with models on Predibase.
📄 Prediction Guard
This page covers how to use the Prediction Guard ecosystem within LangChain.
📄 PromptLayer
This page covers how to use PromptLayer within LangChain.
📄 Psychic
Psychic is a platform for integrating with SaaS tools like Notion, Zendesk,
📄 PubMed
PubMed® by The National Center for Biotechnology Information, National Library of Medicine
📄 Qdrant
This page covers how to use the Qdrant ecosystem within LangChain.
📄 Ray Serve
Ray Serve is a scalable model serving library for building online inference APIs. Serve is particularly well suited for system composition, enabling you to build a complex inference service consisting of multiple chains and business logic all in Python code.
📄 Rebuff
Rebuff is a self-hardening prompt injection detector.
📄 Reddit
Reddit is an American social news aggregation, content rating, and discussion website.
📄 Redis
This page covers how to use the Redis ecosystem within LangChain.
📄 Replicate
This page covers how to run models on Replicate within LangChain.
📄 Roam
ROAM is a note-taking tool for networked thought, designed to create a personal knowledge base.
📄 Rockset
Rockset is a real-time analytics database service for serving low latency, high concurrency analytical queries at scale. It builds a Converged Index™ on structured and semi-structured data with an efficient store for vector embeddings. Its support for running SQL on schemaless data makes it a perfect choice for running vector search with metadata filters.
📄 Runhouse
This page covers how to use the Runhouse ecosystem within LangChain.
📄 RWKV-4


📄 RWKV-4
This page covers how to use the RWKV-4 wrapper within LangChain.
📄 SageMaker Endpoint
Amazon SageMaker is a system that can build, train, and deploy machine learning (ML) models with fully managed infrastructure, tools, and workflows.
📄 SageMaker Tracking
This notebook shows how LangChain Callback can be used to log and track prompts and other LLM hyperparameters into SageMaker Experiments. Here, we use different scenarios to showcase the capability:
📄 ScaNN
Google ScaNN
📄 SearxNG Search API
This page covers how to use the SearxNG search API within LangChain.
📄 SerpAPI
This page covers how to use the SerpAPI search APIs within LangChain.
📄 Shale Protocol
Shale Protocol provides production-ready inference APIs for open LLMs. It's a Plug & Play API as it's hosted on a highly scalable GPU cloud infrastructure.
📄 SingleStoreDB
SingleStoreDB is a high-performance distributed SQL database that supports deployment both in the cloud and on-premises. It provides vector storage, and vector functions including dotproduct and euclideandistance, thereby supporting AI applications that require text similarity matching.
📄 scikit-learn
scikit-learn is an open source collection of machine learning algorithms,
📄 Slack
Slack is an instant messaging program.
📄 spaCy
spaCy is an open-source software library for advanced natural language processing, written in the programming languages Python and Cython.
📄 Spreedly
Spreedly is a service that allows you to securely store credit cards and use them to transact against any number of payment gateways and third party APIs. It does this by simultaneously providing a card tokenization/vault service as well as a gateway and receiver integration service. Payment methods tokenized by Spreedly are stored at Spreedly, allowing you to independently store a card and then pass that card to different end points based on your business requirements.
📄 StarRocks
StarRocks is a High-Performance Analytical Database.
📄 StochasticAI
This page covers how to use the StochasticAI ecosystem within LangChain.


This page covers how to use the StochasticAI ecosystem within LangChain.
📄 Stripe
Stripe is an Irish-American financial services and software as a service (SaaS) company. It offers payment-processing software and application programming interfaces for e-commerce websites and mobile applications.
📄 Supabase (Postgres)
Supabase is an open source Firebase alternative.
📄 Nebula
This page covers how to use Nebula, Symbl.ai's LLM, ecosystem within LangChain.
📄 Tair
This page covers how to use the Tair ecosystem within LangChain.
📄 Telegram
Telegram Messenger is a globally accessible freemium, cross-platform, encrypted, cloud-based and centralized instant messaging service. The application also provides optional end-to-end encrypted chats and video calling, VoIP, file sharing and several other features.
📄 TencentVectorDB
This page covers how to use the TencentVectorDB ecosystem within LangChain.
📄 TensorFlow Datasets
TensorFlow Datasets is a collection of datasets ready to use,
📄 Tigris
Tigris is an open source Serverless NoSQL Database and Search Platform designed to simplify building high-performance vector search applications.
📄 2Markdown
2markdown service transforms website content into structured markdown files.
📄 Trello
Trello is a web-based project management and collaboration tool that allows individuals and teams to organize and track their tasks and projects. It provides a visual interface known as a "board" where users can create lists and cards to represent their tasks and activities.
📄 TruLens
This page covers how to use TruLens to evaluate and track LLM apps built on langchain.
📄 Twitter
Twitter is an online social media and social networking service.
📄 Typesense
Typesense is an open source, in-memory search engine, that you can either
📄 Unstructured
The unstructured package from
📄 USearch
USearch is a Smaller & Faster Single-File Vector Search Engine.
🗃 Vectara
2 items
📄 Vespa
Vespa is a fully featured search engine and vector database.
📄 WandB Tracing


📄 WandB Tracing
There are two recommended ways to trace your LangChains:
📄 Weights & Biases
This notebook goes over how to track your LangChain experiments into one centralized Weights and Biases dashboard. To learn more about prompt engineering and the callback please refer to this Report which explains both alongside the resultant dashboards you can expect to see.
📄 Weather
OpenWeatherMap is an open source weather service provider.
📄 Weaviate
This page covers how to use the Weaviate ecosystem within LangChain.
📄 WhatsApp
WhatsApp (also called WhatsApp Messenger) is a freeware, cross-platform, centralized instant messaging (IM) and voice-over-IP (VoIP) service. It allows users to send text and voice messages, make voice and video calls, and share images, documents, user locations, and other content.
📄 WhyLabs
WhyLabs is an observability platform designed to monitor data pipelines and ML applications for data quality regressions, data drift, and model performance degradation. Built on top of an open-source package called whylogs, the platform enables Data Scientists and Engineers to:
📄 Wikipedia
Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWiki. Wikipedia is the largest and most-read reference work in history.
📄 Wolfram Alpha
WolframAlpha is an answer engine developed by Wolfram Research.
📄 Writer
This page covers how to use the Writer ecosystem within LangChain.
📄 Xata
Xata is a serverless data platform, based on PostgreSQL.
📄 Xorbits Inference (Xinference)
This page demonstrates how to use Xinference
📄 Yeager.ai
This page covers how to use Yeager.ai to generate LangChain tools and agents.
📄 YouTube
YouTube is an online video sharing and social media platform by Google.
📄 Zep
Zep - A long-term memory store for LLM applications.
📄 Zilliz
Zilliz Cloud is a fully managed service on cloud for LF AI Milvus®,


Anthropic
This notebook covers how to get started with Anthropic chat models.
from langchain.chat_models import ChatAnthropic
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
AIMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import AIMessage, HumanMessage, SystemMessage
API Reference:
ChatAnthropic
ChatPromptTemplate
SystemMessagePromptTemplate
AIMessagePromptTemplate
HumanMessagePromptTemplate
AIMessage
HumanMessage
SystemMessage
messages = [
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
chat(messages)
AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)
ChatAnthropic also supports async and streaming functionality:
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
await chat.agenerate([messages])
LLMResult(generations=[[ChatGeneration(text=" J'aime programmer.", generation_info=None, message=AIMessage(content=" J'aime programmer.", additional_kwargs={}, example=False))]], llm_output={}, run=[RunInfo(run_id=UUID('8cc8fb68-1c35-439c-96a0-695036a93652'))])
chat = ChatAnthropic(
streaming=True,
verbose=True,
callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),
)
chat(messages)
J'aime la programmation.

AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)


This notebook demonstrates the use of langchain.chat_models.ChatAnyscale for Anyscale Endpoints.
This way, the three requests will only take as long as the longest individual request.
meta-llama/Llama-2-70b-chat-hf

Greetings! I'm just an AI, I don't have a personal identity like humans do, but I'm here to help you with any questions you have.

I'm a large language model, which means I'm trained on a large corpus of text data to generate language outputs that are coherent and natural-sounding. My architecture is based on a transformer model, which is a type of neural network that's particularly well-suited for natural language processing tasks.

As for my parameters, I have a few billion parameters, but I don't have access to the exact number as it's not relevant to my functioning. My training data includes a vast amount of text from various sources, including books, articles, and websites, which I use to learn patterns and relationships in language.

I'm designed to be a helpful tool for a variety of tasks, such as answering questions, providing information, and generating text. I'm constantly learning and improving my abilities through machine learning algorithms and feedback from users like you.

I hope this helps! Is there anything else you'd like to know about me or my capabilities?

---

meta-llama/Llama-2-7b-chat-hf


---

meta-llama/Llama-2-7b-chat-hf

Ah, a fellow tech enthusiast! *adjusts glasses* I'm glad to share some technical details about myself. 🤓
Indeed, I'm a transformer model, specifically a BERT-like language model trained on a large corpus of text data. My architecture is based on the transformer framework, which is a type of neural network designed for natural language processing tasks. 🏠
As for the number of parameters, I have approximately 340 million. *winks* That's a pretty hefty number, if I do say so myself! These parameters allow me to learn and represent complex patterns in language, such as syntax, semantics, and more. 🤔
But don't ask me to do math in my head – I'm a language model, not a calculating machine! 😅 My strengths lie in understanding and generating human-like text, so feel free to chat with me anytime you'd like. 💬
Now, do you have any more technical questions for me? Or would you like to engage in a nice chat? 😊

---

meta-llama/Llama-2-13b-chat-hf

Hello! As a friendly and helpful AI, I'd be happy to share some technical facts about myself.

I am a transformer-based language model, specifically a variant of the BERT (Bidirectional Encoder Representations from Transformers) architecture. BERT was developed by Google in 2018 and has since become one of the most popular and widely-used AI language models.

Here are some technical details about my capabilities:


Here are some technical details about my capabilities:

1. Parameters: I have approximately 340 million parameters, which are the numbers that I use to learn and represent language. This is a relatively large number of parameters compared to some other languages models, but it allows me to learn and understand complex language patterns and relationships.
2. Training: I was trained on a large corpus of text data, including books, articles, and other sources of written content. This training allows me to learn about the structure and conventions of language, as well as the relationships between words and phrases.
3. Architectures: My architecture is based on the transformer model, which is a type of neural network that is particularly well-suited for natural language processing tasks. The transformer model uses self-attention mechanisms to allow the model to "attend" to different parts of the input text, allowing it to capture long-range dependencies and contextual relationships.
4. Precision: I am capable of generating text with high precision and accuracy, meaning that I can produce text that is close to human-level quality in terms of grammar, syntax, and coherence.
5. Generative capabilities: In addition to being able to generate text based on prompts and questions, I am also capable of generating text based on a given topic or theme. This allows me to create longer, more coherent pieces of text that are organized around a specific idea or concept.

Overall, I am a powerful and versatile language model that is capable of a wide range of natural language processing tasks. I am constantly learning and improving, and I am here to help answer any questions you may have!

---

CPU times: user 371 ms, sys: 15.5 ms, total: 387 ms
Wall time: 12 s


Anthropic Functions
This notebook shows how to use an experimental wrapper around Anthropic that gives it the same API as OpenAI Functions.
from langchain_experimental.llms.anthropic_functions import AnthropicFunctions
/Users/harrisonchase/.pyenv/versions/3.9.1/envs/langchain/lib/python3.9/site-packages/deeplake/util/check_latest_version.py:32: UserWarning: A newer version of deeplake (3.6.14) is available. It's recommended that you update to the latest version using `pip install -U deeplake`.
warnings.warn(
Initialize Model
You can initialize this wrapper the same way you'd initialize ChatAnthropic
model = AnthropicFunctions(model='claude-2')
Passing in functions
You can now pass in functions in a similar way
functions=[
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
]
from langchain.schema import HumanMessage
response = model.predict_messages(
[HumanMessage(content="whats the weater in boston?")],
functions=functions
)
AIMessage(content=' ', additional_kwargs={'function_call': {'name': 'get_current_weather', 'arguments': '{"location": "Boston, MA", "unit": "fahrenheit"}'}}, example=False)
You can now use this for extraction.
from langchain.chains import create_extraction_chain
schema = {
"properties": {
"name": {"type": "string"},
"height": {"type": "integer"},
"hair_color": {"type": "string"},
},
"required": ["name", "height"],
}
inp = """
Alex is 5 feet tall. Claudia is 1 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
"""
chain = create_extraction_chain(schema, model)


"""
chain = create_extraction_chain(schema, model)
[{'name': 'Alex', 'height': '5', 'hair_color': 'blonde'},
{'name': 'Claudia', 'height': '6', 'hair_color': 'brunette'}]
Using for tagging
You can now use this for tagging
from langchain.chains import create_tagging_chain
schema = {
"properties": {
"sentiment": {"type": "string"},
"aggressiveness": {"type": "integer"},
"language": {"type": "string"},
}
}
chain = create_tagging_chain(schema, model)
chain.run("this is really cool")
{'sentiment': 'positive', 'aggressiveness': '0', 'language': 'english'}


Azure
This notebook goes over how to connect to an Azure hosted OpenAI endpoint
from langchain.chat_models import AzureChatOpenAI
from langchain.schema import HumanMessage
BASE_URL = "https://${TODO}.openai.azure.com"
API_KEY = "..."
DEPLOYMENT_NAME = "chat"
model = AzureChatOpenAI(
openai_api_base=BASE_URL,
openai_api_version="2023-05-15",
deployment_name=DEPLOYMENT_NAME,
openai_api_key=API_KEY,
openai_api_type="azure",
)
model(
[
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
)
AIMessage(content="\n\nJ'aime programmer.", additional_kwargs={})
Model Version
Azure OpenAI responses contain model property, which is name of the model used to generate the response. However unlike native OpenAI responses, it does not contain the version of the model, which is set on the deplyoment in Azure. This makes it tricky to know which version of the model was used to generate the response, which as result can lead to e.g. wrong total cost calculation with OpenAICallbackHandler.
To solve this problem, you can pass model_version parameter to AzureChatOpenAI class, which will be added to the model name in the llm output. This way you can easily distinguish between different versions of the model.
from langchain.callbacks import get_openai_callback
BASE_URL = "https://{endpoint}.openai.azure.com"
API_KEY = "..."
DEPLOYMENT_NAME = "gpt-35-turbo" # in Azure, this deployment has version 0613 - input and output tokens are counted separately
model = AzureChatOpenAI(
openai_api_base=BASE_URL,
openai_api_version="2023-05-15",
deployment_name=DEPLOYMENT_NAME,
openai_api_key=API_KEY,
openai_api_type="azure",
)
with get_openai_callback() as cb:
model(
[
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
)


)
]
)
print(f"Total Cost (USD): ${format(cb.total_cost, '.6f')}") # without specifying the model version, flat-rate 0.002 USD per 1k input and output tokens is used
Total Cost (USD): $0.000054
We can provide the model version to AzureChatOpenAI constructor. It will get appended to the model name returned by Azure OpenAI and cost will be counted correctly.
model0613 = AzureChatOpenAI(
openai_api_base=BASE_URL,
openai_api_version="2023-05-15",
deployment_name=DEPLOYMENT_NAME,
openai_api_key=API_KEY,
openai_api_type="azure",
model_version="0613"
)
with get_openai_callback() as cb:
model0613(
[
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
)
print(f"Total Cost (USD): ${format(cb.total_cost, '.6f')}")
Total Cost (USD): $0.000044


AzureML is a platform used to build, train, and deploy machine learning models. Users can explore the types of models to deploy in the Model Catalog, which provides Azure Foundation Models and OpenAI Models. Azure Foundation Models include various open-source models and popular Hugging Face models. Users can also import models of their liking into AzureML.
This notebook goes over how to use a chat model hosted on an AzureML online endpoint
The content_formatter parameter is a handler class for transforming the request and response of an AzureML endpoint to match with required schema. Since there are a wide range of models in the model catalog, each of which may process data differently from one another, a ContentFormatterBase class is provided to allow users to transform data to their liking. The following content formatters are provided:
AIMessage(content=' The Collatz Conjecture is one of the most famous unsolved problems in mathematics, and it has been the subject of much study and research for many years. While it is impossible to predict with certainty whether the conjecture will ever be solved, there are several reasons why it is considered a challenging and important problem:\n\n1. Simple yet elusive: The Collatz Conjecture is a deceptively simple statement that has proven to be extraordinarily difficult to prove or disprove. Despite its simplicity, the conjecture has eluded some of the brightest minds in mathematics, and it remains one of the most famous open problems in the field.\n2. Wide-ranging implications: The Collatz Conjecture has far-reaching implications for many areas of mathematics, including number theory, algebra, and analysis. A solution to the conjecture could have significant impacts on these fields and potentially lead to new insights and discoveries.\n3. Computational evidence: While the conjecture remains unproven, extensive computational evidence supports its validity. In fact, no counterexample to the conjecture has been found for any starting value up to 2^64 (a number', additional_kwargs={}, example=False)


Bedrock Chat
Amazon Bedrock is a fully managed service that makes FMs from leading AI startups and Amazon available via an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case
from langchain.chat_models import BedrockChat
from langchain.schema import HumanMessage
chat = BedrockChat(model_id="anthropic.claude-v2", model_kwargs={"temperature":0.1})
messages = [
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
chat(messages)
AIMessage(content=" Voici la traduction en français : J'adore programmer.", additional_kwargs={}, example=False)


ERNIE-Bot Chat
ERNIE-Bot is a large language model developed by Baidu, covering a huge amount of Chinese data. This notebook covers how to get started with ErnieBot chat models.
from langchain.chat_models import ErnieBotChat
from langchain.schema import HumanMessage
chat = ErnieBotChat(ernie_client_id='YOUR_CLIENT_ID', ernie_client_secret='YOUR_CLIENT_SECRET')
or you can set client_id and client_secret in your environment variables
export ERNIE_CLIENT_ID=YOUR_CLIENT_ID
export ERNIE_CLIENT_SECRET=YOUR_CLIENT_SECRET
chat([
HumanMessage(content='hello there, who are you?')
])
AIMessage(content='Hello, I am an artificial intelligence language model. My purpose is to help users answer questions or provide information. What can I do for you?', additional_kwargs={}, example=False)


Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there.
By default, Google Cloud does not use Customer Data to train its foundation models as part of Google Cloud`s AI/ML Privacy Commitment. More details about how Google processes data can also be found in Google's Customer Data Processing Addendum (CDPA).
To use Vertex AI PaLM you must have the google-cloud-aiplatform Python package installed and either:
Have credentials configured for your environment (gcloud, workload identity, etc...)
Store the path to a service account JSON file as the GOOGLE_APPLICATION_CREDENTIALS environment variable
This codebase uses the google.auth library which first looks for the application credentials variable mentioned above, and then looks for system-level auth.
For more information, see:
https://cloud.google.com/docs/authentication/application-default-credentials#GAC
https://googleapis.dev/python/google-auth/latest/reference/google.auth.html#module-google.auth
#!pip install google-cloud-aiplatform
from langchain.chat_models import ChatVertexAI
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import HumanMessage, SystemMessage
messages = [
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(
content="Translate this sentence from English to French. I love programming."
),
]
chat(messages)
AIMessage(content='Sure, here is the translation of the sentence "I love programming" from English to French:\n\nJ\'aime programmer.', additional_kwargs={}, example=False)
You can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate's format_prompt -- this returns a PromptValue, which you can convert to a string or Message object, depending on whether you want to use the formatted value as input to an llm or chat model.
For convenience, there is a from_template method exposed on the template. If you were to use this template, this is what it would look like:
template = (
"You are a helpful assistant that translates {input_language} to {output_language}."
)


"You are a helpful assistant that translates {input_language} to {output_language}."
)
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages(
[system_message_prompt, human_message_prompt]
)


# get a chat completion from the formatted messages
chat(
chat_prompt.format_prompt(
input_language="English", output_language="French", text="I love programming."
).to_messages()
)
AIMessage(content='Sure, here is the translation of "I love programming" in French:\n\nJ\'aime programmer.', additional_kwargs={}, example=False)
You can now leverage the Codey API for code chat within Vertex AI. The model name is:
codechat-bison: for code assistance
chat = ChatVertexAI(model_name="codechat-bison")
messages = [
HumanMessage(
content="How do I create a python function to identify all prime numbers?"
)
]
chat(messages)
AIMessage(content='The following Python function can be used to identify all prime numbers up to a given integer:\n\n```\ndef is_prime(n):\n """\n Determines whether the given integer is prime.\n\n Args:\n n: The integer to be tested for primality.\n\n Returns:\n True if n is prime, False otherwise.\n """\n\n # Check if n is divisible by 2.\n if n % 2 == 0:\n return False\n\n # Check if n is divisible by any integer from 3 to the square root', additional_kwargs={}, example=False)


JinaChat
This notebook covers how to get started with JinaChat chat models.
from langchain.chat_models import JinaChat
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
AIMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import AIMessage, HumanMessage, SystemMessage
API Reference:
JinaChat
ChatPromptTemplate
SystemMessagePromptTemplate
AIMessagePromptTemplate
HumanMessagePromptTemplate
AIMessage
HumanMessage
SystemMessage
chat = JinaChat(temperature=0)
messages = [
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(
content="Translate this sentence from English to French. I love programming."
),
]
chat(messages)
AIMessage(content="J'aime programmer.", additional_kwargs={}, example=False)
You can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate's format_prompt -- this returns a PromptValue, which you can convert to a string or Message object, depending on whether you want to use the formatted value as input to an llm or chat model.
For convenience, there is a from_template method exposed on the template. If you were to use this template, this is what it would look like:
template = (
"You are a helpful assistant that translates {input_language} to {output_language}."
)
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages(
[system_message_prompt, human_message_prompt]
)

# get a chat completion from the formatted messages
chat(
chat_prompt.format_prompt(
input_language="English", output_language="French", text="I love programming."
).to_messages()
)
AIMessage(content="J'aime programmer.", additional_kwargs={}, example=False)


🚅 LiteLLM
LiteLLM is a library that simplifies calling Anthropic, Azure, Huggingface, Replicate, etc.
This notebook covers how to get started with using Langchain + the LiteLLM I/O library.
from langchain.chat_models import ChatLiteLLM
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
AIMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import AIMessage, HumanMessage, SystemMessage
API Reference:
ChatLiteLLM
ChatPromptTemplate
SystemMessagePromptTemplate
AIMessagePromptTemplate
HumanMessagePromptTemplate
AIMessage
HumanMessage
SystemMessage
chat = ChatLiteLLM(model="gpt-3.5-turbo")
messages = [
HumanMessage(
content="Translate this sentence from English to French. I love programming."
)
]
chat(messages)
AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)
ChatLiteLLM also supports async and streaming functionality:
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
await chat.agenerate([messages])
LLMResult(generations=[[ChatGeneration(text=" J'aime programmer.", generation_info=None, message=AIMessage(content=" J'aime programmer.", additional_kwargs={}, example=False))]], llm_output={}, run=[RunInfo(run_id=UUID('8cc8fb68-1c35-439c-96a0-695036a93652'))])
chat = ChatLiteLLM(
streaming=True,
verbose=True,
callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),
)
chat(messages)
J'aime la programmation.

AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)


Llama API
This notebook shows how to use LangChain with LlamaAPI - a hosted version of Llama2 that adds in support for function calling.
!pip install -U llamaapi
from llamaapi import LlamaAPI

# Replace 'Your_API_Token' with your actual API token
llama = LlamaAPI('Your_API_Token')
from langchain_experimental.llms import ChatLlamaAPI
/Users/harrisonchase/.pyenv/versions/3.9.1/envs/langchain/lib/python3.9/site-packages/deeplake/util/check_latest_version.py:32: UserWarning: A newer version of deeplake (3.6.12) is available. It's recommended that you update to the latest version using `pip install -U deeplake`.
warnings.warn(
model = ChatLlamaAPI(client=llama)
from langchain.chains import create_tagging_chain

schema = {
"properties": {
"sentiment": {"type": "string", 'description': 'the sentiment encountered in the passage'},
"aggressiveness": {"type": "integer", 'description': 'a 0-10 score of how aggressive the passage is'},
"language": {"type": "string", 'description': 'the language of the passage'},
}
}

chain = create_tagging_chain(schema, model)
chain.run("give me your money")
{'sentiment': 'aggressive', 'aggressiveness': 8}


Ollama allows you to run open-source large language models, such as LLaMA2, locally.
Ollama bundles model weights, configuration, and data into a single package, defined by a Modelfile.
It optimizes setup and configuration details, including GPU usage.
For a complete list of supported models and model variants, see the Ollama model library.
If you are using a LLaMA chat model (e.g., ollama pull llama2:7b-chat) then you can use the ChatOllama interface.
With StreamingStdOutCallbackHandler, you will see tokens streamed.
Let's also use local embeddings from GPT4AllEmbeddings and Chroma.
You can also get logging for tokens.
Based on the given context, here is the answer to the question "What are the approaches to Task Decomposition?"

There are three approaches to task decomposition:


1. LLM with simple prompting, such as "Steps for XYZ." or "What are the subgoals for achieving XYZ?"
2. Using task-specific instructions, like "Write a story outline" for writing a novel.


3. With human inputs.{'model': 'llama2:13b-chat', 'created_at': '2023-08-23T15:37:51.469127Z', 'done': True, 'context': [1, 29871, 1, 29961, 25580, 29962, 518, 25580, 29962, 518, 25580, 29962, 3532, 14816, 29903, 6778, 4803, 278, 1494, 12785, 310, 3030, 304, 1234, 278, 1139, 472, 278, 1095, 29889, 29871, 13, 3644, 366, 1016, 29915, 29873, 1073, 278, 1234, 29892, 925, 1827, 393, 366, 1016, 29915, 29873, 1073, 29892, 1016, 29915, 29873, 1018, 304, 1207, 701, 385, 1234, 29889, 29871, 13, 11403, 2211, 25260, 7472, 322, 3013, 278, 1234, 408, 3022, 895, 408, 1950, 29889, 529, 829, 14816, 29903, 6778, 13, 5398, 26227, 508, 367, 2309, 313, 29896, 29897, 491, 365, 26369, 411, 2560, 9508, 292, 763, 376, 7789, 567, 363, 1060, 29979, 29999, 7790, 29876, 29896, 19602, 376, 5618, 526, 278, 1014, 1484, 1338, 363, 3657, 15387, 1060, 29979, 29999, 29973,


15387, 1060, 29979, 29999, 29973, 613, 313, 29906, 29897, 491, 773, 3414, 29899, 14940, 11994, 29936, 321, 29889, 29887, 29889, 376, 6113, 263, 5828, 27887, 1213, 363, 5007, 263, 9554, 29892, 470, 313, 29941, 29897, 411, 5199, 10970, 29889, 13, 13, 5398, 26227, 508, 367, 2309, 313, 29896, 29897, 491, 365, 26369, 411, 2560, 9508, 292, 763, 376, 7789, 567, 363, 1060, 29979, 29999, 7790, 29876, 29896, 19602, 376, 5618, 526, 278, 1014, 1484, 1338, 363, 3657, 15387, 1060, 29979, 29999, 29973, 613, 313, 29906, 29897, 491, 773, 3414, 29899, 14940, 11994, 29936, 321, 29889, 29887, 29889, 376, 6113, 263, 5828, 27887, 1213, 363, 5007, 263, 9554, 29892, 470, 313, 29941, 29897, 411, 5199, 10970, 29889, 13, 13, 1451, 16047, 267, 297, 1472, 29899, 8489, 18987, 322, 3414, 26227, 29901, 1858, 9450, 975, 263, 3309, 29891, 4955,


975, 263, 3309, 29891, 4955, 322, 17583, 3902, 8253, 278, 1650, 2913, 3933, 18066, 292, 29889, 365, 26369, 29879, 21117, 304, 10365, 13900, 746, 20050, 411, 15668, 4436, 29892, 3907, 963, 3109, 16424, 9401, 304, 25618, 1058, 5110, 515, 14260, 322, 1059, 29889, 13, 13, 1451, 16047, 267, 297, 1472, 29899, 8489, 18987, 322, 3414, 26227, 29901, 1858, 9450, 975, 263, 3309, 29891, 4955, 322, 17583, 3902, 8253, 278, 1650, 2913, 3933, 18066, 292, 29889, 365, 26369, 29879, 21117, 304, 10365, 13900, 746, 20050, 411, 15668, 4436, 29892, 3907, 963, 3109, 16424, 9401, 304, 25618, 1058, 5110, 515, 14260, 322, 1059, 29889, 13, 16492, 29901, 1724, 526, 278, 13501, 304, 9330, 897, 510, 3283, 29973, 13, 29648, 1319, 673, 10834, 29914, 25580, 29962, 518, 29914, 25580, 29962, 518, 29914, 25580, 29962, 29871, 16564, 373, 278,


29962, 29871, 16564, 373, 278, 2183, 3030, 29892, 1244, 338, 278, 1234, 304, 278, 1139, 376, 5618, 526, 278, 13501, 304, 9330, 897, 510, 3283, 3026, 13, 13, 8439, 526, 2211, 13501, 304, 3414, 26227, 29901, 13, 13, 29896, 29889, 365, 26369, 411, 2560, 9508, 292, 29892, 1316, 408, 376, 7789, 567, 363, 1060, 29979, 29999, 1213, 470, 376, 5618, 526, 278, 1014, 1484, 1338, 363, 3657, 15387, 1060, 29979, 29999, 3026, 13, 29906, 29889, 5293, 3414, 29899, 14940, 11994, 29892, 763, 376, 6113, 263, 5828, 27887, 29908, 363, 5007, 263, 9554, 29889, 13, 29941, 29889, 2973, 5199, 10970, 29889, 2], 'total_duration': 9514823750, 'load_duration': 795542, 'sample_count': 99, 'sample_duration': 68732000, 'prompt_eval_count': 146, 'prompt_eval_duration': 6206275000, 'eval_count': 98, 'eval_duration': 3229641000}


PromptLayer ChatOpenAI
This example showcases how to connect to PromptLayer to start recording your ChatOpenAI requests.
Install PromptLayer
The promptlayer package is required to use PromptLayer with OpenAI. Install promptlayer using pip.
Imports
import os
from langchain.chat_models import PromptLayerChatOpenAI
from langchain.schema import HumanMessage
Set the Environment API Key
You can create a PromptLayer API Key at www.promptlayer.com by clicking the settings cog in the navbar.
Set it as an environment variable called PROMPTLAYER_API_KEY.
os.environ["PROMPTLAYER_API_KEY"] = "**********"
Use the PromptLayerOpenAI LLM like normal
You can optionally pass in pl_tags to track your requests with PromptLayer's tagging feature.
chat = PromptLayerChatOpenAI(pl_tags=["langchain"])
chat([HumanMessage(content="I am a cat and I want")])
AIMessage(content='to take a nap in a cozy spot. I search around for a suitable place and finally settle on a soft cushion on the window sill. I curl up into a ball and close my eyes, relishing the warmth of the sun on my fur. As I drift off to sleep, I can hear the birds chirping outside and feel the gentle breeze blowing through the window. This is the life of a contented cat.', additional_kwargs={})
The above request should now appear on your PromptLayer dashboard.
Using PromptLayer Track
If you would like to use any of the PromptLayer tracking features, you need to pass the argument return_pl_id when instantializing the PromptLayer LLM to get the request id.
chat = PromptLayerChatOpenAI(return_pl_id=True)
chat_results = chat.generate([[HumanMessage(content="I am a cat and I want")]])

for res in chat_results.generations:
pl_request_id = res[0].generation_info["pl_request_id"]
promptlayer.track.score(request_id=pl_request_id, score=100)
Using this allows you to track the performance of your model in the PromptLayer dashboard. If you are using a prompt template, you can attach a template to a request as well. Overall, this gives you the opportunity to track the performance of different templates and models in the PromptLayer dashboard.


OpenAI
This notebook covers how to get started with OpenAI chat models.
from langchain.chat_models import ChatOpenAI
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
AIMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import AIMessage, HumanMessage, SystemMessage
API Reference:
ChatOpenAI
ChatPromptTemplate
SystemMessagePromptTemplate
AIMessagePromptTemplate
HumanMessagePromptTemplate
AIMessage
HumanMessage
SystemMessage
chat = ChatOpenAI(temperature=0)
The above cell assumes that your OpenAI API key is set in your environment variables. If you would rather manually specify your API key and/or organization ID, use the following code:
chat = ChatOpenAI(temperature=0, openai_api_key="YOUR_API_KEY", openai_organization="YOUR_ORGANIZATION_ID")
Remove the openai_organization parameter should it not apply to you.
messages = [
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(
content="Translate this sentence from English to French. I love programming."
),
]
chat(messages)
AIMessage(content="J'adore la programmation.", additional_kwargs={}, example=False)
You can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate's format_prompt -- this returns a PromptValue, which you can convert to a string or Message object, depending on whether you want to use the formatted value as input to an llm or chat model.
For convenience, there is a from_template method exposed on the template. If you were to use this template, this is what it would look like:
template = (
"You are a helpful assistant that translates {input_language} to {output_language}."
)
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages(
[system_message_prompt, human_message_prompt]
)


# get a chat completion from the formatted messages
chat(
chat_prompt.format_prompt(
input_language="English", output_language="French", text="I love programming."
).to_messages()
)
AIMessage(content="J'adore la programmation.", additional_kwargs={}, example=False)
Fine-tuning
You can call fine-tuned OpenAI models by passing in your corresponding modelName parameter.
This generally takes the form of ft:{OPENAI_MODEL_NAME}:{ORG_NAME}::{MODEL_ID}. For example:
fine_tuned_model = ChatOpenAI(temperature=0, model_name="ft:gpt-3.5-turbo-0613:langchain::7qTVM5AR")

fine_tuned_model(messages)
AIMessage(content="J'adore la programmation.", additional_kwargs={}, example=False)


Streamlit
Streamlit is a faster way to build and share data apps. Streamlit turns data scripts into shareable web apps in minutes. All in pure Python. No front‑end experience required. See more examples at streamlit.io/generative-ai.
In this guide we will demonstrate how to use StreamlitCallbackHandler to display the thoughts and actions of an agent in an interactive Streamlit app. Try it out with the running app below using the MRKL agent:
Installation and Setup
pip install langchain streamlit
You can run streamlit hello to load a sample app and validate your install succeeded. See full instructions in Streamlit's Getting started documentation.
Display thoughts and actions
To create a StreamlitCallbackHandler, you just need to provide a parent container to render the output.
from langchain.callbacks import StreamlitCallbackHandler
import streamlit as st

st_callback = StreamlitCallbackHandler(st.container())
Additional keyword arguments to customize the display behavior are described in the API reference.
Scenario 1: Using an Agent with Tools
The primary supported use case today is visualizing the actions of an Agent with Tools (or Agent Executor). You can create an agent in your Streamlit app and simply pass the StreamlitCallbackHandler to agent.run() in order to visualize the thoughts and actions live in your app.
from langchain.llms import OpenAI
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain.callbacks import StreamlitCallbackHandler
import streamlit as st

llm = OpenAI(temperature=0, streaming=True)
tools = load_tools(["ddg-search"])
agent = initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)


if prompt := st.chat_input():
st.chat_message("user").write(prompt)
with st.chat_message("assistant"):
st_callback = StreamlitCallbackHandler(st.container())
response = agent.run(prompt, callbacks=[st_callback])
st.write(response)
Note: You will need to set OPENAI_API_KEY for the above app code to run successfully. The easiest way to do this is via Streamlit secrets.toml, or any other local ENV management tool.
Additional scenarios
Currently StreamlitCallbackHandler is geared towards use with a LangChain Agent Executor. Support for additional agent types, use directly with Chains, etc will be added in the future.
You may also be interested in using StreamlitChatMessageHistory for LangChain.


Argilla
Argilla is an open-source data curation platform for LLMs. Using Argilla, everyone can build robust language models through faster data curation using both human and machine feedback. We provide support for each step in the MLOps cycle, from data labeling to model monitoring.
In this guide we will demonstrate how to track the inputs and reponses of your LLM to generate a dataset in Argilla, using the ArgillaCallbackHandler.
It's useful to keep track of the inputs and outputs of your LLMs to generate datasets for future fine-tuning. This is especially useful when you're using a LLM to generate data for a specific task, such as question answering, summarization, or translation.
Installation and Setup
pip install argilla --upgrade
pip install openai
Getting API Credentials
To get the Argilla API credentials, follow the next steps:
Go to your Argilla UI.
Click on your profile picture and go to "My settings".
Then copy the API Key.
In Argilla the API URL will be the same as the URL of your Argilla UI.
To get the OpenAI API credentials, please visit https://platform.openai.com/account/api-keys
import os

os.environ["ARGILLA_API_URL"] = "..."
os.environ["ARGILLA_API_KEY"] = "..."

os.environ["OPENAI_API_KEY"] = "..."
Setup Argilla
To use the ArgillaCallbackHandler we will need to create a new FeedbackDataset in Argilla to keep track of your LLM experiments. To do so, please use the following code:
from packaging.version import parse as parse_version


if parse_version(rg.__version__) < parse_version("1.8.0"):
raise RuntimeError(
"`FeedbackDataset` is only available in Argilla v1.8.0 or higher, please "
"upgrade `argilla` as `pip install argilla --upgrade`."
)
dataset = rg.FeedbackDataset(
fields=[
rg.TextField(name="prompt"),
rg.TextField(name="response"),
],
questions=[
rg.RatingQuestion(
name="response-rating",
description="How would you rate the quality of the response?",
values=[1, 2, 3, 4, 5],
required=True,
),
rg.TextQuestion(
name="response-feedback",
description="What feedback do you have for the response?",
required=False,
),
],
guidelines="You're asked to rate the quality of the response and provide feedback.",
)

rg.init(
api_url=os.environ["ARGILLA_API_URL"],
api_key=os.environ["ARGILLA_API_KEY"],
)

dataset.push_to_argilla("langchain-dataset");
📌 NOTE: at the moment, just the prompt-response pairs are supported as FeedbackDataset.fields, so the ArgillaCallbackHandler will just track the prompt i.e. the LLM input, and the response i.e. the LLM output.
Tracking
To use the ArgillaCallbackHandler you can either use the following code, or just reproduce one of the examples presented in the following sections.
from langchain.callbacks import ArgillaCallbackHandler

argilla_callback = ArgillaCallbackHandler(
dataset_name="langchain-dataset",
api_url=os.environ["ARGILLA_API_URL"],
api_key=os.environ["ARGILLA_API_KEY"],
)
Scenario 1: Tracking an LLM
First, let's just run a single LLM a few times and capture the resulting prompt-response pairs in Argilla.
from langchain.callbacks import ArgillaCallbackHandler, StdOutCallbackHandler
from langchain.llms import OpenAI

argilla_callback = ArgillaCallbackHandler(
dataset_name="langchain-dataset",
api_url=os.environ["ARGILLA_API_URL"],
api_key=os.environ["ARGILLA_API_KEY"],
)
callbacks = [StdOutCallbackHandler(), argilla_callback]


llm = OpenAI(temperature=0.9, callbacks=callbacks)
llm.generate(["Tell me a joke", "Tell me a poem"] * 3)