LLMRails
LLMRails is a API platform for building GenAI applications. It provides an easy-to-use API for document indexing and querying that is managed by LLMRails and is optimized for performance and accuracy. See the LLMRails API documentation for more information on how to use the API.
You'll need to install langchain-community
with pip install -qU langchain-community
to use this integration
This notebook shows how to use functionality related to the LLMRails
's integration with langchain.
Note that unlike many other integrations in this category, LLMRails provides an end-to-end managed service for retrieval augmented generation, which includes:
- A way to extract text from document files and chunk them into sentences.
- Its own embeddings model and vector store - each text segment is encoded into a vector embedding and stored in the LLMRails internal vector store
- A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments (including support for Hybrid Search)
All of these are supported in this LangChain integration.
Setup
You will need a LLMRails account to use LLMRails with LangChain. To get started, use the following steps:
- Sign up for a LLMRails account if you don't already have one.
- Next you'll need to create API keys to access the API. Click on the "API Keys" tab in the corpus view and then the "Create API Key" button. Give your key a name. Click "Create key" and you now have an active API key. Keep this key confidential.
To use LangChain with LLMRails, you'll need to have this value: api_key. You can provide those to LangChain in two ways:
- Include in your environment these two variables:
LLM_RAILS_API_KEY
,LLM_RAILS_DATASTORE_ID
.
For example, you can set these variables using os.environ and getpass as follows:
import os
import getpass
os.environ["LLM_RAILS_API_KEY"] = getpass.getpass("LLMRails API Key:")
os.environ["LLM_RAILS_DATASTORE_ID"] = getpass.getpass("LLMRails Datastore Id:")
- Provide them as arguments when creating the LLMRails vectorstore object:
vectorstore = LLMRails(
api_key=llm_rails_api_key,
datastore_id=datastore_id
)