Hey there! We are so excited that you're interested in Danswer.
As an open source project in a rapidly changing space, we welcome all contributions.
The GitHub Issues page is a great place to start for contribution ideas.
Issues that have been explicitly approved by the maintainers (aligned with the direction of the project)
will be marked with the approved by maintainers
label.
Issues marked good first issue
are an especially great place to start.
Connectors to other tools are another great place to contribute. For details on how, refer to this README.md.
If you have a new/different contribution in mind, we'd love to hear about it! Your input is vital to making sure that Danswer moves in the right direction. Before starting on implementation, please raise a GitHub issue.
And always feel free to message us (Chris Weaver / Yuhong Sun) on Slack / Discord directly about anything at all.
To contribute to this project, please follow the "fork and pull request" workflow. When opening a pull request, mention related issues and feel free to tag relevant maintainers.
Before creating a pull request please make sure that the new changes conform to the formatting and linting requirements. See the Formatting and Linting section for how to run these checks locally.
Our goal is to make contributing as easy as possible. If you run into any issues please don't hesitate to reach out. That way we can help future contributors and users can avoid the same issue.
We also have support channels and generally interesting discussions on our Slack and Discord.
We would love to see you there!
Danswer being a fully functional app, relies on some external software, specifically:
- Postgres (Relational DB)
- Vespa (Vector DB/Search Engine)
- Redis (Cache)
- Nginx (Not needed for development flows generally)
Note: This guide provides instructions to build and run Danswer locally from source with Docker containers providing the above external software. We believe this combination is easier for development purposes. If you prefer to use pre-built container images, we provide instructions on running the full Danswer stack within Docker below.
Be sure to use Python version 3.11. For instructions on installing Python 3.11 on macOS, refer to the CONTRIBUTING_MACOS.md readme.
If using a lower version, modifications will have to be made to the code. If using a higher version, sometimes some libraries will not be available (i.e. we had problems with Tensorflow in the past with higher versions of python).
Currently, we use pip and recommend creating a virtual environment.
For convenience here's a command for it:
edit ~/.zshrc file and add below two lines
eval "$(pyenv init -)"
eval "$(pyenv init --path)"
pyenv install 3.11
pyenv shell 3.11.7
pyenv virtualenv danswer3.11.7
pyenv activate danswer3.11.7
python --version
pyenv virtualenvs
In VS Code CMD+SHIFT+P search for Python:Select Interpreter and select the virtual env name that you have just created or you can directly create a virtual
env from VSCode itself
Install the required python dependencies in vscode terminal where virtualenv is created and activated:
pip install -r danswer/backend/requirements/default.txt
pip install -r danswer/backend/requirements/dev.txt
pip install -r danswer/backend/requirements/ee.txt
pip install -r danswer/backend/requirements/model_server.txt
Install Playwright for Python (headless browser required by the Web Connector)
In the activated Python virtualenv, install Playwright for Python by running:
playwright install
You may have to deactivate and reactivate your virtualenv for playwright
to appear on your path.
Install Node.js and npm for the frontend.
Once the above is done, navigate to danswer/web
run:
npm i --no-audit
You will need Docker installed to run these containers.
First navigate to danswer/deployment/docker_compose
, then start up Postgres/Vespa/Redis with:
docker compose -f docker-compose.dev.yml -p danswer-stack up -d relational_db cache
(index refers to Vespa, relational_db refers to Postgres, and cache refers to Redis)
* If you want to start clean, cleanup the vespa_var_storage and vespa_log_storage folders
export VESPA_VAR_STORAGE=/Users/rajivchodisetti/Documents/repos/darwin-latest-31stAug/vespa_data/var
export VESPA_LOG_STORAGE=/Users/rajivchodisetti/Documents/repos/darwin-latest-31stAug/vespa_data/logs
docker run --detach --name vespa --hostname vespa-container --volume $VESPA_VAR_STORAGE:/opt/vespa/var --volume $VESPA_LOG_STORAGE:/opt/vespa/logs --publish 8081:8081 --publish 19071:19071 vespaengine/vespa:8.277.17
To start the frontend, navigate to danswer/web
and run:
npm run dev
Next, start the model server which runs the local NLP models.
Navigate to danswer/backend
and run:
uvicorn model_server.main:app --reload --port 9000
The first time running Danswer, you will need to run the DB migrations for Postgres. After the first time, this is no longer required unless the DB models change.
Navigate to danswer/backend
and with the venv active, run:
alembic upgrade head
Next, start the task queue which orchestrates the background jobs. Jobs that take more time are run async from the API server.
Still in danswer/backend
, run:
python ./scripts/dev_run_background_jobs.py
To run the backend API server, navigate back to danswer/backend
and run:
AUTH_TYPE=disabled uvicorn danswer.main:app --reload --port 8080
Note: If you need finer logging, add the additional environment variable
LOG_LEVEL=DEBUG
to the relevant services.
You should now have 4 servers running:
- Web server
- Backend API
- Model server
- Background jobs
Now, visit http://localhost:3000
in your browser. You should see the Danswer onboarding wizard where you can connect your external LLM provider to Danswer.
You've successfully set up a local Danswer instance! 🏁
You can run the full Danswer application stack from pre-built images including all external software dependencies.
Navigate to danswer/deployment/docker_compose
and run:
docker compose -f docker-compose.dev.yml -p danswer-stack up -d
After Docker pulls and starts these containers, navigate to http://localhost:3000
to use Danswer.
If you want to make changes to Danswer and run those changes in Docker, you can also build a local version of the Danswer container images that incorporates your changes like so:
docker compose -f docker-compose.dev.yml -p danswer-stack up -d --build
For the backend, you'll need to setup pre-commit hooks (black / reorder-python-imports). First, install pre-commit (if you don't have it already) following the instructions here.
With the virtual environment active, install the pre-commit library with:
pip install pre-commit
Then, from the danswer/backend
directory, run:
pre-commit install
Additionally, we use mypy
for static type checking.
Danswer is fully type-annotated, and we want to keep it that way!
To run the mypy checks manually, run python -m mypy .
from the danswer/backend
directory.
We use prettier
for formatting. The desired version (2.8.8) will be installed via a npm i
from the danswer/web
directory.
To run the formatter, use npx prettier --write .
from the danswer/web
directory.
Please double check that prettier passes before creating a pull request.
Danswer loosely follows the SemVer versioning standard. Major changes are released with a "minor" version bump. Currently we use patch release versions to indicate small feature changes. A set of Docker containers will be pushed automatically to DockerHub with every tag. You can see the containers here.