mirror of
https://github.com/langgenius/dify.git
synced 2026-03-29 01:49:57 +08:00
feat: Human Input Node (#32060)
The frontend and backend implementation for the human input node. Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import random
|
||||
@ -10,26 +11,34 @@ from flask.testing import FlaskClient
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app_factory import create_app
|
||||
from configs.app_config import DifyConfig
|
||||
from extensions.ext_database import db
|
||||
from models import Account, DifySetup, Tenant, TenantAccountJoin
|
||||
from services.account_service import AccountService, RegisterService
|
||||
|
||||
_DEFUALT_TEST_ENV = ".env"
|
||||
_DEFAULT_VDB_TEST_ENV = "vdb.env"
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Loading the .env file if it exists
|
||||
def _load_env():
|
||||
current_file_path = pathlib.Path(__file__).absolute()
|
||||
# Items later in the list have higher precedence.
|
||||
files_to_load = [".env", "vdb.env"]
|
||||
env_file_paths = [
|
||||
os.getenv("DIFY_TEST_ENV_FILE", str(current_file_path.parent / _DEFUALT_TEST_ENV)),
|
||||
os.getenv("DIFY_VDB_TEST_ENV_FILE", str(current_file_path.parent / _DEFAULT_VDB_TEST_ENV)),
|
||||
]
|
||||
|
||||
env_file_paths = [current_file_path.parent / i for i in files_to_load]
|
||||
for path in env_file_paths:
|
||||
if not path.exists():
|
||||
continue
|
||||
for env_path_str in env_file_paths:
|
||||
if not pathlib.Path(env_path_str).exists():
|
||||
_logger.warning("specified configuration file %s not exist", env_path_str)
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Set `override=True` to ensure values from `vdb.env` take priority over values from `.env`
|
||||
load_dotenv(str(path), override=True)
|
||||
load_dotenv(str(env_path_str), override=True)
|
||||
|
||||
|
||||
_load_env()
|
||||
@ -41,6 +50,12 @@ os.environ.setdefault("OPENDAL_SCHEME", "fs")
|
||||
_CACHED_APP = create_app()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def dify_config() -> DifyConfig:
|
||||
config = DifyConfig() # type: ignore
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def flask_app() -> Flask:
|
||||
return _CACHED_APP
|
||||
|
||||
Reference in New Issue
Block a user