File size: 1,090 Bytes
fb9092b
 
0d599d9
 
 
fb9092b
0d599d9
fb9092b
 
 
0d599d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: LLM Monitor
emoji: 🛡️
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---

# LLM Monitor (GenAI Shield V2)

A web application powered by Llama-Prompt-Guard-2-86M for pre-inference prompt screening, and post-inference response monitoring.

## Local Development

1. Create a virtual environment and install dependencies:
   ```bash
   python -m venv venv
   source venv/bin/activate
   pip install -r requirements.txt
   ```

2. Download the Prompt Guard model weights:
   ```bash
   python download_model.py
   ```

3. Run the application:
   ```bash
   export GEMINI_API_KEY="your-gemini-key"
   python genai_app.py
   ```

## Deploying to Hugging Face Spaces

1. Create a new Space on [Hugging Face](https://huggingface.co/spaces).
2. Choose **Docker** as the SDK.
3. Choose the **Blank** template.
4. Go to **Settings** > **Variables and Secrets** and add your secrets:
   - `GEMINI_API_KEY`: Your Google Gemini API key.
5. Push this repository to your Hugging Face Space repository. Hugging Face will automatically build and run the Docker image.