Setting up your development environment
Step 1: Fork the repository
Please fork the project repository by clicking on the "Fork" button. Then, clone the repo using your own GitHub handle:
git clone git@github.com:<your GitHub handle>/ask-a-question.git
For questions related to setup, please contact AAQ Support
Step 2: Configure environment variables
-
Navigate to the
deployment/docker-composedirectory. -
Copy
template.*.envinto new files named.*.envwithin the same directory: -
Update
.litellm_proxy.envwith LLM service credentials. This will be used by LiteLLM Proxy Server to authenticate to LLM services.For local development setup, this is the only file you need to update to get started. For more information on the variables used here and other template environment files, see Configuring AAQ.
-
(optional) Edit which LLMs are used in the
litellm_proxy_config.yaml.
Step 3: Set up your development environment
Once you are done with steps 1 & 2, there are two ways to set up your development environment for AAQ:
You can view the pros and cons of each method at the bottom.
Set up using Docker Compose Watch
Install prerequisites
- Install Docker.
- If you are not using
Docker Desktop, install
Docker Compose with version >=2.22 to use
the
watchcommand.
Run docker compose watch
If not done already, configure the environment variables in Step 2.
-
In the
deployment/docker-composedirectory, runHere's what you should see if the above command executes successfully
✔ Network aaq-stack_default Created ✔ Volume "aaq-stack_db_volume" Created ✔ Volume "aaq-stack_caddy_data" Created ✔ Volume "aaq-stack_caddy_config" Created ✔ Container aaq-stack-caddy-1 Started ✔ Container aaq-stack-litellm_proxy-1 Started ✔ Container aaq-stack-relational_db-1 Started ✔ Container aaq-stack-core_backend-1 Started ✔ Container aaq-stack-admin_app-1 Started Watch enabledThe app will now run and update with any changes made to the
core_backendoradmin_appfolders.The admin app will be available on https://localhost and the backend API testing UI on https://localhost/api/docs.
-
To stop AAQ, first exit the running app process in your terminal with
ctrl+cand then run:
Set up manually
Install prerequisites
- Install conda.
-
Install Node.js v19.
Setting up a different NodeJS version
If you have a different NodeJS version installed already, you can switch to a different version by installing Node Version Manager and then executing
-
Install Docker.
- (optional) Install GNU Make.
makeis used to run commands (targets) inMakefiles and can be used to automate various setup procedures.
Set up the backend
-
Navigate to
ask-a-questionrepository root. -
Set up your Python environment by creating a new conda environment using
make.This command will remove any existing
aaqconda environment and create a newaaqconda environment with the required Python packages.Errors with
psycopg2?psycopg2vspsycopg2-binary: For production use cases we should usepsycopg2but for local development,psycopg2-binarysuffices and is often easier to install. If you are getting errors frompsycopg2, try installingpsycopg2-binaryinstead.If you would like
psycopg2-binaryinstead ofpsycopg2, runmake fresh-env psycopg_binary=trueinstead (see below for why you may want this).See here for more details.
Setting up the Python environment manually
Create virtual environment
conda create --name aaq python=3.10Install Python packages
pip install -r core_backend/requirements.txt pip install -r requirements-dev.txtInstall pre-commit
pre-commitis used to ensure that code changes are formatted correctly. It is only necessary if you are planning on making changes to the codebase.pre-commit install -
Activate your
aaqconda environment. -
Set up the required Docker containers by running
The command will start the following containers:
- PostgreSQL with pgvector extension
- LiteLLM Proxy Server
- Redis
Setting up the DB, LiteLLM Proxy Server, and Redis seprately
If you would like to set up each of these dependencies separately, check out the Makefile at repository root.
-
Export the environment variables you defined earlier in Step 2 by running
set -a source deployment/docker-compose/.base.env source deployment/docker-compose/.core_backend.env set +aSaving environment variables in
aaqconda environmentYou can set environment variables by either running
conda env config vars set <NAME>=<VALUE>for each required environment variable, or save them in the environment activation script. -
Start the backend app.
Here's what you should see if the above command executes successfully
INFO: Will watch for changes in these directories: ['~/ask-a-question'] INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: Started reloader process [73855] using StatReload INFO: Started server process [73858] INFO: Waiting for application startup. 07/15/2024 12:29:08 PM __init__.py 79 : Application started INFO: Application startup complete.This will launch the application in "reload" mode (i.e., the app will automatically refresh everytime you make a change to one of the files).
You can test the endpoint for the API documentation by going to http://localhost:8000/docs (the backend itself runs on http://localhost:8000).
-
To stop the backend app, first exit the running app process in your terminal with
ctrl+cand then run:
Set up the frontend
-
Navigate to
ask-a-questionrepository root and activate theaaqvirtual environment: -
In a new terminal:
Here's what you should see if the above commands execute successfully
This will install the required NodeJS packages for the admin app and start the admin app in
dev(i.e., autoreload) mode. The admin app will now be accessible on http://localhost:3000/.You can login with either the default credentials (username:
admin, password:fullaccess) or the ones you specified in.core_backend.env. -
To stop the admin app, exit the running app process in your terminal with
ctrl+c.
Pros and cons of each setup method
| Method | Pros | Cons |
|---|---|---|
| Set up using docker compose watch |
|
|
| Set up manually |
|
|
Step 4: Set up docs
Note
Ensure that you are in the ask-a-question project directory and that you have activated the
aaq virtual environment before proceeding.
To host docs offline so that you can see documentation changes in real-time, run the
following from ask-a-question repository root with an altered port (so that it doesn't
interfere with the app's server):