Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧪 Lab-RAG Assistant

A Retrieval-Augmented Generation (RAG) system designed specifically for laboratory management, providing AI-powered assistance for chemical inventory, safety information, and instrument procedures.

✨ Features

  • 🔍 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

🏗️ Architecture

  • 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)

📦 Installation

  1. Clone the repository
git clone https://github.com/abbykabraham/lab-rag.git
cd lab-rag
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables Create a .env file 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

🚀 Quick Start

  1. Run the Streamlit app
streamlit run app/streamlit_app.py
  1. Initialize the system using the sidebar controls
  2. Load your lab data using the data loading button
  3. Start asking questions!

Example Queries

  • "Where is acetone stored?"
  • "What safety precautions for hydrochloric acid?"
  • "How to turn on the Keithley 2400?"
  • "What PPE is needed for handling sodium?"

📁 Project Structure

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

📊 Data Sources

  • 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

🔧 Configuration

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)

📄 License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages