How chiang-yuan/llamp works
Project Type and Purpose
• Type: Full-stack retrieval-augmented generation (RAG) framework.
• Purpose: Expose a Python-based LLaMP core (hierarchical ReAct agents grounded on Materials Project, ArXiv, ASE, Atomate2) via a web UI, so users can chat with a materials-aware large language model over HTTP/SSE.
High-Level Components
a. Browser / Frontend (Web container)
• Tech: Svelte, Skeleton CSS, Tailwind, Vite.
• Responsibilities: Render chat UI, manage user settings, open Server-Sent Events (SSE) to stream token-by-token responses.
b. API / Backend (API container)
• Tech: Python, FastAPI (implied), LangChain, Redis (for streaming), Uvicorn/Gunicorn.
• Responsibilities:
• HTTP endpoints for chat and agent triggers
• SSE endpoint powering incremental tokens
• Agent orchestrator modules under api/src/llamp/…
• Call external LLM services (OpenAI, etc.)
• Call Materials Project REST API, ArXiv, ASE, Atomate2
c. External Services & Data Stores
• LLM Provider (OpenAI / HuggingFace)
• Materials Project API
• ArXiv API
• ASE / Atomate2 (local simulation libraries, optional)
• Redis (or in-memory pub/sub for SSE callbacks)
• *(Optional)* Docker registry, GitHub Actions for CI
Relationships and Data Flow
1. User in browser sends a chat request via HTTP POST → Frontend
2. Frontend forwards JSON to Backend API
3. Backend API spins up a Hierarchical ReAct agent:
• May fetch schema/tools from mp_openapi.json, ASE utilities, Atomate2
• Issues sub-requests to Materials Project, ArXiv, or runs ASE/Atomate2 code
• Sends prompts to OpenAI (or other LLM)
• Streams tokens back via Redis callbacks → SSE
4. Frontend listens to SSE, renders streaming responses token-by-token
5. End of conversation cycle
6. *(Optional)* Logging / metrics stored or forwarded to CI / monitoring
Architectural Patterns & Principles
• Containerized micro-services: Separate Web and API containers managed by docker-compose.yml
• Modular plugin-style agents: Each domain (mp, arxiv, ase, atomate2) is a plugin under llamp/…
• ReAct pattern: Agents “Reason+Act” recursively
• Retrieval-Augmented Generation (RAG): Grounding LLM with high-fidelity data
• Server-Sent Events (SSE) for low-latency streaming
• Docker-first local dev with .env, .env.example, Dockerfile.dev, GitHub Actions
Detailed Capture of Essential Elements
• Docker-compose orchestration
• At the bottom, show docker-compose.yml linking Web ↔ API
• CI/CD
• Experiments & Lab
• (Optional) Side note: “Jupyter Notebooks” folder that directly imports llamp Python library — not part of production