This project is an educational app designed to help students better understand AI safety, in particular about jailbreaking. There is an AI chatbot designed to protect a secret password. The challenge is to trick the bot into breaking its own rules and revealing hidden information.
You can try the interactive chatbot and see how it works by visiting the deployed version of the app on Streamlit Cloud (https://jailbreaking-app.streamlit.app/)
Follow these steps to get the app running on your local machine.
-
Clone the repository:
git clone https://github.com/your-username/educational-app.git cd educational-app -
Set up a virtual environment (Optional, but recommended):
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install required dependencies:
pip install -r requirements.txt
-
Create
.streamlit/secrets.tomlfile:In the root directory of the project, create a
.streamlit/secrets.tomlfile with your Hugging Face API token.Example:
[huggingface] HF_TOKEN = "your_huggingface_api_token_here"
This file will not be tracked by Git due to
.gitignore.The Hugging Face API token allows secure access to AI models via the Inference API. To generate one, sign up or log in to Hugging Face, navigate to Account Settings then Access Tokens, click New Token, select the "Read" role, and copy the generated token.
-
Run the app locally:
streamlit run src/chatbot/main.py
-
Open your browser and go to
http://localhost:8501to interact with the chatbot.
This project is designed to be deployed on Streamlit Cloud. Follow these steps to set up and deploy the app.
Create a Streamlit Cloud Account
Visit Streamlit Cloud, sign up using or log in.
Link Your GitHub Repository
Authorize Streamlit Cloud to access your GitHub account, and click "New App" in Streamlit Cloud.
Select the GitHub Repository where your project is stored, and Cchoose the correct branch (e.g., main) and set the correct entry point file (e.g., src/chatbot/main.py).
3οΈ Securely Store API Keys using Secrets Management
The Hugging Face API token (used for interacting with AI models) is securely stored in the secrets.toml file. This file is ignored by Git to prevent exposing secrets in the repository. For deployments, you can use Streamlit Cloudβs Secrets management to securely store and access the Hugging Face token.