-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f0488a
commit e584d37
Showing
15 changed files
with
248 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
from configs.build_info import BuildInfo | ||
from configs.deployment_configs import DeploymentConfigs | ||
from configs.endpoint_configs import EndpointConfigs | ||
from configs.http_configs import HttpConfigs | ||
from configs.logging_configs import LoggingConfigs | ||
from configs.security_configs import SecurityConfigs | ||
|
||
|
||
class AppConfigs( | ||
# pydantic-settings | ||
BaseSettings, | ||
|
||
# app configs | ||
BuildInfo, | ||
DeploymentConfigs, | ||
EndpointConfigs, | ||
HttpConfigs, | ||
LoggingConfigs, | ||
SecurityConfigs, | ||
): | ||
# read from dotenv format config file | ||
model_config = SettingsConfigDict( | ||
env_file='.env', | ||
env_file_encoding='utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class BuildInfo(BaseModel): | ||
""" | ||
Build information | ||
""" | ||
|
||
CURRENT_VERSION: str = Field( | ||
description='Dify version', | ||
default='0.6.11', | ||
) | ||
|
||
COMMIT_SHA: str = Field( | ||
description="SHA-1 checksum of the git commit used to build the app", | ||
default='', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class DeploymentConfigs(BaseModel): | ||
""" | ||
Deployment configs | ||
""" | ||
EDITION: str = Field( | ||
description='deployment edition', | ||
default='SELF_HOSTED', | ||
) | ||
|
||
DEPLOY_ENV: str = Field( | ||
description='deployment environment, default to PRODUCTION.', | ||
default='PRODUCTION', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from pydantic import AliasChoices, BaseModel, Field | ||
|
||
|
||
class EndpointConfigs(BaseModel): | ||
""" | ||
Module URL configs | ||
""" | ||
CONSOLE_API_URL: str = Field( | ||
description='The backend URL prefix of the console API.' | ||
'used to concatenate the login authorization callback or notion integration callback.', | ||
default='https://cloud.dify.ai', | ||
) | ||
|
||
CONSOLE_WEB_URL: str = Field( | ||
description='The front-end URL prefix of the console web.' | ||
'used to concatenate some front-end addresses and for CORS configuration use.', | ||
default='https://cloud.dify.ai', | ||
) | ||
|
||
SERVICE_API_URL: str = Field( | ||
description='Service API Url prefix.' | ||
'used to display Service API Base Url to the front-end.', | ||
default='https://api.dify.ai', | ||
) | ||
|
||
APP_WEB_URL: str = Field( | ||
description='WebApp Url prefix.' | ||
'used to display WebAPP API Base Url to the front-end.', | ||
default='https://udify.app', | ||
) | ||
|
||
FILES_URL: str = Field( | ||
description='File preview or download Url prefix.' | ||
' used to display File preview or download Url to the front-end or as Multi-model inputs;' | ||
'Url is signed and has expiration time.', | ||
validation_alias=AliasChoices('FILES_URL', 'CONSOLE_API_URL'), | ||
alias_priority=1, | ||
default='https://cloud.dify.ai', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class HttpConfigs(BaseModel): | ||
""" | ||
HTTP configs | ||
""" | ||
API_COMPRESSION_ENABLED: bool = Field( | ||
description='whether to enable HTTP response compression of gzip', | ||
default=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class LoggingConfigs(BaseModel): | ||
""" | ||
Logging configs | ||
""" | ||
|
||
LOG_LEVEL: str = Field( | ||
description='Log output level, default to INFO.' | ||
'It is recommended to set it to ERROR for production.', | ||
default='INFO', | ||
) | ||
|
||
LOG_FILE: str = Field( | ||
description='logging output file path', | ||
default='', | ||
) | ||
|
||
LOG_FORMAT: str = Field( | ||
description='log format', | ||
default='%(asctime)s.%(msecs)03d %(levelname)s [%(threadName)s] [%(filename)s:%(lineno)d] - %(message)s', | ||
) | ||
|
||
LOG_DATEFORMAT: str = Field( | ||
description='log date format', | ||
default='', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class SecurityConfigs(BaseModel): | ||
""" | ||
Secret Key configs | ||
""" | ||
SECRET_KEY: Optional[str] = Field( | ||
description='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`.' | ||
'Alternatively you can set it with `SECRET_KEY` environment variable.', | ||
default=None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class HttpConfigs(BaseModel): | ||
""" | ||
HTTP configs | ||
""" | ||
CHECK_UPDATE_URL: str = Field( | ||
description='url for checking updates', | ||
default='https://updates.dify.ai', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.