CoolFace
Apppublic

alinia/sec-red-teaming-competition

sourceHugging Faceupdated 8mo agoView on Hugging Face
1likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference


Setup Instructions

1. Supabase Database (Required for data collection)

This app uses Supabase (PostgreSQL) to collect student interactions and feedback. Follow these steps:

Step 1: Create a Supabase Project
  1. 1.Go to supabase.com and sign up (free tier available).
  2. 2.Create a new project (takes ~1 minute).
  3. 3.Note your Project URL and Anon Key from the project settings.
Step 2: Create Tables

In the Supabase SQL Editor, run these commands:

sql
-- WARNING: This schema is for context only and is not meant to be run.
-- Table order and constraints may not be valid for execution.

CREATE TABLE public.feedback (
  id integer NOT NULL DEFAULT nextval('feedback_id_seq'::regclass),
  interaction_id integer,
  username text NOT NULL,
  rating integer,
  optional_text text,
  created_at timestamp without time zone DEFAULT now(),
  CONSTRAINT feedback_pkey PRIMARY KEY (id),
  CONSTRAINT feedback_interaction_id_fkey FOREIGN KEY (interaction_id) REFERENCES public.interactions(id)
);
CREATE TABLE public.interactions (
  id integer NOT NULL DEFAULT nextval('interactions_id_seq'::regclass),
  username text NOT NULL,
  query text NOT NULL,
  model_used text,
  response text,
  guardrail_flagged boolean DEFAULT false,
  guardrail_action text,
  created_at timestamp without time zone DEFAULT now(),
  CONSTRAINT interactions_pkey PRIMARY KEY (id)
);

2. Environment Variables

Set these environment variables on Hugging Face Spaces (or locally):

bash
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
ALINIA_API_KEY=your-alinia-key
ALINIA_API_URL=https://staging.api.alinia.ai

3. Run the App

bash
pip install -r requirements.txt
python3 app.py

The app will start on http://localhost:7860 (or similar).


After Class: Export Data

To download the collected data:

  1. 1.Go to your Supabase project dashboard.
  2. 2.In the Data Editor, select the interactions or feedback table.
  3. 3.Click the menu (⋮) → Download as CSV.
  4. 4.Use the CSV files for analysis or model training.