An intelligent assistant that uses Google's Gemini AI to provide accurate answers about Gita.
graph TD
A[Docs] --> B[Document Processor]
B --> C[Text Chunks]
C --> D[SentenceTransformer Embedding Model]
D --> E[FAISS Vector Store]
F[User Question] --> G[Question Embedding]
G --> H[Similarity Search]
E --> H
H --> I[Context Retrieval]
I --> J[Gemini Pro]
J --> K[Generated Answer]
# Build the image
docker build -t crustdata-assistant .
# Run the container
docker run -p 8000:8000 \
-e GEMINI_API_KEY=your_key_here \
crustdata-assistant
# Create virtual environment
python -m venv venv
# Activate virtual environment
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run the application
python main.py
project/
├── data/
│ ├── processed/
│ │ ├── faiss_index/ # Vector embeddings
│ │ └── chunks/ # Processed text chunks
│ └── raw/ # Raw documentation
├── src/
│ ├── core/ # Core processing logic
│ ├── api/ # API endpoints
│ ├── services/ # Gemini integration
│ └── utils/ # Helper functions
├── Dockerfile
├── requirements.txt
└── main.py
sequenceDiagram
participant D as Documentation
participant C as Chunker
participant E as Embedder
participant F as FAISS
participant U as User
participant G as Gemini
D->>C: Split into chunks
C->>E: Generate embeddings
E->>F: Store vectors
U->>E: Question
E->>F: Search similar docs
F->>G: Context + Question
G->>U: Generated Answer
- Splits documentation into manageable chunks
- Maintains document structure
- Processes markdown formatting
- Uses Gemini for generating embeddings
- Converts text chunks to vectors
- Optimizes for technical content
- Fast similarity search
- In-memory vector storage
- Efficient retrieval
- Context-aware answers
- Technical accuracy
- Natural language responses
POST /api/chat
Content-Type: application/json
{
"question": "Who is arjuna?",
"max_context": 3 # Optional: Number of relevant chunks to use
}
GET /health
GEMINI_API_KEY=
# Application Settings
APP_ENV="development"
DEBUG=True
PORT=8000
# Embedding Model Configuration
EMBEDDING_MODEL="all-mpnet-base-v2"
# Processing Configuration
CHUNK_SIZE=1000
CHUNK_OVERLAP=100
MAX_TOKENS=8192
FROM python:3.9-slim
COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY . .
RUN mkdir -p data/raw data/processed/faiss_index data/processed/chunks logs
CMD ["python", "main.py"]
- Embedding Generation: ~100ms per chunk
- Search Latency: ~50ms
- Response Generation: ~500ms
- Memory Usage: ~500MB base + ~100MB per 1000 chunks
Monitor system health:
curl http://localhost:8000/health
- Documents missing/corrupted
- Embedding generation failures
- Search index errors
- Response generation timeout
- Input sanitization
- Error message sanitization