Memory-Based AI Agents Integrated with Real-Time Quality Control Automates Chip-based nanoESI-MS/MS Platform
This repository implements the first LLM-driven AI agent framework for chip-based nanoESI-MS/MS automation, specifically designed for TriVersa NanoMate coupled to SCIEX 4000 QTRAP systems. The framework leverages large language models to interpret natural language instructions and autonomously execute analytical workflowsβfrom worklist generation and real-time quality control to data conversion, visualization, and literature retrievalβwithout requiring programming expertise. Unlike traditional vendor software or custom scripts, the system integrates persistent memory to preserve both lab-specific protocols and published knowledge, while maintaining a modular, instrument-agnostic architecture that can evolve as experimental needs change across diverse analytical platforms beyond mass spectrometry.
- QC Agent - Automated real-time quality control
- Worklist Agent - Intelligent sample worklist generation
- Parse Agent - Automated data extraction and organization
- Visualization Agent - Automated data visualization
- Helper Agent - Retrival Augmented Generation (RAG) for scientific literature and persistent memory for knowledge retention
# Create conda environment
conda create --name qtrap_paper --clone sciborg_dev
# Or create from scratch:
conda env create -f docs/environment/environment.yml
# Activate environment
conda activate qtrap_paper
# Install additional dependencies
pip install python-dotenv # For secure API key loading# Create .env file for Helper Agent
cd helper_agent
cp .env.example .env
nano .env # Add your OPENAI_API_KEYSee helper_agent/API_KEY_SETUP.md for detailed security setup.
import sys
sys.path.insert(0, "helper_agent/drivers")
from config_loader import setup_environment
from qtrap_utils import setup_helper, ask_agent, tell_agent
# Load API key securely
setup_environment()
# Setup agent
helper = setup_helper(model="gpt-4o", temperature=0)
# Ask questions (searches literature)
answer = ask_agent("What solvent for lipidomics?")
# Store your experimental findings
tell_agent("Project SolventMatrix: 2:1 MeOH/ACN is best...")
# Ask again (now uses YOUR data!)
answer = ask_agent("What solvent for lipidomics?")# Install LangGraph
cd UI_qtrap/react-agent
pip install -e .
# Configure .env
cp .env.example .env
# Add: OPENAI_API_KEY, TAVILY_API_KEY
# Start LangGraph UI
langgraph devOpen browser to http://localhost:8123 to access LangGraph Studio.
Chip-based-nanoESI-MS-MS-AI-Agents/
βββ README.md # This file
βββ .gitignore # Git configuration
β
βββ UI_qtrap/ # Main QTRAP workflow
β βββ react-agent/ # LangGraph agents
β βββ src/react_agent/ # Core scripts
β β βββ Q_QC.py # QC analysis (main)
β β βββ Q_worklist.py # Worklist generation
β β βββ Q_parse.py # Data parsing
β β βββ Q_helper.py # RAG helper
β β βββ Q_viz_*.py # Visualization scripts
β βββ langgraph.json # Agent configuration
β
βββ helper_agent/ # π Standalone Helper AI Agent
β βββ drivers/ # Core modules
β β βββ qtrap_utils.py # Main API (use this!)
β β βββ helper_agent_core.py # Agent implementation
β β βββ config_loader.py # Secure API key loading
β β βββ archive/ # Old/unused files
β β βββ README.md # Module documentation
β β
β βββ logs/ # Organized log files
β β βββ ask_agent/ # Memory-first queries
β β βββ tell_agent/ # Memory storage
β β βββ query/ # Full RAG queries
β β βββ README.md # Log documentation
β β
β βββ papers/ # Scientific literature corpus
β β βββ recentlipids7/ # Lipidomics papers
β β βββ faiss_index/ # Vector embeddings
β β
β βββ helper_agent_notebooks/ # Example notebooks
β βββ .env # API keys (gitignored)
β βββ .env.example # API key template
β βββ API_KEY_SETUP.md # Security guide
β βββ ORGANIZATION_SUMMARY.md # Complete organization guide
β
βββ docs/ # Documentation
βββ README.md # Documentation index
βββ environment/ # Setup files
βββ guides/ # User guides
βββ CLEANUP_SUMMARY.md # Repo maintenance
βββ GIT_LARGE_FILES_REPORT.md
- Monitors MS data quality in real-time
- Detects failed samples automatically
- Generates TIC plots and QC metrics
- Triggers reprocessing workflows
- Creates worklists formatted for Analyst v1.6.3
- Formats for windows 7 and moves files to QTRAP worklist directory automatically
- Operator initials for each experiemnt
- Extracts data from raw .wiff files
- Converts to structured CSV format
- Organizes by project
- RAG-based Q&A on scientific papers
- Persistent memory for knowledge retention
- Memory-first queries (checks stored data before searching literature)
- Automatic logging of all interactions
- Secure API key management
Q_QC.py- Main QC workflow with monitoringQ_QC_TIC.py- TIC extraction and plottingQ_viz_QC.py- QC visualization
Q_parse.py- Data parsing and extractionQ_worklist.py- Worklist generationQ_convert.py- MSConvert integration
Q_viz_intensity.py- Intensity visualizationQ_viz_intensity_advanced.py- Advanced plotsQ_viz_intensity_advanced_part2.py- Statistical plots
Q_helper.py- RAG-based literature assistant (LangGraph integration)helper_agent/- Standalone Helper AI Agent system:qtrap_utils.py- Main API for agent operationshelper_agent_core.py- Core RAG and memory implementationconfig_loader.py- Secure API key management- Organized logging system (ask/tell/query logs)
- Example notebooks with Project SolventMatrix demo
- LangGraph - Agent orchestration and workflow management
- LangChain - LLM integration and tool calling
- OpenAI GPT-4o - Language model for agent reasoning
- FAISS - Vector database for RAG and literature search
- Pandas - Data manipulation and analysis
- NumPy/SciPy - Statistical analysis
- python-dotenv - Secure environment variable management
- Matplotlib/Seaborn - Scientific visualization
If you use this workflow in your research, please cite:
Memory-Based AI Agents Integrated with Real-Time Quality Control Automates Chip-based nanoESI-MS/MS Platform
(In Preparation)
For questions or collaboration:
This project uses:
- LangGraph by LangChain
- OpenAI API
- Scientific Python ecosystem
Last Updated: October 22, 2025