-
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.
Merge remote-tracking branch 'origin/main' into feat/chatting-message…
…-switch-navigation
- Loading branch information
Showing
685 changed files
with
18,748 additions
and
8,238 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
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 |
---|---|---|
|
@@ -51,7 +51,7 @@ jobs: | |
- name: Expose Service Ports | ||
run: sh .github/workflows/expose_service_ports.sh | ||
|
||
- name: Set up Vector Stores (Weaviate, Qdrant, PGVector, Milvus, PgVecto-RS, Chroma, MyScale, ElasticSearch, Couchbase) | ||
- name: Set up Vector Stores (TiDB, Weaviate, Qdrant, PGVector, Milvus, PgVecto-RS, Chroma, MyScale, ElasticSearch, Couchbase) | ||
uses: hoverkraft-tech/[email protected] | ||
with: | ||
compose-file: | | ||
|
@@ -67,6 +67,7 @@ jobs: | |
pgvector | ||
chroma | ||
elasticsearch | ||
tidb | ||
- name: Test Vector Stores | ||
run: poetry run -C api bash dev/pytest/pytest_vdb.sh |
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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
from app_factory import create_app | ||
from libs import threadings_utils, version_utils | ||
from libs import version_utils | ||
|
||
# preparation before creating app | ||
version_utils.check_supported_python_version() | ||
threadings_utils.apply_gevent_threading_patch() | ||
|
||
|
||
def is_db_command(): | ||
import sys | ||
|
||
if len(sys.argv) > 1 and sys.argv[0].endswith("flask") and sys.argv[1] == "db": | ||
return True | ||
return False | ||
|
||
|
||
# create app | ||
app = create_app() | ||
celery = app.extensions["celery"] | ||
if is_db_command(): | ||
from app_factory import create_migrations_app | ||
|
||
app = create_migrations_app() | ||
else: | ||
from app_factory import create_app | ||
from libs import threadings_utils | ||
|
||
threadings_utils.apply_gevent_threading_patch() | ||
|
||
app = create_app() | ||
celery = app.extensions["celery"] | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=5001) |
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 |
---|---|---|
@@ -1,11 +1,51 @@ | ||
from pydantic_settings import SettingsConfigDict | ||
import logging | ||
from typing import Any | ||
|
||
from configs.deploy import DeploymentConfig | ||
from configs.enterprise import EnterpriseFeatureConfig | ||
from configs.extra import ExtraServiceConfig | ||
from configs.feature import FeatureConfig | ||
from configs.middleware import MiddlewareConfig | ||
from configs.packaging import PackagingInfo | ||
from pydantic.fields import FieldInfo | ||
from pydantic_settings import BaseSettings, PydanticBaseSettingsSource, SettingsConfigDict | ||
|
||
from .deploy import DeploymentConfig | ||
from .enterprise import EnterpriseFeatureConfig | ||
from .extra import ExtraServiceConfig | ||
from .feature import FeatureConfig | ||
from .middleware import MiddlewareConfig | ||
from .packaging import PackagingInfo | ||
from .remote_settings_sources import RemoteSettingsSource, RemoteSettingsSourceConfig, RemoteSettingsSourceName | ||
from .remote_settings_sources.apollo import ApolloSettingsSource | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class RemoteSettingsSourceFactory(PydanticBaseSettingsSource): | ||
def __init__(self, settings_cls: type[BaseSettings]): | ||
super().__init__(settings_cls) | ||
|
||
def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str, bool]: | ||
raise NotImplementedError | ||
|
||
def __call__(self) -> dict[str, Any]: | ||
current_state = self.current_state | ||
remote_source_name = current_state.get("REMOTE_SETTINGS_SOURCE_NAME") | ||
if not remote_source_name: | ||
return {} | ||
|
||
remote_source: RemoteSettingsSource | None = None | ||
match remote_source_name: | ||
case RemoteSettingsSourceName.APOLLO: | ||
remote_source = ApolloSettingsSource(current_state) | ||
case _: | ||
logger.warning(f"Unsupported remote source: {remote_source_name}") | ||
return {} | ||
|
||
d: dict[str, Any] = {} | ||
|
||
for field_name, field in self.settings_cls.model_fields.items(): | ||
field_value, field_key, value_is_complex = remote_source.get_field_value(field, field_name) | ||
field_value = remote_source.prepare_field_value(field_name, field, field_value, value_is_complex) | ||
if field_value is not None: | ||
d[field_key] = field_value | ||
|
||
return d | ||
|
||
|
||
class DifyConfig( | ||
|
@@ -19,6 +59,8 @@ class DifyConfig( | |
MiddlewareConfig, | ||
# Extra service configs | ||
ExtraServiceConfig, | ||
# Remote source configs | ||
RemoteSettingsSourceConfig, | ||
# Enterprise feature configs | ||
# **Before using, please contact [email protected] by email to inquire about licensing matters.** | ||
EnterpriseFeatureConfig, | ||
|
@@ -35,3 +77,20 @@ class DifyConfig( | |
# please consider to arrange it in the proper config group of existed or added | ||
# for better readability and maintainability. | ||
# Thanks for your concentration and consideration. | ||
|
||
@classmethod | ||
def settings_customise_sources( | ||
cls, | ||
settings_cls: type[BaseSettings], | ||
init_settings: PydanticBaseSettingsSource, | ||
env_settings: PydanticBaseSettingsSource, | ||
dotenv_settings: PydanticBaseSettingsSource, | ||
file_secret_settings: PydanticBaseSettingsSource, | ||
) -> tuple[PydanticBaseSettingsSource, ...]: | ||
return ( | ||
init_settings, | ||
env_settings, | ||
RemoteSettingsSourceFactory(settings_cls), | ||
dotenv_settings, | ||
file_secret_settings, | ||
) |
Oops, something went wrong.