### Docker Compose Up Output Example Source: https://docs.dify.ai/en/self-host/quick-start/docker-compose Example output showing the status and start time of Dify containers after running `docker compose up -d`. ```bash [+] Running 13/13 ✔ Network docker_ssrf_proxy_network Created 10.0s ✔ Network docker_default Created 0.1s ✔ Container docker-sandbox-1 Started 0.3s ✔ Container docker-db_postgres-1 Healthy 2.8s ✔ Container docker-web-1 Started 0.3s ✔ Container docker-redis-1 Started 0.3s ✔ Container docker-ssrf_proxy-1 Started 0.4s ✔ Container docker-weaviate-1 Started 0.3s ✔ Container docker-worker_beat-1 Started 3.2s ✔ Container docker-api-1 Started 3.2s ✔ Container docker-worker-1 Started 3.2s ✔ Container docker-plugin_daemon-1 Started 3.2s ✔ Container docker-nginx-1 Started 3.4s ``` -------------------------------- ### Clone Example Repository and Setup Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/cloudflare-worker Clone the Dify extension workers repository and copy the example wrangler.toml file to set up your project. ```bash git clone https://github.com/crazywoola/dify-extension-workers.git cp wrangler.toml.example wrangler.toml ``` -------------------------------- ### Web Service Startup Output Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Example output indicating the web service has started successfully and is accessible via localhost. ```text ▲ Next.js 15 - Local: http://localhost:3000 - Network: http://0.0.0.0:3000 ✓ Starting... ✓ Ready in 73ms ``` -------------------------------- ### Example: Retrieving and Converting Data Source: https://docs.dify.ai/en/develop-plugin/features-and-specs/plugin-types/persistent-storage-kv Shows how to retrieve string and JSON data using `get` and then decode/deserialize it for use. ```python # Retrieving string data name_bytes = storage.get("user_name") if name_bytes: name = name_bytes.decode('utf-8') print(f"Retrieved name: {name}") # Retrieving JSON data import json user_data_bytes = storage.get("user_data") if user_data_bytes: user_data = json.loads(user_data_bytes.decode('utf-8')) print(f"User preferences: {user_data['preferences']}") ``` -------------------------------- ### Install Dependencies and Run Locally for Testing Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/cloudflare-worker Install project dependencies and run the API extension locally for testing purposes. ```bash npm install npm run dev ``` -------------------------------- ### Install Dependencies and Run Plugin Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Installs project dependencies and runs the plugin in debug mode. ```bash pip install -r requirements.txt python -m main ``` -------------------------------- ### Self-Hosted Dify Sandbox Setup Source: https://docs.dify.ai/en/use-dify/nodes/code Command to start the sandbox service for secure code execution in a self-hosted Dify environment. Requires Docker. ```bash docker-compose -f docker-compose.middleware.yaml up -d ``` -------------------------------- ### Install Web Dependencies Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Install all necessary project dependencies for the web service using PNPM, ensuring lockfile consistency. ```bash pnpm install --frozen-lockfile ``` -------------------------------- ### Globally Install Dify CLI (Recommended) Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet Installs the Dify plugin scaffold tool globally by moving the binary to the system path. This example shows the process for macOS ARM. ```bash # Rename and move to system path # Example (macOS ARM) mv dify-plugin-darwin-arm64 dify sudo mv dify /usr/local/bin/ dify version ``` -------------------------------- ### Start Dify with Docker Compose Source: https://docs.dify.ai/en/use-dify/tutorials/twitter-chatflow Navigate to the Dify docker directory, copy the environment file, and start Dify services using Docker Compose. ```bash cd dify/docker cp .env.example .env docker compose up -d ``` -------------------------------- ### Docker Compose Ps Output Example Source: https://docs.dify.ai/en/self-host/quick-start/docker-compose Example output from `docker compose ps` indicating that Dify containers are running and healthy. ```bash NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS docker-api-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" api 26 seconds ago Up 22 seconds 5001/tcp docker-db_postgres-1 postgres:15-alpine "docker-entrypoint.s…" db_postgres 26 seconds ago Up 25 seconds (healthy) 5432/tcp docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx 26 seconds ago Up 22 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp docker-plugin_daemon-1 langgenius/dify-plugin-daemon:0.4.1-local "/bin/bash -c /app/e…" plugin_daemon 26 seconds ago Up 22 seconds 0.0.0.0:5003->5003/tcp, :::5003->5003/tcp docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis 26 seconds ago Up 25 seconds (health: starting) 6379/tcp docker-sandbox-1 langgenius/dify-sandbox:0.2.12 "/main" sandbox 26 seconds ago Up 25 seconds (health: starting) docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy 26 seconds ago Up 25 seconds 3128/tcp docker-weaviate-1 semitechnologies/weaviate:1.27.0 "/bin/weaviate --hos…" weaviate 26 seconds ago Up 25 seconds ``` -------------------------------- ### Install Dify CLI on Linux Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-md-exporter Installs the Dify CLI on Linux by downloading the appropriate binary from GitHub releases and making it executable. ```bash # Download appropriate version chmod +x dify-plugin-linux-amd64 mv dify-plugin-linux-amd64 dify sudo mv dify /usr/local/bin/ ``` -------------------------------- ### Install Dify CLI for Linux Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet Installs the Dify plugin scaffold tool on Linux by downloading and making the binary executable. ```bash # Download dify-plugin-linux-amd64 chmod +x dify-plugin-linux-amd64 ./dify-plugin-linux-amd64 version ``` -------------------------------- ### Install Dify CLI on Windows Source: https://docs.dify.ai/en/develop-plugin/getting-started/cli Install the Dify CLI on Windows by downloading the executable, renaming it, and adding it to your PATH. ```bash Download dify-plugin-windows-amd64.exe (or dify-plugin-windows-arm64.exe) from the [Dify Plugin Daemon releases page](https://github.com/langgenius/dify-plugin-daemon/releases), rename it to dify.exe, and add its folder to your PATH. ``` -------------------------------- ### Install Dependencies and Deploy API Extension Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/cloudflare-worker Install project dependencies using npm and deploy the API extension to Cloudflare Workers. ```bash npm install npm run deploy ``` -------------------------------- ### Install Dependencies for Migration Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration Installs the necessary Python packages for the Weaviate migration script. It's recommended to do this in a temporary virtual environment. ```bash cd /path/to/dify python3 -m venv weaviate_migration_env source weaviate_migration_env/bin/activate pip install weaviate-client requests ``` -------------------------------- ### Install Dify CLI on Linux Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Installs the Dify CLI on Linux by downloading and moving the binary. Ensure you select the correct binary for your architecture. ```bash chmod +x dify-plugin-linux-amd64 sudo mv dify-plugin-linux-amd64 /usr/local/bin/dify ``` -------------------------------- ### Start Middlewares with Docker Compose Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code This command starts the required middleware services for Dify backend. Ensure you have configured the .env file if not using default PostgreSQL and Weaviate. ```bash cd docker cp envs/middleware.env.example middleware.env # Change DB_TYPE or COMPOSE_PROFILES in middleware.env if you are not using PostgreSQL and Weaviate. docker compose --env-file middleware.env -f docker-compose.middleware.yaml -p dify up -d ``` -------------------------------- ### Navigate to API Directory Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Change the current directory to the 'api' folder to begin the setup process. ```bash cd api ``` -------------------------------- ### Start Web Service Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Launch the web service application using PNPM. ```bash pnpm start ``` -------------------------------- ### Start Worker Service on Windows Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code This command is used to start the Worker service on Windows systems. It utilizes a solo concurrency model and disables gossip and mingle for a simpler setup. ```bash uv run celery -A app.celery worker -P solo --without-gossip --without-mingle --loglevel INFO -Q dataset,dataset_summary,priority_dataset,priority_pipeline,pipeline,mail,ops_trace,app_deletion,plugin,workflow_storage,conversation,workflow,schedule_poller,schedule_executor,triggered_workflow_dispatcher,trigger_refresh_executor,retention,workflow_based_app_execution ``` -------------------------------- ### Navigate to Plugin Directory Source: https://docs.dify.ai/en/develop-plugin/getting-started/cli After initialization, change into the newly created plugin directory. ```bash cd hello-world ``` -------------------------------- ### Initialize Dify Plugin Project Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-a-slack-bot-plugin Use this command to set up your plugin development environment. Follow the prompts to provide project details and select the 'extension' template, granting necessary permissions for Apps and Endpoints. ```bash dify plugin init ``` -------------------------------- ### Configure WEAVIATE_GRPC_ENDPOINT for Docker Compose Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration Example of setting the WEAVIATE_GRPC_ENDPOINT environment variable within a Docker Compose setup for internal Weaviate connections. ```bash WEAVIATE_GRPC_ENDPOINT=weaviate:50051 ``` -------------------------------- ### Logging Model Calls in Agent Strategy Plugin Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/agent-strategy-plugin This example shows how to log the start and end of a model call within an Agent Strategy Plugin. It uses create_log_message and finish_log_message to track progress and results. ```python model_log = self.create_log_message( label=f"{params.model.model} Thought", data={}, metadata={"start_at": model_started_at, "provider": params.model.provider}, status=ToolInvokeMessage.LogMessage.LogStatus.START, ) yield model_log self.session.model.llm.invoke(...) yield self.finish_log_message( log=model_log, data={ "output": response, "tool_name": tool_call_names, "tool_input": tool_call_inputs, }, metadata={ "started_at": model_started_at, "finished_at": time.perf_counter(), "elapsed_time": time.perf_counter() - model_started_at, "provider": params.model.provider, }, ) ``` -------------------------------- ### Initialize Ngrok and Add Auth Token Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/api-extension Run these commands after downloading and extracting Ngrok to initialize it and authenticate with your token. ```shell unzip /path/to/ngrok.zip ./ngrok config add-authtoken your-token ``` -------------------------------- ### Example Quick-Reply Buttons Source: https://docs.dify.ai/en/use-dify/nodes/template Demonstrates how to create quick-reply buttons for user interaction. Buttons can send messages or open links. ```html Would you like to see more options? ``` -------------------------------- ### Install or Update Weaviate Client Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration Ensure the weaviate-client v4 is installed. For Docker installations, pull the latest Dify version. For source installations, uninstall the old client and install the specific v4 version. ```bash # For Docker installations, ensure you're running the correct Dify version docker compose pull docker compose down docker compose up -d # For source installations pip uninstall weaviate-client pip install weaviate-client==4.17.0 ``` -------------------------------- ### Install Dependencies with uv Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Install project dependencies, including development dependencies, using the uv package manager. For macOS, ensure libmagic is installed via Homebrew. ```bash uv sync --dev ``` -------------------------------- ### Dify Plugin Initialization Prompts Source: https://docs.dify.ai/en/develop-plugin/getting-started/cli Example of the interactive prompts during Dify plugin initialization, including project name, author, description, and language selection. ```bash Edit profile of the plugin Plugin name (press Enter to next step): hello-world Author (press Enter to next step): langgenius Description (press Enter to next step): hello world example Repository URL (Optional) (press Enter to next step): Repository URL (Optional) Enable multilingual README: [✔] English is required by default Languages to generate: English: [✔] (required) → 简体中文 (Simplified Chinese): [✔] 日本語 (Japanese): [✘] Português (Portuguese - Brazil): [✘] Controls: ↑/↓ Navigate • Space/Tab Toggle selection • Enter Next step ``` -------------------------------- ### Copy Environment File Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Copies the example environment file to be used for local development. ```bash cp .env.example .env ``` -------------------------------- ### Verify Dify CLI Installation Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Checks if the Dify CLI has been installed correctly by displaying its version. ```bash dify version ``` -------------------------------- ### Install PNPM with NPM Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Use this command to install the PNPM package manager globally using npm. ```bash npm i -g pnpm ``` -------------------------------- ### Install Plugin Dependencies Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-md-exporter Installs all necessary Python packages required for the plugin to run, as listed in the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Copy Opensearch Environment Configuration Source: https://docs.dify.ai/en/self-host/platform-guides/dify-premium Copy the example environment file for Opensearch to use it for configuration. ```bash cd /dify cp envs/vectorstores/opensearch.env.example envs/vectorstores/opensearch.env ``` -------------------------------- ### Start Dify Services After Upgrade Source: https://docs.dify.ai/en/self-host/platform-guides/dify-premium Pull the latest Docker images and start Dify services in detached mode. ```bash docker compose pull docker compose -f docker-compose.yaml -f docker-compose.override.yaml up -d ``` -------------------------------- ### Copy Environment Configuration Source: https://docs.dify.ai/en/self-host/quick-start/docker-compose Copies the example environment file to `.env`. This file is used to configure Dify's deployment settings. You can customize this file later. ```bash cp .env.example .env ``` -------------------------------- ### Complete Dify Weaviate Configuration Example Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration A comprehensive example of environment variables for configuring Dify to connect to Weaviate, including HTTP endpoint, API key, gRPC settings, and batch import size. ```bash # docker/.env or environment configuration VECTOR_STORE=weaviate # HTTP Endpoint (required) WEAVIATE_ENDPOINT=http://weaviate:8080 # Authentication (if enabled on your Weaviate instance) WEAVIATE_API_KEY=your-secret-api-key # gRPC Configuration (recommended for performance) WEAVIATE_GRPC_ENABLED=true WEAVIATE_GRPC_ENDPOINT=weaviate:50051 # Batch Import Settings WEAVIATE_BATCH_SIZE=100 ``` -------------------------------- ### Initialize Bundle Plugin Project (Global CLI) Source: https://docs.dify.ai/en/develop-plugin/features-and-specs/advanced-development/bundle Run this command if the Dify CLI binary is named 'dify' and is available in your system's PATH. It initializes a new Bundle plugin project. ```bash dify bundle init ``` -------------------------------- ### Install FFmpeg on CentOS Source: https://docs.dify.ai/en/self-host/troubleshooting/integrations Install FFmpeg on CentOS using yum. This is required for OpenAI TTS audio stream segmentation. ```bash sudo yum install epel-release sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm sudo yum update sudo yum install ffmpeg ffmpeg-devel ``` -------------------------------- ### Initialize Bundle Plugin Project (macOS ARM) Source: https://docs.dify.ai/en/develop-plugin/features-and-specs/advanced-development/bundle Use this command to start a new Bundle plugin project on macOS with an ARM processor. Ensure you have the Dify plugin scaffolding tool. ```bash ./dify-plugin-darwin-arm64 bundle init ``` -------------------------------- ### Install FFmpeg on Ubuntu Source: https://docs.dify.ai/en/self-host/troubleshooting/integrations Install FFmpeg on Ubuntu using apt-get. This is required for OpenAI TTS audio stream segmentation. ```bash sudo apt-get update sudo apt-get install ffmpeg ``` -------------------------------- ### Compare Environment Files Source: https://docs.dify.ai/en/self-host/platform-guides/dify-premium Compare the main .env file with its example and check for new variables in optional environment templates. ```bash diff /dify/.env /dify/.env.example find /dify/envs -name "*.env" -print | while read -r env_file; do diff "$env_file" "$env_file.example" done ``` -------------------------------- ### Install FFmpeg on macOS Source: https://docs.dify.ai/en/self-host/troubleshooting/integrations Install FFmpeg using Homebrew on macOS. This is required for OpenAI TTS audio stream segmentation. ```bash brew install ffmpeg ``` -------------------------------- ### Install FastAPI Dependencies Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/api-extension Install the necessary Python packages for FastAPI and Uvicorn. This command should be run in your project's virtual environment. ```bash pip install fastapi[all] uvicorn ``` -------------------------------- ### Initialize Git and Push Plugin Source Source: https://docs.dify.ai/en/develop-plugin/publishing/marketplace-listing/release-to-individual-github-repo Initialize a Git repository in your plugin project and push the source code to a remote GitHub repository. Ensure your GitHub handle matches the author field in manifest.yaml. ```bash cd your_plugin_project git init git add . git commit -m "initial commit" git branch -M main git remote add origin https://github.com//.git git push -u origin main ``` -------------------------------- ### Initialize a New Dify Plugin Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet Creates a new plugin project using the Dify CLI. Follow the prompts to configure basic plugin information. ```bash ./dify plugin init ``` -------------------------------- ### Initialize a New Dify Plugin Project Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Creates a new Dify plugin project. Follow the prompts to name your plugin and select its type. ```bash dify plugin init ```