File size: 2,554 Bytes
d9fdc34 ca1ff64 d9fdc34 a7fd580 d9fdc34 ca1ff64 a637385 0826229 a637385 f2337a6 d9fdc34 7e138b7 d9fdc34 ca1ff64 d9fdc34 e25d722 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# Hugging Face Spaces (Docker) — Deploy + Debug
This project is deployed as a Hugging Face Space using the Docker SDK.
## One-time setup (Space UI)
Space: `https://huggingface.co/spaces/MikelWL/ConverTA`
In Space → Settings → Variables and secrets:
**Secrets**
- `LLM_API_KEY`: OpenRouter API key
- `APP_PASSWORD`: shared password to unlock the Space UI (optional but recommended for public Spaces)
**Variables**
- `LLM_BACKEND`: `openrouter`
- `LLM_HOST`: `https://openrouter.ai/api/v1`
- `LLM_MODEL`: e.g. `google/gemini-3-flash-preview`
- `LLM_SITE_URL`: `https://huggingface.co/spaces/MikelWL/ConverTA` (optional)
- `LLM_APP_NAME`: `ConverTA` (optional)
- `DB_PATH`: `/data/converta/converta.db`
- `FRONTEND_WEBSOCKET_URL`: `ws://127.0.0.1:7860/api/ws/conversation`
- `FRONTEND_BACKEND_BASE_URL`: `http://127.0.0.1:7860/api` (optional)
Restart the Space after changing secrets/variables.
## Local smoke test (HF-like)
Run the Docker image locally before pushing to HF:
```bash
./run_docker_local.sh
```
Then open `http://localhost:7860` and click **Start Conversation**.
If `APP_PASSWORD` is set, you will first see a login page; enter the password to unlock the app.
Note: the local Docker runner forces `FRONTEND_WEBSOCKET_URL` to use the mounted backend (`/api/ws/conversation`) so you don’t accidentally point at `localhost:8000`.
It also mounts `./.localdata` to `/data` and defaults `DB_PATH` to `/data/converta/converta.db` for HF-like persistence.
If `7860` is already in use locally, run:
```bash
HOST_PORT=7861 ./run_docker_local.sh
```
## Deploy (push to Space repo)
The Space is also configured as a git remote locally (`hf`).
```bash
git push hf main
```
If the Space repo ever gets reset/recreated and your push is rejected with “fetch first”, use:
```bash
git push --force hf main
```
## Troubleshooting
- **UI loads but analysis never appears / shows backend connection errors**
- Ensure `FRONTEND_WEBSOCKET_URL` is set to `ws://127.0.0.1:7860/api/ws/conversation`.
- **Space is public but you want to prevent casual usage**
- Set the `APP_PASSWORD` secret to enable the shared-password login gate.
- **Space crashes on startup**
- Check Space → Logs for the Python traceback.
- Confirm `PORT` is being respected (HF sets it automatically; we bind to `0.0.0.0:$PORT`).
- **OpenRouter errors**
- Confirm `LLM_API_KEY` secret is set and `LLM_MODEL` is valid on OpenRouter.
- The resource agent retries twice (5s, 10s) on transient OpenRouter failures before surfacing an error in the UI.
|