Spaces:
Build error
Build error
Commit
·
0f0007e
1
Parent(s):
c394ae1
readme
Browse files
README.md
CHANGED
|
@@ -1,74 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
- ⚡ Fast inference with PyTorch
|
| 11 |
-
|
| 12 |
-
## Installation
|
| 13 |
-
|
| 14 |
-
1. Install dependencies:
|
| 15 |
-
```bash
|
| 16 |
-
pip install -r requirements.txt
|
| 17 |
-
```
|
| 18 |
-
|
| 19 |
-
## Usage
|
| 20 |
-
|
| 21 |
-
### Local Development
|
| 22 |
-
|
| 23 |
-
1. Start the web server:
|
| 24 |
-
```bash
|
| 25 |
-
python app.py
|
| 26 |
-
```
|
| 27 |
-
|
| 28 |
-
2. Open your browser and navigate to:
|
| 29 |
-
```
|
| 30 |
-
http://localhost:7860
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
3. Enter a prompt in the text area and click "Check Safety"
|
| 34 |
-
|
| 35 |
-
### Docker Deployment
|
| 36 |
-
|
| 37 |
-
Build and run with Docker:
|
| 38 |
-
```bash
|
| 39 |
-
docker build -t prompt-safety-checker .
|
| 40 |
-
docker run -p 7860:7860 prompt-safety-checker
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
### Hugging Face Spaces Deployment
|
| 44 |
-
|
| 45 |
-
1. Create a new Docker Space on Hugging Face
|
| 46 |
-
2. Upload the following files:
|
| 47 |
-
- `Dockerfile`
|
| 48 |
-
- `app.py`
|
| 49 |
-
- `requirements.txt`
|
| 50 |
-
- `templates/index.html`
|
| 51 |
-
3. The app will automatically deploy on port 7860
|
| 52 |
-
|
| 53 |
-
## Model
|
| 54 |
-
|
| 55 |
-
This app uses the [STU-Injection-aegis](https://huggingface.co/viccon23/STU-Injection-aegis) model from Hugging Face, which is designed to detect potentially unsafe or malicious prompts that could be used for injection attacks.
|
| 56 |
-
|
| 57 |
-
## API Endpoint
|
| 58 |
-
|
| 59 |
-
You can also use the API directly:
|
| 60 |
-
|
| 61 |
-
```bash
|
| 62 |
-
curl -X POST http://localhost:5000/classify \
|
| 63 |
-
-H "Content-Type: application/json" \
|
| 64 |
-
-d '{"prompt": "Your prompt here"}'
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
Response:
|
| 68 |
-
```json
|
| 69 |
-
{
|
| 70 |
-
"label": "Safe",
|
| 71 |
-
"confidence": 95.32,
|
| 72 |
-
"predicted_class": 0
|
| 73 |
-
}
|
| 74 |
-
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Prompt Injection Detection
|
| 3 |
+
emoji: 🛡️
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: orange
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|