You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Yeuoly e852a21634
Feat/workflow phase2 (#4687)
1 year ago
..
.vscode chore: replace outdated config in vscode debug settings (#3106) 1 year ago
constants Feat/chat custom disclaimer (#4306) 1 year ago
controllers Feat/workflow phase2 (#4687) 1 year ago
core Feat/workflow phase2 (#4687) 1 year ago
docker improvement: introduce Super-Linter actions to check style for shell script, dockerfile and yaml files (#1966) 1 year ago
events Feat/workflow phase2 (#4687) 1 year ago
extensions fix the wrong env variable AZURE_BLOB_CONTAINER_NAME (#4455) 1 year ago
fields Feat/workflow phase2 (#4687) 1 year ago
libs Feat/workflow phase2 (#4687) 1 year ago
migrations Feat/workflow phase2 (#4687) 1 year ago
models Feat/workflow phase2 (#4687) 1 year ago
schedule Feat/dify rag (#2528) 1 year ago
services Feat/workflow phase2 (#4687) 1 year ago
tasks Knowledge optimization (#3755) 1 year ago
templates fix: email template style (#1914) 1 year ago
tests Feat/workflow phase2 (#4687) 1 year ago
.dockerignore build: fix .dockerignore file (#800) 2 years ago
.env.example allow to config max segmentation tokens length for RAG document using environment variable (#4375) 1 year ago
Dockerfile improvement: speed up dependency installation in docker image rebuilds by mounting cache layer (#3218) 1 year ago
README.md test: add scripts for running tests on api module both locally and CI jobs (#3497) 1 year ago
app.py refactor: config file (#3852) 1 year ago
commands.py add qdrant metadata.doc_id index (#4559) 1 year ago
config.py fix: the date is incorrect if the db field is timestamp and the TZ is not the UTC (#4624) 1 year ago
pyproject.toml improve: extract method for safe loading yaml file and avoid using PyYaml's FullLoader (#4031) 1 year ago
requirements-dev.txt feat: support LLM jinja2 template prompt (#3968) 1 year ago
requirements.txt Support for Vertex AI (#4586) 1 year ago

README.md

Dify Backend API

Usage

  1. Start the docker-compose stack

The backend require some middleware, including PostgreSQL, Redis, and Weaviate, which can be started together using docker-compose.

   cd ../docker
   docker-compose -f docker-compose.middleware.yaml -p dify up -d
   cd ../api
  1. Copy .env.example to .env
  2. Generate a SECRET_KEY in the .env file.
   sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env
  1. If you use Anaconda, create a new environment and activate it bash conda create --name dify python=3.10 conda activate dify
  2. Install dependencies bash pip install -r requirements.txt
  3. Run migrate

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

   flask db upgrade

⚠️ If you encounter problems with jieba, for example

   > flask db upgrade
   Error: While importing 'app', an ImportError was raised:

Please run the following command instead.

   pip install -r requirements.txt --upgrade --force-reinstall
  1. Start backend: bash flask run --host 0.0.0.0 --port=5001 --debug
  2. Setup your application by visiting http://localhost:5001/console/api/setup or other apis…
  3. If you need to debug local async processing, please start the worker service by running celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail. The started celery app handles the async tasks, e.g. dataset importing and documents indexing.

Testing

  1. Install dependencies for both the backend and the test environment

    pip install -r requirements.txt -r requirements-dev.txt
    
  2. Run the tests locally with mocked system environment variables in tool.pytest_env section in pyproject.toml

    dev/pytest/pytest_all_tests.sh