|
| 1 | +--- |
| 2 | +name: setup-genai-dev |
| 3 | +description: Set up the GenAI Engine development environment. Use when starting work on the project for the first time, or when environment needs to be reset. Handles Poetry, PostgreSQL, migrations, and environment variables. |
| 4 | +allowed-tools: Bash, Read, Write |
| 5 | +--- |
| 6 | + |
| 7 | +# Setup GenAI Engine Development Environment |
| 8 | + |
| 9 | +## Prerequisites Check |
| 10 | + |
| 11 | +Before setup, verify these are installed: |
| 12 | +1. Python 3.12 (`python3 --version`) |
| 13 | +2. Docker is running (`docker ps`) |
| 14 | +3. Poetry (`poetry --version`) |
| 15 | + |
| 16 | +If any are missing, inform the user and stop. |
| 17 | + |
| 18 | +## Setup Steps |
| 19 | + |
| 20 | +Execute these steps in order: |
| 21 | + |
| 22 | +### 1. Navigate to Project Directory |
| 23 | +```bash |
| 24 | +cd ./genai-engine |
| 25 | +``` |
| 26 | + |
| 27 | +### 2. Configure Poetry Environment |
| 28 | +```bash |
| 29 | +poetry env use 3.12 |
| 30 | +poetry install --with dev,linters |
| 31 | +``` |
| 32 | + |
| 33 | +### 3. Start PostgreSQL Database |
| 34 | +```bash |
| 35 | +docker compose up -d db |
| 36 | +``` |
| 37 | + |
| 38 | +Wait for healthy status: |
| 39 | +```bash |
| 40 | +sleep 5 |
| 41 | +docker compose ps |
| 42 | +``` |
| 43 | + |
| 44 | +### 4. Set Environment Variables |
| 45 | + |
| 46 | +Export ALL of these environment variables: |
| 47 | +```bash |
| 48 | +export POSTGRES_USER=postgres |
| 49 | +export POSTGRES_PASSWORD=changeme_pg_password |
| 50 | +export POSTGRES_URL=localhost |
| 51 | +export POSTGRES_PORT=5432 |
| 52 | +export POSTGRES_DB=arthur_genai_engine |
| 53 | +export POSTGRES_USE_SSL=false |
| 54 | +export PYTHONPATH="src:$PYTHONPATH" |
| 55 | +export GENAI_ENGINE_SECRET_STORE_KEY="some_test_key" |
| 56 | +export GENAI_ENGINE_ENVIRONMENT=local |
| 57 | +export GENAI_ENGINE_ADMIN_KEY=changeme123 |
| 58 | +export GENAI_ENGINE_INGRESS_URI=http://localhost:3030 |
| 59 | +export GENAI_ENGINE_ENABLE_PERSISTENCE=enabled |
| 60 | +export ALLOW_ADMIN_KEY_GENERAL_ACCESS=enabled |
| 61 | +``` |
| 62 | + |
| 63 | +### 5. Run Database Migrations |
| 64 | +```bash |
| 65 | +cd ./genai-engine |
| 66 | +poetry run alembic upgrade head |
| 67 | +``` |
| 68 | + |
| 69 | +### 6. Verify Setup |
| 70 | +Check database is running: |
| 71 | +```bash |
| 72 | +docker compose ps |
| 73 | +``` |
| 74 | + |
| 75 | +Check migrations applied: |
| 76 | +```bash |
| 77 | +poetry run alembic current |
| 78 | +``` |
| 79 | + |
| 80 | +## Output |
| 81 | + |
| 82 | +Report success/failure for each step. |
| 83 | + |
| 84 | +### LLM Configuration |
| 85 | + |
| 86 | +Check for `OPENAI_API_KEY` in the `.env` file in the `./genai-engine` directory. If present, load it: |
| 87 | +```bash |
| 88 | +source ./genai-engine/.env |
| 89 | +export OPENAI_API_KEY |
| 90 | +``` |
| 91 | + |
| 92 | +If not present, inform the user they need to add their OpenAI API key to the `.env` file for LLM features to work. |
| 93 | + |
| 94 | +## Troubleshooting |
| 95 | + |
| 96 | +- If Docker fails: ensure Docker Desktop is running |
| 97 | +- If Poetry fails: try `poetry env remove 3.12` then retry |
| 98 | +- If migrations fail: check PostgreSQL is healthy with `docker compose logs db` |
0 commit comments