Spaces:
Sleeping
π± Deploy DE Assistant to iOS β Step by Step ($0)
What you get
A PWA that installs on your iPhone home screen like a native app, with:
- Full chat interface with markdown rendering
- Voice input (speak your question)
- Voice output (AI reads the answer aloud)
- Works offline for the UI shell
- Connected to Groq's free-tier LLM (sub-500ms responses)
Option A: Hugging Face Spaces (Recommended β 5 minutes)
HF Spaces gives you a free public HTTPS URL β required for the PWA to work on iOS.
Step 1 β Get a free Groq API key
- Go to console.groq.com
- Sign up β API Keys β Create API Key
- Copy the key (starts with
gsk_)
Step 2 β Create a Hugging Face Space
- Go to huggingface.co/new-space
- Space name:
de-knowledge-assistant - SDK: Docker (not Gradio/Streamlit)
- Visibility: Public
Step 3 β Create a Dockerfile in the Space
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 7860
CMD ["python", "app.py"]
Step 4 β Upload all files
Push these files to the Space repo (via git or HF UI):
app.py
rag.py
agent.py
requirements.txt
static/index.html
static/manifest.json
static/sw.js
knowledge/data_engineering_patterns.pdf
Dockerfile
# Using git
git clone https://huggingface.co/spaces/your-username/de-knowledge-assistant
cd de-knowledge-assistant
# copy all de-assistant/ files here
git add .
git commit -m "Initial deployment"
git push
Step 5 β Set the Groq API key as a secret
In HF Spaces β Settings β Repository Secrets:
- Name:
GROQ_API_KEY - Value: your
gsk_...key
Step 6 β Add to iPhone home screen
- Wait for the Space to build (~3 min)
- Open your Space URL in Safari on iPhone:
https://your-username-de-knowledge-assistant.hf.space - Tap the Share button (box with arrow) β Add to Home Screen
- Name it "DE Assistant" β Add
Done! It now appears on your home screen like a native app. π
Option B: Local + Ngrok (instant, for testing)
Run locally and expose with a free ngrok tunnel so Safari can reach it:
# Terminal 1 β start the app
./setup.sh
# Terminal 2 β expose publicly
brew install ngrok # or download at ngrok.com
ngrok http 8000
Copy the https://xxxx.ngrok.io URL β open in iPhone Safari β Add to Home Screen.
Enabling Voice on iOS
Voice requires HTTPS (which HF Spaces provides). After installing the PWA:
- Open the app from your home screen
- Tap the π€ microphone button
- iOS will ask for microphone permission β Allow
- Speak your question β the AI will reply and read the answer aloud
Tip: The voice assistant also reads back the AI's answer using the device's built-in text-to-speech (no extra API needed).
Architecture Overview
iPhone (Safari PWA)
β
β HTTPS / SSE streaming
βΌ
Hugging Face Spaces (free)
β FastAPI app.py
β ββ /api/chat β agent.py (streaming)
β ββ /api/search β rag.py (vector search)
β
ββ RAG pipeline
β ββ PDF β PyPDF2 β 800-char chunks
β ββ sentence-transformers/all-MiniLM-L6-v2 (free, CPU)
β ββ ChromaDB in-memory (MMR retrieval)
β
ββ Groq API (free tier)
ββ llama-3.1-8b-instant (< 500ms latency)
Connecting to Databricks (optional upgrade)
Once you have a Databricks workspace:
- Run
databricks/agent_notebook.pyto register the MLflow model - Create a Model Serving endpoint (free on Databricks trial)
- Add
DATABRICKS_ENDPOINT_URLandDATABRICKS_TOKENto HF Spaces secrets - The agent automatically routes to Databricks when those vars are set
Free Tier Limits (as of 2024)
| Service | Free Limit |
|---|---|
| Groq API | 14,400 requests/day, 30 req/min |
| HF Spaces | 2 vCPU, 16 GB RAM, always-on |
| ChromaDB | Unlimited (in-memory) |
| sentence-transformers | Unlimited (local) |
The embedding model (~90 MB) is downloaded on first start and cached in HF Spaces.