GPT Pilot

repository·main·Indexed 13 days ago

https://github.com/pythagora-io/gpt-pilot

An AI developer companion that builds production-ready applications using a multi-agent system. It employs specialized agents—including a Specification Writer, Architect, Tech Lead, Developer, and Code Monkey—to architect, code, review, and debug software step-by-step alongside a human developer.

Tokens
5.8K
Snippets
23
Records
31
Agent score
98%

What's inside GPT Pilot

  1. How GPT Pilot Works: The Agent Workflow

    main

    GPT Pilot uses a multi-agent system to build applications step-by-step. Instead of generating a whole codebase at once, it follows a structured lifecycle of specialized agents:

    1. Product Owner agent: (Conceptual role)
    2. Specification Writer agent: Clarifies requirements through questioning.
    3. Architect agent: Selects technologies and ensures they are installed on the machine.
    4. Tech Lead agent: Breaks down development into specific tasks.
    5. Developer agent: Translates tasks into human-readable implementation plans.
    6. Code Monkey agent: Implements the actual code changes based on the Developer's plan.
    7. Reviewer agent: Validates the implementation; sends it back to the Code Monkey if errors are found.
    8. Troubleshooter agent: Assists the user in providing feedback when issues arise.
    9. Debugger agent: Assists in resolving runtime or logic errors.
    10. Technical Writer agent: Generates project documentation.

    This step-by-step approach allows the AI to debug issues as they arise and enables the developer to oversee the implementation at scale.

  2. Understand what telemetry data is collected

    main

    Pythagora collects anonymous telemetry data to monitor performance, understand usage patterns, and improve the user experience. The following data points may be collected:

    • Runtime & Usage: Total Runtime, Command Runs, Development Steps, LLM Requests, User Inputs, and Time taken to generate a project.
    • Environment: Operating System (including Linux distro), Python Version, and GPT Pilot Version.
    • LLM Details: LLM Model(s) used.
    • Project Context: Initial prompt (app description), Architecture designed, Documentation used, and Pythagora Tasks/Steps performed.
    • User Identity: User Email (collected if using the Pythagora VSCode Extension or if explicitly provided via the CLI).

    All data is anonymized and used for internal analysis only; it is not shared with third parties.

  3. Manage background tasks with Bull

    main

    If background tasks are enabled, the project uses bull backed by Redis for task queuing.

    Task Definition: Tasks are defined and exported in src/tasks.js.

    Queuing Tasks: Call proxies are automatically created. You can queue a task by importing the tasks utility:

    import { tasks } from "./src/utils/queue.js";
    const result = await tasks.someFunction(...);

    Running Workers: To execute the queued tasks, you must run the worker process:

    npm run worker
  4. Quickstart for React Express template

    main

    Follow these steps to set up and verify your React Express project:

    1. Install dependencies: Run npm install.
    2. Configure environment: Update your .env file with the necessary settings.
    3. Database Setup (SQL only): If using a SQL database, create the initial migration and generate the Prisma client by running:
      npx prisma migrate dev --name initial
    4. Verify installation: Run the test suite to ensure everything is working correctly:
      npm run test
    npm install
    npx prisma migrate dev --name initial
    npm run test
  5. Install and Setup GPT Pilot via CLI

    main

    To use GPT Pilot via the command line, ensure you have Python 3.9+ installed. Follow these steps to set up a local development environment:

    1. Clone the repository:
      git clone https://github.com/Pythagora-io/gpt-pilot.git
      cd gpt-pilot
    2. Create and activate a virtual environment:
      python3 -m venv venv
      source venv/bin/activate
      (On Windows, use venv\Scripts\activate)
    3. Install dependencies:
      pip install -r requirements.txt
    4. Initialize configuration:
      cp example-config.json config.json
    5. Configure config.json with your LLM provider (e.g., openai, anthropic, or groq), API keys, and database settings.
    6. Start the pilot:
      python main.py

    Generated code is stored in a workspace folder inside a directory named after your app.

    git clone https://github.com/Pythagora-io/gpt-pilot.git
    cd gpt-pilot
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    cp example-config.json config.json
    python main.py
  6. Opt out of telemetry collection

    main

    If you prefer not to send anonymous telemetry data to Pythagora, you can disable it by modifying your local configuration file.

    1. Locate your configuration file at ~/.gpt-pilot/config.json.
    2. Set the telemetry.enabled key to false.

    Once this setting is updated, Pythagora will stop collecting telemetry data from your machine.

    {
      "telemetry": {
        "enabled": false
      }
    }
  7. Use Docker with React Express

    main

    You can containerize the application using the provided Dockerfile.

    Build the image:

    docker build -t {{ project_folder }} .

    Run the container: To run the web server (gunicorn) and expose the internal port (3000), use the -P flag and provide your .env file:

    docker run --env-file .env -P {{ project_folder }}
    docker ps

    Run custom commands: To run a specific command inside the container (e.g., starting a Node shell):

    docker run --env-file .env {{ project_folder }} npm run shell

    Note: Replace {{ project_folder }} with your actual project folder name.

    docker build -t {{ project_folder }} .
    docker run --env-file .env -P {{ project_folder }}
  8. Development workflow for React Express

    main

    For local development, use the following commands:

    • Start development server: Runs the server with hot-reload and pretty-printed logs using npm run dev.
    • Run tests: Execute the test suite with npm run test.
    • Linting: The project uses ESLint (configured in .eslintrc.json).
    • Formatting: Code is automatically formatted with prettier. You can manually trigger formatting with npm run prettier or configure your editor to run it on save.
    npm run dev
    npm run test
    npm run prettier
  9. Configure PostgreSQL Support

    main

    By default, GPT Pilot uses SQLite. To use a PostgreSQL database instead, follow these steps:

    1. Install the required drivers:
      pip install asyncpg psycopg2
    2. Update your config.json file. Set the db.url key to your PostgreSQL connection string using the postgresql+asyncpg driver: "db.url": "postgresql+asyncpg://<user>:<password>@<db-host>/<db-name>"
    pip install asyncpg psycopg2
  10. Resume a Pythagora session

    main

    You can resume a previous project session by providing specific identifiers in the CLI arguments. This allows you to pick up exactly where the Orchestrator left off (e.g., at a specific step or state).

    Supported arguments for continuation:

    • --project <project_id>
    • --branch <branch_name>
    • --step <step_id>
    • --project_state_id <state_id>

    When these are provided, telemetry.set("is_continuation", True) is triggered, and the system loads the existing conversation history and project state instead of starting from scratch.

  11. Configure environment variables for Node/Express/Mongoose templates

    main

    When using the node_express_mongoose template, you must create a .env file in your project root based on the .env.example file. This file defines the core runtime configuration for the server, including the network port, database connection, and session security.

    To set up your environment:

    1. Copy .env.example to a new file named .env.
    2. Populate the following keys with your specific values.
    # Copy this file to .env and edit the settings
    
    # Port to listen on (example: 3000)
    PORT=
    
    # MongoDB database URL (example: mongodb://localhost/dbname)
    DATABASE_URL=
    
    # Session secret string (must be unique to your server)
    SESSION_SECRET=