A proof-of-concept application that demonstrates Retrieval-Augmented Generation (RAG) using Pinecone vector database and Claude AI. This version includes both a CLI and a web-based interface.
- Document ingestion into Pinecone vector database
- Interactive search interface (CLI and web)
- Semantic search using Pinecone sparse vectors
- Integration with Claude AI for generating answers
- Web-based UI for easier interaction
-
Clone this repository:
git clone https://github.com/anova-culinary/pinecone-claude-rag.git cd pinecone-claude-rag -
Install dependencies:
npm install -
Create a
.envfile with your API keys and configuration:cp env-example .envThen edit the
.envfile with your actual API keys and configuration values.
This project requires several environment variables to work properly. These are stored in a .env file in the root directory. For security reasons, this file is not included in the repository.
A sample env-example file is provided with placeholder values. You need to:
- Create your own
.envfile:cp env-example .env - Update the values in your
.envfile with your actual credentials:
# Pinecone Configuration
PINECONE_API_KEY= # Your Pinecone API key
PINECONE_INDEX_NAME= # Name of your Pinecone index
PINECONE_INDEX_HOST= # Host URL of your Pinecone index
PINECONE_NAMESPACE= # Optional namespace in your Pinecone index
PINECONE_EMBEDDING_MODEL= # The embedding model to use (default: sparse+sparse:hkunlp/instructor-base:thenlper/gte-small)
# Anthropic API Configuration
ANTHROPIC_API_KEY= # Your Anthropic API key for Claude
# Optional: Server Configuration (for web interface)
PORT=3000 # Port for the web server (default: 3000)
- Pinecone API Key: Sign up at Pinecone and create an API key from the dashboard.
- Anthropic API Key: Sign up for Anthropic's Claude API to get an API key.
To ingest PDF documents into the Pinecone vector database:
node ingest.js /path/to/your/document.pdf
To search the documents using the command-line interface:
node search.js
This will start an interactive search interface where you can:
- Enter your question
- View retrieved context from Pinecone
- Press Enter to generate an answer from Claude
- Choose to ask another question or exit
To use the web-based interface:
npm start
This will start the server and you can access the application at http://localhost:3000 (or the port you specified in your .env file).
With the web interface, you can:
- Enter your question in the text area
- Click the Search button (or press Enter)
- View retrieved context on the left side
- See Claude's generated answer on the right side
- Ask additional questions as needed
For development with automatic reloading:
npm run dev
-
Ingestion (ingest.js):
- Reads PDF documents
- Splits text into chunks
- Generates sparse embeddings via Pinecone API
- Stores embeddings and text in Pinecone
-
Search:
-
CLI (search.js):
- Takes user queries interactively via command line
- Generates sparse embeddings for the query
- Retrieves relevant document chunks from Pinecone
- Sends context and query to Claude
- Displays the AI-generated answer in the terminal
-
Web Interface (server.js, app.js):
- Provides a user-friendly web interface
- Handles queries through a REST API
- Server-side processing to keep API keys secure
- Displays both context and answers in a clean UI
-
- Node.js
- Pinecone account with API access
- Claude API access (via Anthropic)
- Modern web browser (for web interface)