A Retrieval-Augmented Generation (RAG) system designed specifically for laboratory management, providing AI-powered assistance for chemical inventory, safety information, and instrument procedures.
- 🔍 Smart Query Routing: Automatically classifies queries as location, safety, or procedure questions
- 📊 Multi-Source Search: Searches across chemical inventory, element storage, and instrument manuals
- 🛡️ Safety-First Design: Prioritizes safety information with proper H-phrases and P-phrases
- 📈 Confidence Scoring: Provides reliability scores for all responses
- 💻 Professional UI: Clean Streamlit interface suitable for lab environments
- 🔗 API Integration: Flask API for embeddings and reranking services
- Frontend: Streamlit web application
- Backend: Flask API with ChromaDB vector database
- LLM: Together.ai (Llama 3.2)
- Embeddings: Sentence Transformers (all-MPNet-base-v2)
- Vector Store: ChromaDB (Windows compatible)
- Clone the repository
git clone https://github.com/abbykabraham/lab-rag.git
cd lab-rag- Install dependencies
pip install -r requirements.txt- Set up environment variables
Create a
.envfile in the project root:
# Required
TOGETHER_API_KEY=your_together_ai_api_key_here
# Optional (defaults provided)
DEFAULT_MODEL=meta-llama/Llama-3.2-3B-Instruct-Turbo
EMBEDDING_MODEL=sentence-transformers/all-MPNet-base-v2
DATA_DIR=./data
LOG_LEVEL=INFO- Run the Streamlit app
streamlit run app/streamlit_app.py- Initialize the system using the sidebar controls
- Load your lab data using the data loading button
- Start asking questions!
- "Where is acetone stored?"
- "What safety precautions for hydrochloric acid?"
- "How to turn on the Keithley 2400?"
- "What PPE is needed for handling sodium?"
lab-rag/
├── src/lab_rag/ # Core RAG system
│ ├── utils.py # LLM and utility functions
│ ├── chroma_client.py # ChromaDB vector database client
│ ├── weaviate_client.py # Weaviate vector database client
│ ├── flask_app.py # API endpoints
│ ├── data_ingestion.py # Data processing pipeline
│ ├── retrieval.py # Main RAG orchestrator
│ └── config.py # Configuration management
├── app/ # User interface
│ └── streamlit_app.py # Main Streamlit app
├── data/ # Lab data files
│ ├── chemicals_inventory.csv
│ ├── elements_inventory.csv
│ ├── glove_box_list.csv
│ └── *.pdf # Instrument manuals
├── tests/ # Unit tests
└── requirements.txt # Dependencies
- Chemical Inventory: 32+ chemicals with storage locations and hazard information
- Element Inventory: 35+ elements with cabinet locations and safety data
- Glove Box Items: 34+ specialized chemicals in controlled environment
- Instrument Manuals: Comprehensive PDF manuals for lab equipment
Key environment variables:
TOGETHER_API_KEY: Together.ai API key (required)DEFAULT_MODEL: LLM model to use (default: meta-llama/Llama-3.2-3B-Instruct-Turbo)EMBEDDING_MODEL: Embedding model (default: sentence-transformers/all-MPNet-base-v2)DATA_DIR: Directory containing lab data files (default: ./data)
MIT License - see LICENSE file for details.