Spaces:
Sleeping
Sleeping
File size: 4,891 Bytes
f0831d4 dc784c4 f0831d4 11b9516 3306153 11b9516 f0831d4 11e1f42 f0831d4 11e1f42 aeb68e9 11e1f42 aeb68e9 | 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | ---
title: Fist-aid assitant
emoji: 🚀
colorFrom: blue
colorTo: green
sdk: streamlit
sdk_version: 1.33.0
app_file: app.py
pinned: false
---
# Snakebit Firstaid 🚀
**Short description:** Web application that provides quick, essential first-aid guidance for snakebite (poisoned wound) and normal wounds, and then offers an advanced ChatGPT-powered assistant to deliver tailored next-step guidance.
---
## Features
* Simple, two-panel quick-first-aid interface:
* Left: Snakebite (poisoned wound) — short essential steps.
* Right: Normal wound — short essential steps.
* Users confirm completion and press **Next → Advanced** which forwards the wound type to the advanced assistant.
* Advanced assistant powered by OpenAI ChatGPT (via the `openai` package):
* Confirms basic-first-aid steps completed.
* Collects victim information (name, age, height, weight, notes).
* Saves victim info to `./data/victims.json`.
* Provides in-depth, concise first-aid & monitoring steps and supports follow-up questions.
* Safe defaults for deployment (server settings in `.streamlit/config.toml`).
---
## Files in the repo
* `app.py` — main Streamlit app (single-file app).
* `requirements.txt` — project dependencies.
* `.streamlit/config.toml` — UI theme + server defaults.
* `.streamlit/secrets.toml` — (empty by default; store `OPENAI_API_KEY` here locally if needed — **do not commit**).
* `data/victims.json` — auto-created and appended with victim records by the app (add `data/.gitkeep` if you want the empty folder tracked).
* `.gitignore` — prevents committing secrets, virtualenvs, and local data.
* `README.md` — this document.
---
## Quick start (local)
> Tested with Python 3.10+ (recommend 3.11). Adjust if your environment differs.
1. Create a virtual environment and activate it:
```bash
python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows (PowerShell)
.\.venv\Scripts\Activate.ps1
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Provide your OpenAI API key securely. Recommended options:
* Add to environment (temporary):
```bash
export OPENAI_API_KEY="sk-..."
# Windows PowerShell
$env:OPENAI_API_KEY = "sk-..."
```
* OR (local only, not for public repos) add to `.streamlit/secrets.toml`:
```toml
OPENAI_API_KEY = "sk-REPLACE_WITH_YOUR_KEY"
# Optionally set the model
# OPENAI_MODEL = "gpt-4o-mini"
```
4. Run the app:
```bash
streamlit run app.py
```
Open the address printed by Streamlit (usually [http://localhost:8501](http://localhost:8501)).
---
## Deploying to Hugging Face Spaces (Streamlit)
1. Create a new Space on Hugging Face and choose **Streamlit** as the SDK.
2. Push this repository (all files except secrets) to the Space.
3. In the Space settings, add a secret named `OPENAI_API_KEY` with your OpenAI key. Do **not** commit `secrets.toml` to the repo.
4. Start the Space — it will use `app.py` automatically.
---
## Configuration & secrets
* `.streamlit/config.toml` contains the UI theme and safe server defaults (headless mode, address `0.0.0.0`, disabled XSRF for certain container environments).
* **Never commit** `.streamlit/secrets.toml` (contains API keys). Add it to `.gitignore` (already provided).
---
## Security & emergency notes
* This app is *not* a substitute for professional medical care. It gives short, essential guidance to assist non-professionals.
* If a victim is deteriorating, losing consciousness, has severe bleeding, or you suspect life-threatening poisoning, **call local emergency services immediately**.
* The app stores victim records in `./data/victims.json`. Treat this as potentially sensitive information; if you deploy publicly, review data retention policies and consider adding encryption or removing storage.
---
## Requirements
See `requirements.txt`. Minimal runtime packages include `streamlit` and `openai`. Optionally include `toml`, `python-dotenv`, and `Pillow`.
---
## Development notes
* The app accepts `OPENAI_MODEL` environment variable to override the default model used.
* The app supports both the modern `openai.OpenAI(api_key=...)` client shape and the classic `openai` package usage (the code tries both imports).
* `data/victims.json` is appended; if you want the directory tracked but empty, create `data/.gitkeep` and commit it.
---
## Contributing
If you want improvements (multi-page separation, richer UI, persistent DB, authentication, localization), open an issue or send a pull request. I can help implement features such as:
* Separate pages for the simple/advanced parts (actual `next.py` pages).
* Better UX: progress indicators, larger touch targets, i18n (Vietnamese + English).
* Replace local JSON file with small database (SQLite) or cloud storage for multi-user deployments.
---
## License
Add a license (e.g., MIT) — currently not set in this repo.
|