RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Print configs when startup RAGFlow server (#3414)
Jin Hai6878d23a57ac
diff --git a/api/constants.py b/api/constants.pyindex 636c246bcf..f571d21578 100644--- a/api/constants.py+++ b/api/constants.py@@ -15,4 +15,6 @@NAME_LENGTH_LIMIT = 2 ** 10-IMG_BASE64_PREFIX = 'data:image/png;base64,'\ No newline at end of file+IMG_BASE64_PREFIX = 'data:image/png;base64,'++SERVICE_CONF = "service_conf.yaml"\ No newline at end of filediff --git a/api/ragflow_server.py b/api/ragflow_server.pyindex 7be85c078e..091cf9a58d 100644--- a/api/ragflow_server.py+++ b/api/ragflow_server.py@@ -17,6 +17,7 @@import loggingimport inspectfrom api.utils.log_utils import initRootLogger+initRootLogger(inspect.getfile(inspect.currentframe()))for module in ["pdfminer"]:module_logger = logging.getLogger(module)@@ -45,6 +46,7 @@ from api import utilsfrom api.db.db_models import init_database_tables as init_web_dbfrom api.db.init_data import init_web_datafrom api.versions import get_ragflow_version+from api.utils import show_configsdef update_progress():@@ -71,6 +73,7 @@ if __name__ == '__main__':logging.info(f'project base: {utils.file_utils.get_project_base_directory()}')+ show_configs()# init dbinit_web_db()@@ -80,7 +83,7 @@ if __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument(- "--version", default=False, help="rag flow version", action="store_true"+ "--version", default=False, help="RAGFlow version", action="store_true")parser.add_argument("--debug", default=False, help="debug mode", action="store_true"@@ -97,9 +100,8 @@ if __name__ == '__main__':RuntimeConfig.init_env()RuntimeConfig.init_config(JOB_SERVER_HOST=HOST, HTTP_PORT=HTTP_PORT)-- thr = ThreadPoolExecutor(max_workers=1)- thr.submit(update_progress)+ thread = ThreadPoolExecutor(max_workers=1)+ thread.submit(update_progress)# start http servertry:diff --git a/api/utils/__init__.py b/api/utils/__init__.pyindex edb50577f1..9be51f9b3d 100644--- a/api/utils/__init__.py+++ b/api/utils/__init__.py@@ -23,54 +23,61 @@ import socketimport timeimport uuidimport requests+import loggingfrom enum import Enum, IntEnumimport importlibfrom Cryptodome.PublicKey import RSAfrom Cryptodome.Cipher import PKCS1_v1_5 as Cipher_pkcs1_v1_5-from filelock import FileLock+from api.constants import SERVICE_CONFfrom . import file_utils-SERVICE_CONF = "service_conf.yaml"-def conf_realpath(conf_name):conf_path = f"conf/{conf_name}"return os.path.join(file_utils.get_project_base_directory(), conf_path)-def get_base_config(key, default=None, conf_name=SERVICE_CONF) -> dict:+def read_config(conf_name=SERVICE_CONF):local_config = {}local_path = conf_realpath(f'local.{conf_name}')- if default is None:- default = os.environ.get(key.upper())+ # load local config fileif os.path.exists(local_path):local_config = file_utils.load_yaml_conf(local_path)if not isinstance(local_config, dict):raise ValueError(f'Invalid config file: "{local_path}".')- if key is not None and key in local_config:- return local_config[key]+ global_config_path = conf_realpath(conf_name)+ global_config = file_utils.load_yaml_conf(global_config_path)- config_path = conf_realpath(conf_name)- config = file_utils.load_yaml_conf(config_path)+ if not isinstance(global_config, dict):+ raise ValueError(f'Invalid config file: "{global_config_path}".')- if not isinstance(config, dict):- raise ValueError(f'Invalid config file: "{config_path}".')+ global_config.update(local_config)+ return global_config- config.update(local_config)- return config.get(key, default) if key is not None else config+CONFIGS = read_config()-use_deserialize_safe_module = get_base_config(- 'use_deserialize_safe_module', False)++def show_configs():+ logging.info(f"Current configs, from {conf_realpath(SERVICE_CONF)}:")+ for k, v in CONFIGS.items():+ logging.info(f"{k}: {v}")-class CoordinationCommunicationProtocol(object):- HTTP = "http"- GRPC = "grpc"+def get_base_config(key, default=None):+ if key is None:+ return None+ if default is None:+ default = os.environ.get(key.upper())+ return CONFIGS.get(key, default)+++use_deserialize_safe_module = get_base_config(+ 'use_deserialize_safe_module', False)class BaseType:@@ -98,6 +105,7 @@ class BaseType:data = objreturn {"type": obj.__class__.__name__,"data": data, "module": module}+return _dict(self)@@ -342,8 +350,8 @@ def download_img(url):return ""response = requests.get(url)return "data:" + \- response.headers.get('Content-Type', 'image/jpg') + ";" + \- "base64," + base64.b64encode(response.content).decode("utf-8")+ response.headers.get('Content-Type', 'image/jpg') + ";" + \+ "base64," + base64.b64encode(response.content).decode("utf-8")def delta_seconds(date_string: str):diff --git a/api/validation.py b/api/validation.pyindex 7c0e42a141..39d506a8f2 100644--- a/api/validation.py+++ b/api/validation.py@@ -43,7 +43,7 @@ def download_nltk_data():try:from multiprocessing import Poolpool = Pool(processes=1)- thr = pool.apply_async(download_nltk_data)- binary = thr.get(timeout=60)+ thread = pool.apply_async(download_nltk_data)+ binary = thread.get(timeout=60)except Exception as e:print('\x1b[6;37;41m WARNING \x1b[0m' + "Downloading NLTK data failure.", flush=True)