Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: config file (#3852)

takatost8bca908f1571
diff --git a/api/.env.example b/api/.env.example
index d8c3f0e1290..c61cb60d3eb 100644
--- a/api/.env.example
+++ b/api/.env.example
@@ -1,6 +1,3 @@
-# Server Edition
-EDITION=SELF_HOSTED
-
# Your App secret key will be used for securely signing the session cookie
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`.
@@ -123,25 +120,6 @@ NOTION_CLIENT_SECRET=you-client-secret
NOTION_CLIENT_ID=you-client-id
NOTION_INTERNAL_SECRET=you-internal-secret
-# Hosted Model Credentials
-HOSTED_OPENAI_API_KEY=
-HOSTED_OPENAI_API_BASE=
-HOSTED_OPENAI_API_ORGANIZATION=
-HOSTED_OPENAI_TRIAL_ENABLED=false
-HOSTED_OPENAI_QUOTA_LIMIT=200
-HOSTED_OPENAI_PAID_ENABLED=false
-
-HOSTED_AZURE_OPENAI_ENABLED=false
-HOSTED_AZURE_OPENAI_API_KEY=
-HOSTED_AZURE_OPENAI_API_BASE=
-HOSTED_AZURE_OPENAI_QUOTA_LIMIT=200
-
-HOSTED_ANTHROPIC_API_BASE=
-HOSTED_ANTHROPIC_API_KEY=
-HOSTED_ANTHROPIC_TRIAL_ENABLED=false
-HOSTED_ANTHROPIC_QUOTA_LIMIT=600000
-HOSTED_ANTHROPIC_PAID_ENABLED=false
-
ETL_TYPE=dify
UNSTRUCTURED_API_URL=
diff --git a/api/app.py b/api/app.py
index 23274c307cf..a36750410e1 100644
--- a/api/app.py
+++ b/api/app.py
@@ -1,28 +1,28 @@
import os
-import sys
-from logging.handlers import RotatingFileHandler
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
from gevent import monkey
monkey.patch_all()
- # if os.environ.get("VECTOR_STORE") == 'milvus':
+
import grpc.experimental.gevent
grpc.experimental.gevent.init_gevent()
import json
import logging
+import sys
import threading
import time
import warnings
+from logging.handlers import RotatingFileHandler
from flask import Flask, Response, request
from flask_cors import CORS
from werkzeug.exceptions import Unauthorized
from commands import register_commands
-from config import CloudEditionConfig, Config
+from config import Config
# DO NOT REMOVE BELOW
from events import event_handlers
@@ -75,16 +75,9 @@ config_type = os.getenv('EDITION', default='SELF_HOSTED') # ce edition first
# ----------------------------
-def create_app(test_config=None) -> Flask:
+def create_app() -> Flask:
app = DifyApp(__name__)
-
- if test_config:
- app.config.from_object(test_config)
- else:
- if config_type == "CLOUD":
- app.config.from_object(CloudEditionConfig())
- else:
- app.config.from_object(Config())
+ app.config.from_object(Config())
app.secret_key = app.config['SECRET_KEY']
@@ -101,6 +94,7 @@ def create_app(test_config=None) -> Flask:
),
logging.StreamHandler(sys.stdout)
]
+
logging.basicConfig(
level=app.config.get('LOG_LEVEL'),
format=app.config.get('LOG_FORMAT'),
diff --git a/api/config.py b/api/config.py
index a269bd582f3..8fb6b83cb3c 100644
--- a/api/config.py
+++ b/api/config.py
@@ -5,6 +5,7 @@ import dotenv
dotenv.load_dotenv()
DEFAULTS = {
+ 'EDITION': 'SELF_HOSTED',
'DB_USERNAME': 'postgres',
'DB_PASSWORD': '',
'DB_HOST': 'localhost',
@@ -106,7 +107,7 @@ class Config:
# ------------------------
self.CURRENT_VERSION = "0.6.5"
self.COMMIT_SHA = get_env('COMMIT_SHA')
- self.EDITION = "SELF_HOSTED"
+ self.EDITION = get_env('EDITION')
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
self.TESTING = False
self.LOG_LEVEL = get_env('LOG_LEVEL')
@@ -260,7 +261,7 @@ class Config:
self.SMTP_USE_TLS = get_bool_env('SMTP_USE_TLS')
# ------------------------
- # Workpace Configurations.
+ # Workspace Configurations.
# ------------------------
self.INVITE_EXPIRY_HOURS = int(get_env('INVITE_EXPIRY_HOURS'))
@@ -299,6 +300,12 @@ class Config:
# ------------------------
# Platform Configurations.
# ------------------------
+ self.GITHUB_CLIENT_ID = get_env('GITHUB_CLIENT_ID')
+ self.GITHUB_CLIENT_SECRET = get_env('GITHUB_CLIENT_SECRET')
+ self.GOOGLE_CLIENT_ID = get_env('GOOGLE_CLIENT_ID')
+ self.GOOGLE_CLIENT_SECRET = get_env('GOOGLE_CLIENT_SECRET')
+ self.OAUTH_REDIRECT_PATH = get_env('OAUTH_REDIRECT_PATH')
+
self.HOSTED_OPENAI_API_KEY = get_env('HOSTED_OPENAI_API_KEY')
self.HOSTED_OPENAI_API_BASE = get_env('HOSTED_OPENAI_API_BASE')
self.HOSTED_OPENAI_API_ORGANIZATION = get_env('HOSTED_OPENAI_API_ORGANIZATION')
@@ -345,17 +352,3 @@ class Config:
self.KEYWORD_DATA_SOURCE_TYPE = get_env('KEYWORD_DATA_SOURCE_TYPE')
self.ENTERPRISE_ENABLED = get_bool_env('ENTERPRISE_ENABLED')
-
-
-class CloudEditionConfig(Config):
-
- def __init__(self):
- super().__init__()
-
- self.EDITION = "CLOUD"
-
- self.GITHUB_CLIENT_ID = get_env('GITHUB_CLIENT_ID')
- self.GITHUB_CLIENT_SECRET = get_env('GITHUB_CLIENT_SECRET')
- self.GOOGLE_CLIENT_ID = get_env('GOOGLE_CLIENT_ID')
- self.GOOGLE_CLIENT_SECRET = get_env('GOOGLE_CLIENT_SECRET')
- self.OAUTH_REDIRECT_PATH = get_env('OAUTH_REDIRECT_PATH')
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index c32306e6dbb..46ed6374248 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -247,7 +247,6 @@ services:
image: langgenius/dify-web:0.6.5
restart: always
environment:
- EDITION: SELF_HOSTED
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
diff --git a/web/.env.example b/web/.env.example
index 208a24adf55..653913033d8 100644
--- a/web/.env.example
+++ b/web/.env.example
@@ -1,6 +1,6 @@
# For production release, change this to PRODUCTION
NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT
-# The deployment edition, SELF_HOSTED or CLOUD
+# The deployment edition, SELF_HOSTED
NEXT_PUBLIC_EDITION=SELF_HOSTED
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
diff --git a/web/README.md b/web/README.md
index 9859f5bcab2..3864e2ba5e2 100644
--- a/web/README.md
+++ b/web/README.md
@@ -17,7 +17,7 @@ Then, configure the environment variables. Create a file named `.env.local` in t
```
# For production release, change this to PRODUCTION
NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT
-# The deployment edition, SELF_HOSTED or CLOUD
+# The deployment edition, SELF_HOSTED
NEXT_PUBLIC_EDITION=SELF_HOSTED
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.