- A MongoDB Atlas Cluster
- An OpenAI API Key
- Python
Run the following commands to create your app based on rag-mongo template:
pip install langchain-cli
pip install openai
langchain app new <my-app-name> --package rag-mongo
export OPENAI_API_KEY=<my-openai-api-key>
export MONGO_URI=<my-mongodb-cs>
Add the route to your app:
from rag_mongo import chain as rag_mongo_chain
add_routes(app, rag_mongo_chain, path="/rag-mongo")
DB_NAME = "database-name"
COLLECTION_NAME = "collection-name"
ATLAS_VECTOR_SEARCH_INDEX_NAME = "vector-index-name"
EMBEDDING_FIELD_NAME = "embedding"
# PDF file to split location
FILE_URI = "https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4HkJP"
CHUNK_SIZE = 500
CHUNK_OVERLAP = 0
DB_NAME = "database-name"
COLLECTION_NAME = "collection-name"
ATLAS_VECTOR_SEARCH_INDEX_NAME = "vector-index-name"
SEARCH_K_VALUE = 100
POST_FILTER_PIPELINE_LIMIT = 1
OPENAI_MODEL_NAME = "gpt-3.5-turbo-16k-0613"
python3 ingest.py
{
"fields": [{
"path": "embedding",
"numDimensions": 1536,
"similarity": "cosine",
"type": "vector"
}]
}
Run LangServe at /app level
langchain serve
http://localhost:8000/rag-mongo/playground/