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
Add list configs and environments (#12438)
Jin Hai92780c486a95
diff --git a/admin/client/admin_client.py b/admin/client/admin_client.pyindex 1007835052..174cd5857a 100644--- a/admin/client/admin_client.py+++ b/admin/client/admin_client.py@@ -58,6 +58,8 @@ sql_command: list_services| set_variable| show_variable| list_variables+ | list_configs+ | list_environments// meta command definitionmeta_command: "\\" meta_command_name [meta_args]@@ -103,6 +105,8 @@ SET: "SET"iVERSION: "VERSION"iVAR: "VAR"iVARS: "VARS"i+CONFIGS: "CONFIGS"i+ENVS: "ENVS"ilist_services: LIST SERVICES ";"show_service: SHOW SERVICE NUMBER ";"@@ -137,6 +141,8 @@ revoke_admin: REVOKE ADMIN quoted_string ";"set_variable: SET VAR identifier identifier ";"show_variable: SHOW VAR identifier ";"list_variables: LIST VARS ";"+list_configs: LIST CONFIGS ";"+list_environments: LIST ENVS ";"show_version: SHOW VERSION ";"@@ -284,6 +290,12 @@ class AdminTransformer(Transformer):def list_variables(self, items):return {"type": "list_variables"}+ def list_configs(self, items):+ return {"type": "list_configs"}++ def list_environments(self, items):+ return {"type": "list_environments"}+def action_list(self, items):return items@@ -648,6 +660,10 @@ class AdminCLI(Cmd):self._show_variable(command_dict)case "list_variables":self._list_variables(command_dict)+ case "list_configs":+ self._list_configs(command_dict)+ case "list_environments":+ self._list_environments(command_dict)case "meta":self._handle_meta_command(command_dict)case _:@@ -840,6 +856,24 @@ class AdminCLI(Cmd):else:print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")+ def _list_configs(self, command):+ url = f"http://{self.host}:{self.port}/api/v1/admin/configs"+ response = self.session.get(url)+ res_json = response.json()+ if response.status_code == 200:+ self._print_table_simple(res_json["data"])+ else:+ print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")++ def _list_environments(self, command):+ url = f"http://{self.host}:{self.port}/api/v1/admin/environments"+ response = self.session.get(url)+ res_json = response.json()+ if response.status_code == 200:+ self._print_table_simple(res_json["data"])+ else:+ print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")+def _handle_list_datasets(self, command):username_tree: Tree = command["user_name"]user_name: str = username_tree.children[0].strip("'\"")diff --git a/admin/server/routes.py b/admin/server/routes.pyindex fcf75e485d..ec63dbfe19 100644--- a/admin/server/routes.py+++ b/admin/server/routes.py@@ -21,7 +21,7 @@ from flask_login import current_user, login_required, logout_userfrom auth import login_verify, login_admin, check_admin_authfrom responses import success_response, error_response-from services import UserMgr, ServiceMgr, UserServiceMgr, SettingsMgr+from services import UserMgr, ServiceMgr, UserServiceMgr, SettingsMgr, ConfigMgr, EnvironmentsMgrfrom roles import RoleMgrfrom api.common.exceptions import AdminExceptionfrom common.versions import get_ragflow_version@@ -449,6 +449,30 @@ def get_variable():except Exception as e:return error_response(str(e), 500)+@admin_bp.route('/configs', methods=['GET'])+@login_required+@check_admin_auth+def get_config():+ try:+ res = list(ConfigMgr.get_all())+ return success_response(res)+ except AdminException as e:+ return error_response(str(e), 400)+ except Exception as e:+ return error_response(str(e), 500)++@admin_bp.route('/environments', methods=['GET'])+@login_required+@check_admin_auth+def get_environments():+ try:+ res = list(EnvironmentsMgr.get_all())+ return success_response(res)+ except AdminException as e:+ return error_response(str(e), 400)+ except Exception as e:+ return error_response(str(e), 500)+@admin_bp.route('/version', methods=['GET'])@login_required@check_admin_authdiff --git a/admin/server/services.py b/admin/server/services.pyindex fe23996fff..a3e29a51c4 100644--- a/admin/server/services.py+++ b/admin/server/services.py@@ -306,5 +306,37 @@ class SettingsMgr:elif len(settings) > 1:raise AdminException(f"Can't update more than 1 setting: {name}")else:- raise AdminException(f"No sett"- f"ing: {name}")\ No newline at end of file+ raise AdminException(f"No setting: {name}")++class ConfigMgr:++ @staticmethod+ def get_all():+ result = []+ configs = SERVICE_CONFIGS.configs+ for config in configs:+ config_dict = config.to_dict()+ result.append(config_dict)+ return result++class EnvironmentsMgr:+ @staticmethod+ def get_all():+ result = []++ env_kv = {"env": "DOC_ENGINE", "value": os.getenv('DOC_ENGINE')}+ result.append(env_kv)++ env_kv = {"env": "DEFAULT_SUPERUSER_EMAIL", "value": os.getenv("DEFAULT_SUPERUSER_EMAIL", "[email protected]")}+ result.append(env_kv)++ env_kv = {"env": "DB_TYPE", "value": os.getenv("DB_TYPE", "mysql")}+ result.append(env_kv)++ env_kv = {"env": "DEVICE", "value": os.getenv("DEVICE", "cpu")}+ result.append(env_kv)++ env_kv = {"env": "STORAGE_IMPL", "value": os.getenv("STORAGE_IMPL", "MINIO")}+ result.append(env_kv)++ return result