Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 11, 2024
1 parent a224e22 commit 53d36c8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,44 @@
SECRET_KEY=${secret_key}" .env
```

4. Create environment.
4. Prepare Python environment

Dify API service uses [Poetry](https://python-poetry.org/docs/) to manage dependencies. You can execute `poetry shell` to activate the environment.
Dify API services requires Python 3.11 or 3.12, and the [Poetry](https://python-poetry.org/docs/) for dependency
management.
- To install Poetry, please refer to
the [Poetry's installation guide](https://python-poetry.org/docs/#installation).
- Run `poetry env use 3.11` to switch to the Python version for Poetry, please refer the usage of `poetry env use`
command in [Poetry docs](https://python-poetry.org/docs/managing-environments/#switching-between-environments).
- Run `poetry shell` to activate the shell environment with Poetry support.

5. Install dependencies

```bash
cd api
poetry env use 3.11
poetry install
```

In case of contributors missing to update dependencies for `pyproject.toml`, you can perform the following shell instead.

```bash
poetry shell # activate current environment
poetry add $(cat requirements.txt) # install dependencies of production and update pyproject.toml
poetry add $(cat requirements-dev.txt) --group dev # install dependencies of development and update pyproject.toml
```

6. Run migrate
6. Run db migration

Before the first launch, migrate the database to the latest version.

```bash
poetry run python -m flask db upgrade
```

7. Start backend
7. Start api service

```bash
poetry run python -m flask run --host 0.0.0.0 --port=5001 --debug
```

8. Start Dify [web](../web) service.

9. Setup your application by visiting `http://localhost:3000`...
10. If you need to handle and debug the async tasks (e.g. dataset importing and documents indexing), please start the worker service.

10. Start the worker service, if you need to handle and debug the async tasks (e.g. dataset importing and documents
indexing), please start the worker service.

```bash
poetry run python -m celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace,app_deletion
Expand Down

0 comments on commit 53d36c8

Please sign in to comment.