This project is a Retrieval-Augmented Generation (RAG) system that allows users to retrieve Pokémon information using natural language queries. It combines FastAPI, Pinecone, and an LLM (Llama-3) to intelligently fetch Pokémon data.
- Fetches Pokémon data from PokeAPI and stores it in a CSV file.
- Embeds Pokémon data into Pinecone for vector search.
- Uses an LLM (Llama-3-70B) to enhance responses.
- Provides a FastAPI server for queries.
- Includes a chat-style frontend for easy interaction.
git clone https://github.com/KushPatel-18/Pokemon-RAG.git
cd pokemon-ragEnsure you're working in a virtual environment to keep dependencies isolated.
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtIf you don't have a requirements.txt file, install the dependencies manually:
pip install fastapi uvicorn pinecone-client pandas python-dotenv transformers torch together tqdm requestsYou must create a .env file in the root directory with the following keys:
PINECONE_API_KEY=your_pinecone_api_key_here
TOGETHER_API_KEY=your_together_ai_api_key_here- Pinecone API Key → Sign up at Pinecone and create an index.
- Together AI API Key → Sign up at Together AI and get a free key.
Before running the application, you need to fetch Pokémon data and store it in a CSV file.
python data_downloader.pyThis will create a pokemon_data.csv file containing all the Pokémon details.
Once the data is downloaded, you need to upload it to Pinecone for vector search.
python data_utils.py✅ This will process the CSV and store embeddings in Pinecone.
To enable searching via API, run the FastAPI server:
uvicorn app:app --reloadThe server will start at http://127.0.0.1:8000
Open a browser or use curl to test the API:
http://127.0.0.1:8000/search/?query=What is the height of Charizard?Expected JSON response:
{
"results": "The height is 17."
}To test the chatbot frontend:
- Open
web.htmlin a browser. - Ensure the backend URL in the JavaScript points to your FastAPI server:
fetch(`http://127.0.0.1:8000/search/?query=${encodeURIComponent(userText)}`)- Ask a question! The chatbot will return Pokémon-related responses.
| Step | Command |
|---|---|
| Install dependencies | pip install -r requirements.txt |
| Fetch Pokémon data | python data_downloader.py |
| Upload data to Pinecone | python data_utils.py |
| Start FastAPI server | uvicorn app:app --reload |
| Test API | http://127.0.0.1:8000/search/?query=Pikachu |
| Run frontend | Open web.html in a browser |
-
Push your code to GitHub:
git add . git commit -m "Initial commit" git push origin main
-
Go to Render.com → Click New Web Service.
-
Select your repo and set:
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn app:app --host 0.0.0.0 --port 8000
- Build Command:
-
Add environment variables (
PINECONE_API_KEY,TOGETHER_API_KEY). -
Click Deploy!
Your API will be available at:
https://{your-app-name}.onrender.com/search/?query=Charizard
fly launch
fly deploygcloud run deploy pokemon-rag --source .❌ Error: ModuleNotFoundError: No module named 'fastapi'
✅ Run: pip install fastapi uvicorn
❌ TypeError: Pinecone.create_index() missing 'spec'
✅ Update data_utils.py:
from pinecone import ServerlessSpec
pinecone.create_index(name, spec=ServerlessSpec(cloud="aws", region="us-east-1"))❌ Frontend Not Connecting?
✅ Make sure web.html is pointing to the correct backend URL.

