A Retrieval-Augmented Generation (RAG) system for providing intelligent repair advice and assessments based on a large database of repair cases. The system uses OpenAI's GPT models for generation and Pinecone for efficient vector similarity search.
The system combines:
- OpenAI GPT Models for generating repair advice
- Pinecone Vector Database for efficient similarity search
- OpenRepair Dataset as the knowledge source
- Modern Web Interface for easy interaction
-
Clone & Install
git clone <repository-url> cd repair_rag pip install -r requirements.txt
-
Configure Environment Create a
.envfile in therepair_ragdirectory:# OpenAI Configuration OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-4o-mini-2024-07-18 EMBEDDING_MODEL=text-embedding-3-small # Pinecone Configuration PINECONE_API_KEY=your_pinecone_api_key_here PINECONE_ENVIRONMENT=gcp-starter PINECONE_INDEX=repair-kb PINECONE_NAMESPACE=repair-cases -
Start the API Server
cd repair_rag python run.py api -
Access the Web Interface
- Open
index.htmlin your browser - Start asking repair-related questions!
- Open
repair_rag/
├── app/ # Core application code
│ ├── main.py # FastAPI server
│ ├── rag_engine.py # RAG implementation
│ └── __init__.py # Package marker
├── data/ # Data storage
├── index.html # Main web interface
├── results.html # Results display
├── styles.css # UI styling
├── run.py # Application launcher
├── ingest_data_to_pinecone.py # Data ingestion
├── parts_url_generator.py # Parts URL utilities
└── requirements.txt # Python dependencies
- Intelligent Repair Analysis: Combines vector similarity search with GPT-powered analysis
- Comprehensive Advice:
- Repair feasibility assessment
- Cost-benefit analysis
- Required tools and parts
- Step-by-step guidance
- Multi-language Support: Automatically detects and responds in the user's language
- Similar Case Analysis: Shows relevant past repair cases
- Parts & Tools Links: Direct links to purchase necessary items
To add new repair cases to the existing database:
-
Prepare Your Data Create a JSON file with the following structure:
[ { "brand": "Device brand", "product_category": "Category of the device", "problem": "Description of the problem", "repair_status": "Fixed/Not Fixed/etc.", "repair_barrier": "Any barriers to repair", "year_of_manufacture": "Year", "country": "Country", "tools_required": ["Tool1", "Tool2"], "parts_needed": ["Part1", "Part2"], "estimated_cost": "Cost estimate", "repair_description": "Detailed repair description" }, // ... more cases ] -
Ingest to Pinecone
python ingest_data_to_pinecone.py --data-path your_data.json
Options:
--batch-size: Number of vectors to batch (default: 50)--embedding-model: OpenAI embedding model to use--index-name: Pinecone index name--namespace: Namespace within the index
-
API Key Errors
- Ensure both OpenAI and Pinecone API keys are in
.env - Check API key permissions and quotas
- Ensure both OpenAI and Pinecone API keys are in
-
Connection Issues
- Verify the API server is running (
python run.py api) - Check the port (8000) isn't in use
- Verify the API server is running (
-
No Results
- Ensure Pinecone index contains data
- Check query formatting and language
- OpenAI has rate limits for both embeddings and completions
- Pinecone has query per second (QPS) limits
- Use batch processing for large data ingestion
- Consider implementing caching for frequent queries
- Uses Pinecone for vector similarity search
- Dimension: 1536 (OpenAI text-embedding-3-small)
- Metric: Cosine similarity
- Namespace: Organizes different data sources
- Embeddings: text-embedding-3-small
- Generation: gpt-4o-mini-2024-07-18
- Temperature: 0.1 (for factual responses)
- Pure HTML/CSS/JavaScript
- No framework dependencies
- Responsive design
- Cross-browser compatible
-
OpenAI Costs:
- Embeddings: $0.02 per million tokens
- GPT-4 Completions: Varies by model and usage
-
Pinecone Costs:
- Free tier available
- Pricing based on vector count and QPS
- Built on OpenRepair Dataset
- Uses OpenAI's API
- Pinecone Vector Database
- [Add your license information]