├── .env ├── .gitignore ├── LICENSE ├── README.md ├── config ├── api.env ├── middleware.env └── worker.env ├── docker-compose.png ├── docker-compose.yaml ├── nginx.conf ├── preview.jpg └── title-generate.php /.env: -------------------------------------------------------------------------------- 1 | DOCKER_DIFY_API_IMAGE=langgenius/dify-api:0.6.4 2 | DOCKER_DIFY_WEB_IMAGE=langgenius/dify-web:0.6.4 3 | DOCKER_DIFY_SANDBOX_IMAGE=langgenius/dify-sandbox:latest 4 | DOCKER_VECTOR_WEAVIATE_IMAGE=semitechnologies/weaviate:1.19.0 5 | DOCKER_VECTOR_QDRANT_IMAGE=langgenius/qdrant:v1.7.3 6 | DOCKER_POSTGRES_IMAGE=postgres:15-alpine 7 | DOCKER_REDIS_IMAGE=redis:6-alpine 8 | DOCKER_NGINX_IMAGE=nginx:latest 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | volumes 2 | wordpress 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dify with WordPress 2 | 3 | > Enabling various applications to be AI-enabled or used by AI. (1st/100th) 4 | 5 | ![](./preview.jpg) 6 | 7 | - More "+AI" Cases: https://github.com/soulteary/100-apps-plus-AI 8 | 9 | - Article: https://soulteary.com/2024/04/24/use-dify-and-moonshot-api-to-build-your-ai-workflow-make-non-ai-applications-goto-ai.html 10 | 11 | 12 | ## Credits 13 | 14 | - https://github.com/langgenius/dify 15 | - https://github.com/soulteary/docker-wp-api 16 | -------------------------------------------------------------------------------- /config/api.env: -------------------------------------------------------------------------------- 1 | # Startup mode, 'api' starts the API server. 2 | MODE=api 3 | # The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` 4 | LOG_LEVEL=INFO 5 | # A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`. 6 | SECRET_KEY=sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U 7 | # The base URL of console application web frontend, refers to the Console base URL of WEB service if console domain is 8 | # different from api or web app domain. 9 | # example=http://cloud.dify.ai 10 | CONSOLE_WEB_URL='' 11 | # Password for admin user initialization. 12 | # If left unset, admin user will not be prompted for a password when creating the initial admin account. 13 | INIT_PASSWORD='' 14 | # The base URL of console application api server, refers to the Console base URL of WEB service if console domain is 15 | # different from api or web app domain. 16 | # example=http://cloud.dify.ai 17 | CONSOLE_API_URL='' 18 | # The URL prefix for Service API endpoints, refers to the base URL of the current API service if api domain is 19 | # different from console domain. 20 | # example=http://api.dify.ai 21 | SERVICE_API_URL='' 22 | # The URL prefix for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from 23 | # console or api domain. 24 | # example=http://udify.app 25 | APP_WEB_URL='' 26 | # File preview or download Url prefix. 27 | # used to display File preview or download Url to the front-end or as Multi-model inputs; 28 | # Url is signed and has expiration time. 29 | FILES_URL='' 30 | # When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed. 31 | MIGRATION_ENABLED='true' 32 | 33 | # Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins. 34 | WEB_API_CORS_ALLOW_ORIGINS='*' 35 | # Specifies the allowed origins for cross-origin requests to the console API, e.g. https://cloud.dify.ai or * for all origins. 36 | CONSOLE_CORS_ALLOW_ORIGINS='*' 37 | # CSRF Cookie settings 38 | # Controls whether a cookie is sent with cross-site requests, 39 | # providing some protection against cross-site request forgery attacks 40 | # 41 | # Default=`SameSite=Lax, Secure=false, HttpOnly=true` 42 | # This default configuration supports same-origin requests using either HTTP or HTTPS, 43 | # but does not support cross-origin requests. It is suitable for local debugging purposes. 44 | # 45 | # If you want to enable cross-origin support, 46 | # you must use the HTTPS protocol and set the configuration to `SameSite=None, Secure=true, HttpOnly=true`. 47 | 48 | # The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled. 49 | SENTRY_DSN='' 50 | # The sample rate for Sentry events. Default=`1.0` 51 | SENTRY_TRACES_SAMPLE_RATE=1.0 52 | # The sample rate for Sentry profiles. Default=`1.0` 53 | SENTRY_PROFILES_SAMPLE_RATE=1.0 54 | 55 | # The sandbox service endpoint. 56 | CODE_EXECUTION_ENDPOINT="http://sandbox:8194" 57 | CODE_EXECUTION_API_KEY=dify-sandbox 58 | CODE_MAX_NUMBER=9223372036854775807 59 | CODE_MIN_NUMBER=-9223372036854775808 60 | CODE_MAX_STRING_LENGTH=80000 61 | TEMPLATE_TRANSFORM_MAX_LENGTH=80000 62 | CODE_MAX_STRING_ARRAY_LENGTH=30 63 | CODE_MAX_OBJECT_ARRAY_LENGTH=30 64 | CODE_MAX_NUMBER_ARRAY_LENGTH=1000 65 | -------------------------------------------------------------------------------- /config/middleware.env: -------------------------------------------------------------------------------- 1 | # The configurations of postgres database connection. 2 | # It is consistent with the configuration in the 'db' service below. 3 | DB_USERNAME=postgres 4 | DB_PASSWORD=difyai123456 5 | DB_HOST=db 6 | DB_PORT=5432 7 | DB_DATABASE=dify 8 | # The configurations of redis connection. 9 | # It is consistent with the configuration in the 'redis' service below. 10 | REDIS_HOST=redis 11 | REDIS_PORT=6379 12 | REDIS_USERNAME='' 13 | REDIS_PASSWORD=difyai123456 14 | REDIS_USE_SSL='false' 15 | # use redis db 0 for redis cache 16 | REDIS_DB=0 17 | REDIS_USE_SSL='false' 18 | 19 | # The configurations of celery broker. 20 | # Use redis as the broker, and redis db 1 for celery broker. 21 | CELERY_BROKER_URL=redis://:difyai123456@redis:6379/1 22 | 23 | # The type of storage to use for storing user files. Supported values are `local` and `s3` and `azure-blob`, Default=`local` 24 | STORAGE_TYPE=local 25 | # The path to the local storage directory, the directory relative the root path of API service codes or absolute path. Default=`storage` or `/home/john/storage`. 26 | # only available when STORAGE_TYPE is `local`. 27 | STORAGE_LOCAL_PATH=storage 28 | # The S3 storage configurations, only available when STORAGE_TYPE is `s3`. 29 | S3_ENDPOINT='https://xxx.r2.cloudflarestorage.com' 30 | S3_BUCKET_NAME='difyai' 31 | S3_ACCESS_KEY='ak-difyai' 32 | S3_SECRET_KEY='sk-difyai' 33 | S3_REGION='us-east-1' 34 | 35 | # The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`. 36 | AZURE_BLOB_ACCOUNT_NAME='difyai' 37 | AZURE_BLOB_ACCOUNT_KEY='difyai' 38 | AZURE_BLOB_CONTAINER_NAME='difyai-container' 39 | AZURE_BLOB_ACCOUNT_URL='https://.blob.core.windows.net' 40 | 41 | # The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`. 42 | VECTOR_STORE=weaviate 43 | # The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`. 44 | WEAVIATE_ENDPOINT=http://weaviate:8080 45 | # The Weaviate API key. 46 | WEAVIATE_API_KEY=WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih 47 | 48 | # The Qdrant endpoint URL. Only available when VECTOR_STORE is `qdrant`. 49 | QDRANT_URL=http://qdrant:6333 50 | # The Qdrant API key. 51 | QDRANT_API_KEY=difyai123456 52 | # The Qdrant clinet timeout setting. 53 | QDRANT_CLIENT_TIMEOUT=20 54 | 55 | # Milvus configuration Only available when VECTOR_STORE is `milvus`. 56 | # The milvus host. 57 | MILVUS_HOST=127.0.0.1 58 | # The milvus host. 59 | MILVUS_PORT=19530 60 | # The milvus username. 61 | MILVUS_USER=root 62 | # The milvus password. 63 | MILVUS_PASSWORD=Milvus 64 | # The milvus tls switch. 65 | MILVUS_SECURE='false' 66 | 67 | # Mail configuration, support=resend, smtp 68 | MAIL_TYPE='' 69 | # default send from email address, if not specified 70 | MAIL_DEFAULT_SEND_FROM='YOUR EMAIL FROM (eg=no-reply )' 71 | SMTP_SERVER='' 72 | SMTP_PORT=587 73 | SMTP_USERNAME='' 74 | SMTP_PASSWORD='' 75 | SMTP_USE_TLS='true' 76 | 77 | # the api-key for resend (https://resend.com) 78 | RESEND_API_KEY='' 79 | RESEND_API_URL=https://api.resend.com 80 | -------------------------------------------------------------------------------- /config/worker.env: -------------------------------------------------------------------------------- 1 | # Startup mode, 'worker' starts the Celery worker for processing the queue. 2 | MODE=worker 3 | # The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` 4 | LOG_LEVEL=INFO 5 | # A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`. 6 | # same as the API service 7 | SECRET_KEY=sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U 8 | 9 | # relyt configurations 10 | RELYT_HOST=db 11 | RELYT_PORT=5432 12 | RELYT_USER=postgres 13 | RELYT_PASSWORD=difyai123456 14 | RELYT_DATABASE=postgres 15 | -------------------------------------------------------------------------------- /docker-compose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soulteary/dify-with-wordpress/3f48fd9b2f56f43754ded758c3344d5ecdd8ead5/docker-compose.png -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | # API service 4 | api: 5 | image: langgenius/dify-api:0.6.4 6 | restart: always 7 | env_file: 8 | - ./config/api.env 9 | - ./config/middleware.env 10 | depends_on: 11 | - db 12 | - redis 13 | volumes: 14 | # Mount the storage directory to the container, for storing user files. 15 | - ./volumes/app/storage:/app/api/storage 16 | # uncomment to expose dify-api port to host 17 | # ports: 18 | # - "5001:5001" 19 | 20 | # worker service 21 | # The Celery worker for processing the queue. 22 | worker: 23 | image: langgenius/dify-api:0.6.4 24 | restart: always 25 | env_file: 26 | - ./config/worker.env 27 | - ./config/middleware.env 28 | depends_on: 29 | - db 30 | - redis 31 | volumes: 32 | # Mount the storage directory to the container, for storing user files. 33 | - ./volumes/app/storage:/app/api/storage 34 | 35 | # Frontend web application. 36 | web: 37 | image: langgenius/dify-web:0.6.4 38 | restart: always 39 | environment: 40 | EDITION: SELF_HOSTED 41 | # The base URL of console application api server, refers to the Console base URL of WEB service if console domain is 42 | # different from api or web app domain. 43 | # example: http://cloud.dify.ai 44 | CONSOLE_API_URL: '' 45 | # The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from 46 | # console or api domain. 47 | # example: http://udify.app 48 | APP_API_URL: '' 49 | # The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled. 50 | SENTRY_DSN: '' 51 | # uncomment to expose dify-web port to host 52 | # ports: 53 | # - "3000:3000" 54 | 55 | # The postgres database. 56 | db: 57 | image: postgres:15-alpine 58 | restart: always 59 | environment: 60 | PGUSER: postgres 61 | # The password for the default postgres user. 62 | POSTGRES_PASSWORD: difyai123456 63 | # The name of the default postgres database. 64 | POSTGRES_DB: dify 65 | # postgres data directory 66 | PGDATA: /var/lib/postgresql/data/pgdata 67 | volumes: 68 | - ./volumes/db/data:/var/lib/postgresql/data 69 | # uncomment to expose db(postgresql) port to host 70 | # ports: 71 | # - "5432:5432" 72 | healthcheck: 73 | test: [ "CMD", "pg_isready" ] 74 | interval: 1s 75 | timeout: 3s 76 | retries: 30 77 | 78 | # The redis cache. 79 | redis: 80 | image: redis:6-alpine 81 | restart: always 82 | volumes: 83 | # Mount the redis data directory to the container. 84 | - ./volumes/redis/data:/data 85 | # Set the redis password when startup redis server. 86 | command: redis-server --requirepass difyai123456 87 | healthcheck: 88 | test: [ "CMD", "redis-cli", "ping" ] 89 | # uncomment to expose redis port to host 90 | # ports: 91 | # - "6379:6379" 92 | 93 | # The Weaviate vector store. 94 | weaviate: 95 | image: semitechnologies/weaviate:1.19.0 96 | restart: always 97 | volumes: 98 | # Mount the Weaviate data directory to the container. 99 | - ./volumes/weaviate:/var/lib/weaviate 100 | environment: 101 | # The Weaviate configurations 102 | # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information. 103 | QUERY_DEFAULTS_LIMIT: 25 104 | AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false' 105 | PERSISTENCE_DATA_PATH: '/var/lib/weaviate' 106 | DEFAULT_VECTORIZER_MODULE: 'none' 107 | CLUSTER_HOSTNAME: 'node1' 108 | AUTHENTICATION_APIKEY_ENABLED: 'true' 109 | AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih' 110 | AUTHENTICATION_APIKEY_USERS: 'hello@dify.ai' 111 | AUTHORIZATION_ADMINLIST_ENABLED: 'true' 112 | AUTHORIZATION_ADMINLIST_USERS: 'hello@dify.ai' 113 | # uncomment to expose weaviate port to host 114 | # ports: 115 | # - "8080:8080" 116 | 117 | # The DifySandbox 118 | sandbox: 119 | image: langgenius/dify-sandbox:latest 120 | restart: always 121 | cap_add: 122 | # Why is sys_admin permission needed? 123 | # https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-16.-why-is-sys_admin-permission-needed 124 | - SYS_ADMIN 125 | environment: 126 | # The DifySandbox configurations 127 | API_KEY: dify-sandbox 128 | GIN_MODE: release 129 | WORKER_TIMEOUT: 15 130 | 131 | # Qdrant vector store. 132 | # uncomment to use qdrant as vector store. 133 | # (if uncommented, you need to comment out the weaviate service above, 134 | # and set VECTOR_STORE to qdrant in the api & worker service.) 135 | # qdrant: 136 | # image: langgenius/qdrant:v1.7.3 137 | # restart: always 138 | # volumes: 139 | # - ./volumes/qdrant:/qdrant/storage 140 | # environment: 141 | # QDRANT_API_KEY: 'difyai123456' 142 | # # uncomment to expose qdrant port to host 143 | # # ports: 144 | # # - "6333:6333" 145 | 146 | # The nginx reverse proxy. 147 | # used for reverse proxying the API service and Web service. 148 | nginx: 149 | image: nginx:latest 150 | restart: always 151 | volumes: 152 | - ./nginx.conf:/etc/nginx/nginx.conf 153 | depends_on: 154 | - api 155 | - web 156 | ports: 157 | - "8082:80" 158 | #- "443:443" 159 | 160 | 161 | wordpress: 162 | image: soulteary/wp-api:6.5.2-sqlite 163 | restart: always 164 | ports: 165 | - 8083:80 166 | volumes: 167 | - ./wordpress:/var/www/html 168 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes auto; 3 | 4 | error_log /var/log/nginx/error.log notice; 5 | pid /var/run/nginx.pid; 6 | 7 | events { 8 | worker_connections 1024; 9 | } 10 | 11 | http { 12 | include /etc/nginx/mime.types; 13 | default_type application/octet-stream; 14 | 15 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 16 | '$status $body_bytes_sent "$http_referer" ' 17 | '"$http_user_agent" "$http_x_forwarded_for"'; 18 | 19 | access_log /var/log/nginx/access.log main; 20 | 21 | sendfile on; 22 | keepalive_timeout 65; 23 | client_max_body_size 15M; 24 | 25 | server { 26 | listen 80; 27 | server_name _; 28 | 29 | proxy_set_header Host $host; 30 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 31 | proxy_set_header X-Forwarded-Proto $scheme; 32 | proxy_http_version 1.1; 33 | proxy_set_header Connection ""; 34 | proxy_buffering off; 35 | proxy_read_timeout 3600s; 36 | proxy_send_timeout 3600s; 37 | 38 | location @backend { 39 | proxy_pass http://api:5001; 40 | } 41 | 42 | location @frontend { 43 | proxy_pass http://web:3000; 44 | } 45 | 46 | location /console/api { 47 | try_files $uri $uri/ @backend; 48 | } 49 | 50 | location /api { 51 | try_files $uri $uri/ @backend; 52 | } 53 | 54 | location /v1 { 55 | try_files $uri $uri/ @backend; 56 | } 57 | 58 | location /files { 59 | try_files $uri $uri/ @backend; 60 | } 61 | 62 | location / { 63 | try_files $uri $uri/ @frontend; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soulteary/dify-with-wordpress/3f48fd9b2f56f43754ded758c3344d5ecdd8ead5/preview.jpg -------------------------------------------------------------------------------- /title-generate.php: -------------------------------------------------------------------------------- 1 | [ 35 | "content" => $content, 36 | ], 37 | "response_mode" => "blocking", 38 | "user" => "soulteary", 39 | ]; 40 | curl_setopt( 41 | $ch, 42 | CURLOPT_POSTFIELDS, 43 | json_encode($payload, JSON_UNESCAPED_UNICODE) 44 | ); 45 | $response = curl_exec($ch); 46 | curl_close($ch); 47 | 48 | $data = json_decode($response, true); 49 | if (empty($data["answer"])) { 50 | return "AI 生成标题失败"; 51 | } 52 | 53 | $title = $data["answer"]; 54 | $title = str_replace('"', "", $title); 55 | return $title; 56 | } 57 | 58 | // 当文章发布或更新时,如果标题为空,自动生成一个标题 59 | add_action("the_post", "update_post_title"); 60 | function update_post_title($post) 61 | { 62 | // 当标题存在,就不再生成 63 | if (!empty($post->post_title)) { 64 | return; 65 | } 66 | 67 | // 生成标题 68 | $post_title = generate_title_by_content($post->post_content); 69 | 70 | // 更新数据库中标题 71 | wp_update_post(["ID" => $post->ID, "post_title" => $post_title]); 72 | 73 | // 更新当前文章对象 74 | $post->post_title = $post_title; 75 | } 76 | --------------------------------------------------------------------------------