mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Improve Khoj with DB setup instructions in the Django app readme (for now)
This commit is contained in:
parent
f212cc7174
commit
ef24485ada
1 changed files with 40 additions and 12 deletions
|
@ -17,16 +17,26 @@ docker-compose up
|
|||
|
||||
## Setup (Local)
|
||||
|
||||
### Install dependencies
|
||||
### Install Postgres (with PgVector)
|
||||
|
||||
#### MacOS
|
||||
- Install the [Postgres.app](https://postgresapp.com/).
|
||||
|
||||
#### Debian, Ubuntu
|
||||
From [official instructions](https://wiki.postgresql.org/wiki/Apt)
|
||||
|
||||
```bash
|
||||
pip install -e '.[dev]'
|
||||
sudo apt install -y postgresql-common
|
||||
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
|
||||
sudo apt install postgres-16 postgresql-16-pgvector
|
||||
```
|
||||
|
||||
### Setup the database
|
||||
#### Windows
|
||||
- Use the [recommended installer](https://www.postgresql.org/download/windows/)
|
||||
|
||||
1. Ensure you have Postgres installed. For MacOS, you can use [Postgres.app](https://postgresapp.com/).
|
||||
2. If you're not using Postgres.app, you may have to install the pgvector extension manually. You can find the instructions [here](https://github.com/pgvector/pgvector#installation). If you're using Postgres.app, you can skip this step. Reproduced instructions below for convenience.
|
||||
#### From Source
|
||||
1. Follow instructions to [Install Postgres](https://www.postgresql.org/download/)
|
||||
2. Follow instructions to [Install PgVector](https://github.com/pgvector/pgvector#installation) in case you need to manually install it. Reproduced instructions below for convenience.
|
||||
|
||||
```bash
|
||||
cd /tmp
|
||||
|
@ -35,32 +45,50 @@ cd pgvector
|
|||
make
|
||||
make install # may need sudo
|
||||
```
|
||||
3. Create a database
|
||||
|
||||
### Create the khoj database
|
||||
### Create the Khoj database
|
||||
|
||||
#### MacOS
|
||||
```bash
|
||||
createdb khoj -U postgres
|
||||
```
|
||||
|
||||
### Make migrations
|
||||
#### Debian, Ubuntu
|
||||
```bash
|
||||
sudo -u postgres createdb khoj
|
||||
```
|
||||
|
||||
This command will create the migrations for the database app. This command should be run whenever a new model is added to the database app or an existing model is modified (updated or deleted).
|
||||
- [Optional] To set default postgres user's password
|
||||
- Execute `ALTER USER postgres PASSWORD 'my_secure_password';` using `psql`
|
||||
- Run `export $POSTGRES_PASSWORD=my_secure_password` in your terminal for Khoj to use it later
|
||||
|
||||
### Install Khoj
|
||||
|
||||
```bash
|
||||
pip install -e '.[dev]'
|
||||
```
|
||||
|
||||
### Make Khoj DB migrations
|
||||
|
||||
This command will create the migrations for the database app. This command should be run whenever a new db model is added to the database app or an existing db model is modified (updated or deleted).
|
||||
|
||||
```bash
|
||||
python3 src/manage.py makemigrations
|
||||
```
|
||||
|
||||
### Run migrations
|
||||
### Run Khoj DB migrations
|
||||
|
||||
This command will run any pending migrations in your application.
|
||||
```bash
|
||||
python3 src/manage.py migrate
|
||||
```
|
||||
|
||||
### Run the server
|
||||
### Start Khoj Server
|
||||
|
||||
While we're using Django for the ORM, we're still using the FastAPI server for the API. This command automatically scaffolds the Django application in the backend.
|
||||
|
||||
*Note: Anonymous mode bypasses authentication for local, single-user usage.*
|
||||
|
||||
```bash
|
||||
python3 src/khoj/main.py
|
||||
python3 src/khoj/main.py --anonymous-mode
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue