Spaces:
Sleeping
Sleeping
Placebo Deploy commited on
Commit Β·
06e2bcc
1
Parent(s): bcad276
md file update
Browse files7 unmodified lines891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697 unmodified linespinned: false---# Placebo AI - Medical Intelligence PlatformPlacebo AI is a high-performance, cloud-native medical artificial intelligence platform. It provides instant, medically grounded answers utilizing a massive database of over 1.3 million medical text vectors, powered by a completely serverless and lightweight architecture.## π Cloud-Native ArchitectureThis project was recently migrated from a heavy local-dataset architecture to a **100% Serverless Cloud-Native infrastructure**, ensuring zero memory crashes (OOM) and lightning-fast global deployments.- **Vector Database:** [DataStax Astra DB](https://astra.datastax.com/) (Serverless Cloud Vector Search)- **LLM Inference Engine:** [Groq](https://groq.com/) (Llama-3.1-8b-instant for hyper-fast token generation)- **Asset Storage:** [HuggingFace Datasets](https://huggingface.co/) (Serverless Image & Document retrieval)- **Backend Framework:** FastAPI (Python)- **Authentication:** Supabase Auth## β‘ Key Features- **Zero Local Footprint:** The 17GB vector database and 88GB image database have been entirely offloaded to Astra DB and HuggingFace. The application requires virtually zero local disk space to run.- **Lightning Fast:** Uses Groq's LPU architecture to stream LLM responses instantly.- **Dynamic Frontend (Perfect 100s):** A beautiful, responsive, clinical UI built with modern CSS animations and glassmorphism. Achieves perfect 100/100 Accessibility and SEO scores on Google Lighthouse.- **Full-Stack Engineering:** Designed meticulously from the UI to the core logic, featuring custom KeywordAugmented RAG Retrievers, strict XML prompt boundaries, and seamless Supabase JWT verification.## π οΈ Installation & Setup1. **Clone the repository:**```bashgit clone https://github.com/labstrinetra/placebo.ai.gitcd placebo.ai```2. **Install dependencies:**```bashpip install -r requirements.txt```3. **Set Environment Variables:**Create a `.env` file and add your credentials:```envGROQ_API_KEY=your_groq_api_keyASTRA_DB_API_ENDPOINT=your_astra_endpointASTRA_DB_APPLICATION_TOKEN=your_astra_tokenSUPABASE_URL=your_supabase_urlSUPABASE_ANON_KEY=your_supabase_key```4. **Run the Application:**```bashpython src/app.py```The application will be available at `http://localhost:8000`## π¦ DeploymentPlacebo AI is successfully deployed and running live on **HuggingFace Spaces** using a custom Docker container.- **Live URL:** [https://trinetralabs-placeboai.hf.space/](https://trinetralabs-placeboai.hf.space/)Because Placebo AI is completely serverless, you can also deploy this exact repository directly to free platforms like **Render**, **Railway**, or **Vercel** without worrying about disk space or RAM limitations.---*Developed by Trinetra Labs*7 unmodified lines891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082097 unmodified linespinned: false---<div align="center"># π§ Placebo AI### Medical Intelligence Platform β Serverless RAG at LPU Speed[](https://trinetralabs-placeboai.hf.space/)[](#license)[](#)[](#)[](https://groq.com/)**Instant, medically-grounded answers backed by 1.3M+ medical text vectors β with zero local disk footprint.**[Live Demo](https://trinetralabs-placeboai.hf.space/) Β· [Architecture](#-architecture) Β· [Setup](#%EF%B8%8F-installation--setup) Β· [Deployment](#-deployment)</div>---## π Overview**Placebo AI** is a cloud-native medical intelligence platform that combines retrieval-augmented generation (RAG) with a fully serverless data layer. Rather than shipping a multi-gigabyte vector index alongside the application, Placebo AI offloads all heavy assets β embeddings, document text, and images β to managed cloud services, leaving the application itself lightweight, stateless, and trivially deployable to any container platform.The result is a system that can answer nuanced medical questions with grounded, source-backed context, streamed back to the user in near real-time thanks to Groq's LPU (Language Processing Unit) inference engine.> **Disclaimer:** Placebo AI is an informational and educational tool. It is not a substitute for professional medical diagnosis, advice, or treatment. Always consult a qualified healthcare provider for medical concerns.---## ποΈ ArchitecturePlacebo AI's architecture was deliberately redesigned to eliminate the operational fragility of local, disk-resident datasets. The migration removed a 17GB vector store and an 88GB image corpus from the application's runtime footprint entirely, replacing them with serverless equivalents that scale independently of the app container.```mermaidflowchart LRU[User Browser] -->|HTTPS| FE[Frontend<br/>Glassmorphic UI]FE -->|JWT Auth| AUTH[Supabase Auth]FE -->|Query| API[FastAPI Backend]API -->|Keyword-Augmented<br/>Retrieval| ASTRA[(Astra DB<br/>Serverless Vector Search)]API -->|Asset Fetch| HFDS[(HuggingFace Datasets<br/>Docs & Images)]API -->|Grounded Prompt| GROQ[Groq LPU<br/>Llama-3.1-8b-instant]ASTRA -->|Top-K Context| APIHFDS -->|Media/Refs| APIGROQ -->|Streamed Tokens| APIAPI -->|SSE Stream| FE```### Design Principles| Principle | Implementation ||---|---|| **Zero local footprint** | All vector and asset data lives in managed cloud stores; the container ships with no bundled dataset. || **Stateless compute** | The FastAPI backend holds no persistent state, enabling horizontal scaling and instant cold starts. || **Grounded generation** | Retrieval context is injected into strict XML-bounded prompts to reduce hallucination and keep the model anchored to retrieved evidence. || **Fail-safe by design** | Because there's no local dataset to load into memory, the architecture is immune to out-of-memory (OOM) crashes that plagued the previous local-dataset version. |---## π§© Tech Stack| Layer | Technology | Purpose ||---|---|---|| **Vector Database** | [DataStax Astra DB](https://astra.datastax.com/) | Serverless cloud-native vector search over 1.3M+ medical text embeddings || **LLM Inference** | [Groq](https://groq.com/) β Llama-3.1-8b-instant | Ultra-low-latency token streaming via custom LPU hardware || **Asset Storage** | [HuggingFace Datasets](https://huggingface.co/) | Serverless retrieval of source documents and images || **Backend Framework** | FastAPI (Python) | Async API layer, request validation, streaming responses || **Authentication** | Supabase Auth | JWT-based session management and identity verification || **Frontend** | HTML/CSS/JS (glassmorphism, custom animations) | Clinical, responsive UI optimized for accessibility and SEO || **Deployment** | Docker (HuggingFace Spaces, Render, Railway, Vercel-compatible) | Portable, serverless-friendly container |---## β‘ Key Features- **Zero Local Footprint** β The former 17GB vector database and 88GB image archive have been fully migrated off-disk to Astra DB and HuggingFace Datasets respectively. The running application requires negligible local storage.- **Lightning-Fast Inference** β Powered by Groq's LPU architecture, responses stream token-by-token with minimal latency compared to traditional GPU-based inference.- **Keyword-Augmented RAG Retrieval** β A custom retriever layer blends semantic vector search with keyword-based re-ranking to improve relevance on medical terminology and abbreviations.- **Strict XML Prompt Boundaries** β All retrieved context is wrapped in explicit XML tags before being passed to the LLM, reducing prompt injection risk and improving grounding fidelity.- **Secure Authentication** β Supabase-issued JWTs are verified server-side on every protected request, ensuring session integrity without maintaining server-side session state.- **Accessibility & Performance** β The frontend achieves perfect 100/100 Accessibility and SEO scores on Google Lighthouse, with a responsive, glassmorphic clinical interface.- **Platform-Agnostic Deployment** β Being fully serverless on the data side, the same Docker image can be deployed to HuggingFace Spaces, Render, Railway, Vercel, or any container-compatible host without modification.---## π API Overview> Update endpoint paths/names below to match your actual FastAPI routes β placeholders shown for structure.| Method | Endpoint | Description | Auth Required ||---|---|---|---|| `POST` | `/api/query` | Submit a medical question; returns a streamed, RAG-grounded response | β || `GET` | `/api/health` | Service health check | β || `POST` | `/api/auth/session` | Validate Supabase JWT and establish a session context | β || `GET` | `/api/sources/{doc_id}` | Retrieve a specific source document/image reference | β |---## π οΈ Installation & Setup### Prerequisites- Python 3.10+- A Groq API key- A DataStax Astra DB instance (serverless vector-enabled)- A Supabase project (for authentication)### 1. Clone the repository```bashgit clone https://github.com/labstrinetra/placebo.ai.gitcd placebo.ai```### 2. Install dependencies```bashpip install -r requirements.txt```### 3. Configure environment variablesCreate a `.env` file in the project root:```envGROQ_API_KEY=your_groq_api_keyASTRA_DB_API_ENDPOINT=your_astra_endpointASTRA_DB_APPLICATION_TOKEN=your_astra_tokenSUPABASE_URL=your_supabase_urlSUPABASE_ANON_KEY=your_supabase_key```### 4. Run the application```bashpython src/app.py```The application will be available at `http://localhost:8000`.---## π¦ DeploymentPlacebo AI is live in production on **HuggingFace Spaces**, running in a custom Docker container:π **Live URL:** [https://trinetralabs-placeboai.hf.space/](https://trinetralabs-placeboai.hf.space/)Because all heavy data lives off-container, the exact same repository can be deployed to any of the following without disk or memory tuning:- **Render** β Docker web service, no persistent disk required- **Railway** β one-click Docker deploy from GitHub- **Vercel** β via Docker-compatible serverless functions (API routes)- **HuggingFace Spaces** β current production host (Docker SDK)### Deployment Checklist- [ ] All environment variables set in the host platform's secrets manager (never commit `.env`)- [ ] `app_port` matches the platform's expected port (7860 for HF Spaces, configurable elsewhere)- [ ] Astra DB and Supabase projects are on production-tier plans if expecting sustained traffic- [ ] Groq API rate limits reviewed for expected concurrent load---## π Security Notes- JWTs issued by Supabase are verified server-side on every authenticated request; no session state is persisted in the application.- API keys and database tokens are read exclusively from environment variables β never hardcoded or logged.- Retrieved context is sandboxed within explicit XML boundaries before being passed to the LLM, limiting the blast radius of prompt-injection attempts embedded in source documents.---## πΊοΈ Roadmap- [ ] Multi-turn conversational memory with session-scoped context windows- [ ] Source citation UI (inline links to retrieved documents/images)- [ ] Admin dashboard for corpus management and query analytics- [ ] Rate limiting and usage quotas per authenticated user---## π€ ContributingContributions, issues, and feature requests are welcome. Please open an issue first to discuss significant changes before submitting a pull request.---## π LicenseDistributed under the MIT License. See `LICENSE` for details.---<div align="center">*Developed by **Trinetra Labs***</div>
README.md+183-43