From 66c01c7274852cea0ff9149d08cb3da1973543d3 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Thu, 6 Nov 2025 15:28:48 +0800 Subject: [PATCH] Minor tweaks (#11060) ### What problem does this PR solve? Minor tweaks ### Type of change - [x] Refactoring --------- Signed-off-by: Jin Hai --- admin/client/admin_client.py | 3 ++- admin/server/auth.py | 2 +- agent/component/__init__.py | 9 +++++---- agent/component/base.py | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/admin/client/admin_client.py b/admin/client/admin_client.py index 622ad0d51..4a792f6a4 100644 --- a/admin/client/admin_client.py +++ b/admin/client/admin_client.py @@ -23,6 +23,7 @@ from Cryptodome.Cipher import PKCS1_v1_5 as Cipher_pkcs1_v1_5 from typing import Dict, List, Any from lark import Lark, Transformer, Tree import requests +import getpass GRAMMAR = r""" start: command @@ -359,7 +360,7 @@ class AdminCLI(Cmd): if single_command: admin_passwd = arguments['password'] else: - admin_passwd = input(f"password for {self.admin_account}: ").strip() + admin_passwd = getpass.getpass(f"password for {self.admin_account}: ").strip() try: self.admin_password = encrypt(admin_passwd) response = self.session.post(url, json={'email': self.admin_account, 'password': self.admin_password}) diff --git a/admin/server/auth.py b/admin/server/auth.py index baf4e8e47..564c348e3 100644 --- a/admin/server/auth.py +++ b/admin/server/auth.py @@ -24,7 +24,7 @@ from flask_login import current_user, login_user from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer from api.common.exceptions import AdminException, UserNotFoundError -from api.db.init_data import encode_to_base64 +from api.common.base64 import encode_to_base64 from api.db.services import UserService from common.constants import ActiveEnum, StatusEnum from api.utils.crypt import decrypt diff --git a/agent/component/__init__.py b/agent/component/__init__.py index 47a348fb0..010458b2a 100644 --- a/agent/component/__init__.py +++ b/agent/component/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - +import logging import os import importlib import inspect @@ -50,9 +50,10 @@ del _package_path, _import_submodules, _extract_classes_from_module def component_class(class_name): - for mdl in ["agent.component", "agent.tools", "rag.flow"]: + for module_name in ["agent.component", "agent.tools", "rag.flow"]: try: - return getattr(importlib.import_module(mdl), class_name) - except Exception: + return getattr(importlib.import_module(module_name), class_name) + except Exception as e: + logging.warning(f"Can't import module: {module_name}, error: {e}") pass assert False, f"Can't import {class_name}" diff --git a/agent/component/base.py b/agent/component/base.py index db9a8f29d..75cb63abe 100644 --- a/agent/component/base.py +++ b/agent/component/base.py @@ -514,6 +514,7 @@ class ComponentBase(ABC): def get_param(self, name): if hasattr(self._param, name): return getattr(self._param, name) + return None def debug(self, **kwargs): return self._invoke(**kwargs) @@ -521,7 +522,7 @@ class ComponentBase(ABC): def get_parent(self) -> Union[object, None]: pid = self._canvas.get_component(self._id).get("parent_id") if not pid: - return + return None return self._canvas.get_component(pid)["obj"] def get_upstream(self) -> List[str]: @@ -546,7 +547,7 @@ class ComponentBase(ABC): def exception_handler(self): if not self._param.exception_method: - return + return None return { "goto": self._param.exception_goto, "default_value": self._param.exception_default_value