https://github.com/aerospike/rag-aerospike
langchain rag template for aerospike
https://github.com/aerospike/rag-aerospike
aerospike langchain nosql rag
Last synced: 7 months ago
JSON representation
langchain rag template for aerospike
- Host: GitHub
- URL: https://github.com/aerospike/rag-aerospike
- Owner: aerospike
- License: mit
- Created: 2024-08-23T21:42:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-18T17:04:23.000Z (10 months ago)
- Last Synced: 2025-01-17T12:17:31.720Z (9 months ago)
- Topics: aerospike, langchain, nosql, rag
- Language: Python
- Homepage: https://github.com/aerospike/langchain/tree/master/templates
- Size: 22.5 KB
- Stars: 1
- Watchers: 42
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rag-aerospike
This template performs RAG using Aerospike Vector Search (AVS), HuggingFace embeddings, and an OpenAI LLM. The data set is the [AVS architecture overview]("https://aerospike.com/docs/vector/architecture/components") web page, which is loaded, tokenized, then embedded using the all-MiniLM-L6-v2 sentence transformer. The context and embeddings are stored in the Aerospike Vector Search LangChain vector store.
The chain exposed in this example shows basic usage of the Aerospike Vector Search LangChain vector store as a retriever for RAG applications.
## Environment Setup
Set the `OPENAI_API_KEY` environment variable to access the [OpenAI](https://platform.openai.com) models:
Set `AVS_HOST` (default: localhost) and `AVS_PORT` (default: 5000) to the address for your AVS deployment.
Set `AVS_NAMESPACE` (default: test) to the Aerospike namespace to store vector data and indexes in.
Set `DATASOURCE` (default: "https://aerospike.com/docs/vector/architecture/components") to the URL of a webpage you would like to index. The text from the page will be used as context in the RAG application.## Usage
To use this package, you should first have the LangChain CLI installed:
```shell
pip install -U langchain-cli
```Create a new LangChain project:
```shell
langchain app new my-app
```Change into your new project directory.
```
cd my-app
```Add the Aerospike RAG langchain template to your new project:
```shell
langchain app add --repo="aerospike/rag-aerospike/" --branch="main"
```And add the following code to your `server.py` file:
```python
from rag_aerospike import chain as rag_aerospike_chainadd_routes(app, rag_aerospike_chain, path="/rag-aerospike")
```(Optional) Let's now configure LangSmith.
LangSmith will help us trace, monitor and debug LangChain applications.
You can sign up for LangSmith [here](https://smith.langchain.com/).
If you don't have access, you can skip this section```shell
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=
export LANGCHAIN_PROJECT= # if not specified, defaults to "default"
```If you are inside the root directory of this repo, then you can spin up a LangServe instance directly by:
```shell
langchain serve
```This will start the FastAPI app with a server is running locally at
[http://localhost:8000](http://localhost:8000)We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
We can access the playground at [http://127.0.0.1:8000/rag-aerospike/playground](http://127.0.0.1:8000/rag-aerospike/playground)We can access the template from code with:
```python
from langserve.client import RemoteRunnablerunnable = RemoteRunnable("http://localhost:8000/rag-aerospike")
```