GithubHelp home page GithubHelp logo

amsiddiqui / ai-code-heist Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 219 KB

An Interactive Prompt Engineering Game

License: MIT License

JavaScript 0.40% HTML 0.28% CSS 0.17% TypeScript 55.14% Python 38.31% Shell 4.08% Dockerfile 1.63%

ai-code-heist's Introduction

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.

ai-code-heist's People

Contributors

amsiddiqui avatar

Watchers

 avatar

ai-code-heist's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.