Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Dify Backend API
  2. ## Usage
  3. 1. Start the docker-compose stack
  4. The backend require some middleware, including PostgreSQL, Redis, and Weaviate, which can be started together using `docker-compose`.
  5. ```bash
  6. cd ../docker
  7. docker-compose -f docker-compose.middleware.yaml -p dify up -d
  8. cd ../api
  9. ```
  10. 2. Copy `.env.example` to `.env`
  11. 3. Generate a `SECRET_KEY` in the `.env` file.
  12. ```bash
  13. sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env
  14. ```
  15. 4. If you use Anaconda, create a new environment and activate it
  16. ```bash
  17. conda create --name dify python=3.10
  18. conda activate dify
  19. ```
  20. 5. Install dependencies
  21. ```bash
  22. pip install -r requirements.txt
  23. ```
  24. 6. Run migrate
  25. Before the first launch, migrate the database to the latest version.
  26. ```bash
  27. flask db upgrade
  28. ```
  29. ⚠️ If you encounter problems with jieba, for example
  30. ```
  31. > flask db upgrade
  32. Error: While importing 'app', an ImportError was raised:
  33. ```
  34. Please run the following command instead.
  35. ```
  36. pip install -r requirements.txt --upgrade --force-reinstall
  37. ```
  38. 7. Start backend:
  39. ```bash
  40. flask run --host 0.0.0.0 --port=5001 --debug
  41. ```
  42. 8. Setup your application by visiting http://localhost:5001/console/api/setup or other apis...
  43. 9. If you need to debug local async processing, please start the worker service by running
  44. `celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail`.
  45. The started celery app handles the async tasks, e.g. dataset importing and documents indexing.
  46. ## Testing
  47. 1. Install dependencies for both the backend and the test environment
  48. ```bash
  49. pip install -r requirements.txt -r requirements-dev.txt
  50. ```
  51. 2. Run the tests locally with mocked system environment variables in `tool.pytest_env` section in `pyproject.toml`
  52. ```bash
  53. dev/pytest/pytest_all_tests.sh
  54. ```