This is a sample app to demonstrate how to use the Pinecone Python SDK with asyncio support. This is a simple Next.js app with a FastAPI backend.
- A Pinecone account. Create your free account here if you don't already have one.
- A Pinecone API key by following these steps.
- Python 3.12 or higher.
- Node.js 20 or higher.
Create and activate a Python virtual environment:
python3 -m venv .venv
source .venv/bin/activatepip3 install -r requirements.txtIf you don't have both a dense index and a sparse index loaded with your own data, you can load test data using the load-data.py in the scripts directory. This will create two indexes:
- a dense index using NVIDIA's
llama-text-embed-v2, a state-of-the-art embedding model available natively in Pinecone Inference - a sparse index using Pinecone's own
pinecone-sparse-english-v0embedding model
Once the indexes are created, it will chunk and upsert data from the GEM/sportsett_basketball dataset on Huggingface, converting the text to vectors automatically using the hosted embedding model.
Set up your scripts environment variables by copying the .env.example file in the scripts directory to .env and replacing with your environment values.
From the scripts directory, run:
python3 load-data.pySet up your app environment variables by copying the .env.example file in the project root to .env and replacing with your environment values. You'll need to grab the index host URLs either from the Pinecone console or from the Pinecone API using describe_index as detailed here.
From the project root, run:
npm installFrom the project root, run:
npm run devHead over to http://localhost:3000 to view the app.
The FastAPI server will be running on http://127.0.0.1:8000.