Skip to content

amSiddiqui/AI-Code-Heist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Code Heist

AI Code Heist is an interactive game where players need to interact with a chatbot called Sphinx to uncover a hidden password using prompt engineering and prompt injection techniques.

AI Code Heist Cover

Table of Contents

Requirements

Installation

Front End

  1. Navigate to the code-heist directory:
    cd code-heist
  2. Install the dependencies:
    npm install
  3. Start the development server:
    npm run dev

Back End

  1. Create a Firebase account and download the firebase-sdk.json file.
  2. Place the firebase-sdk.json file in the server directory.
  3. Navigate to the server directory:
    cd server
  4. Create a virtual environment with Python 3.11+:
    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  5. Install the required dependencies:
    pip install -r requirements.txt

Environment Setup

  1. Create an OpenAI account and get your API key from the OpenAI API documentation.
  2. Set up your environment variables:
    • Create a .env file from .env.example:
      cp .env.example .env
    • Edit the .env file and set the following variables:
      OPENAI_API_KEY=<your_openai_api_key>
      ADMIN_KEY=<your_admin_key>
      SECRET_KEY=<your_secret_key>
      REDIS_URL=localhost
      REDIS_PORT=6379
      
    • To generate the ADMIN_KEY, use the following Python script:
      import hashlib
      
      key = '<Choose an admin password>'
      print(hashlib.sha256(key.encode("utf-8")).hexdigest())
    • SECRET_KEY can be any random long string

Running the Application

  1. Install Redis server locally. Follow the Redis installation instructions.
  2. Start the Redis server:
    redis-server
  3. Make sure your firebase-sdk.json file is in the server directory.
  4. Activate your virtual environment:
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  5. Run the FastAPI server:
    uvicorn main:app --reload

Accessing the Application

  • Open your browser and go to http://localhost:5173 to access the main application.
  • To access the admin panel, go to http://localhost:5173/admin.
  • Use the password you generated for the ADMIN_KEY in the .env file to log in.
  • Click Create Game to create a new game session.
  • Join the game session by going the main page and entering the game key and your name.
  • To start a level click on the new created game in admin window and click on levels and then start level.

Docker Setup

To run the application using Docker, ensure you have Node.js installed and Docker Desktop set up.

  1. Once the environment file is in place and firebase-sdk.json downloaded, build the static files.
  2. Navigate to the code-heist directory:
    cd code-heist
  3. Install the dependencies:
    npm install
  4. Build the static files:
    npm run deploy
  5. Navigate to the server directory:
    cd ../server
  6. Launch the Docker image that creates the Redis server and Uvicorn server:
    docker compose up --build

Helpful Links

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

An Interactive Prompt Engineering Game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published