CoolFace
Apppublic

TrinetraLabs/Placebo_AI

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
App README

<div align="center">

🧠 Placebo AI

Medical Intelligence Platform β€” Serverless RAG at LPU Speed

![Live Demo](https://trinetralabs-placeboai.hf.space/) ![License](#license) ![Python](#) ![FastAPI](#) ![Groq](https://groq.com/)

Instant, medically-grounded answers backed by 1.3M+ medical text vectors β€” with zero local disk footprint.

Live Demo Β· Architecture Β· Setup Β· 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.

πŸ—οΈ Architecture

Placebo 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.

mermaid
flowchart LR
    U[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| API
    HFDS -->|Media/Refs| API
    GROQ -->|Streamed Tokens| API
    API -->|SSE Stream| FE

Design Principles

PrincipleImplementation
Zero local footprintAll vector and asset data lives in managed cloud stores; the container ships with no bundled dataset.
Stateless computeThe FastAPI backend holds no persistent state, enabling horizontal scaling and instant cold starts.
Grounded generationRetrieval context is injected into strict XML-bounded prompts to reduce hallucination and keep the model anchored to retrieved evidence.
Fail-safe by designBecause 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

LayerTechnologyPurpose
Vector DatabaseDataStax Astra DBServerless cloud-native vector search over 1.3M+ medical text embeddings
LLM InferenceGroq β€” Llama-3.1-8b-instantUltra-low-latency token streaming via custom LPU hardware
Asset StorageHuggingFace DatasetsServerless retrieval of source documents and images
Backend FrameworkFastAPI (Python)Async API layer, request validation, streaming responses
AuthenticationSupabase AuthJWT-based session management and identity verification
FrontendHTML/CSS/JS (glassmorphism, custom animations)Clinical, responsive UI optimized for accessibility and SEO
DeploymentDocker (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.
MethodEndpointDescriptionAuth Required
POST/api/querySubmit a medical question; returns a streamed, RAG-grounded responseβœ…
GET/api/healthService health check❌
POST/api/auth/sessionValidate 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

bash
git clone https://github.com/labstrinetra/placebo.ai.git
cd placebo.ai

2. Install dependencies

bash
pip install -r requirements.txt

3. Configure environment variables

Create a .env file in the project root:

env
GROQ_API_KEY=your_groq_api_key
ASTRA_DB_API_ENDPOINT=your_astra_endpoint
ASTRA_DB_APPLICATION_TOKEN=your_astra_token
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_key

4. Run the application

bash
python src/app.py

The application will be available at http://localhost:8000.


πŸ“¦ Deployment

Placebo AI is live in production on HuggingFace Spaces, running in a custom Docker container:

πŸ”— Live URL: 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

🀝 Contributing

Contributions, issues, and feature requests are welcome. Please open an issue first to discuss significant changes before submitting a pull request.


πŸ“„ License

Distributed under the MIT License. See LICENSE for details.


<div align="center">

Developed by Trinetra Labs**

</div>