diff --git a/api/controllers/console/workspace/tool_providers.py b/api/controllers/console/workspace/tool_providers.py index 9f2b622681..3b393f9d44 100644 --- a/api/controllers/console/workspace/tool_providers.py +++ b/api/controllers/console/workspace/tool_providers.py @@ -589,6 +589,7 @@ class APOToolBuiltinListApi(Resource): parser = reqparse.RequestParser() parser.add_argument("tool_type", type=str, required=True, nullable=False, location="args") parser.add_argument("query", type=str, required=False, nullable=True, location="args") + parser.add_argument("language", type=int, required=False, nullable=True, location="args") args = parser.parse_args() @@ -600,6 +601,7 @@ class APOToolBuiltinListApi(Resource): tenant_id, args["tool_type"], args.get("query", None), + args.get("language", "zh") ) ] ) diff --git a/api/services/tools/builtin_tools_manage_service.py b/api/services/tools/builtin_tools_manage_service.py index 210daa3966..7fd68a853c 100644 --- a/api/services/tools/builtin_tools_manage_service.py +++ b/api/services/tools/builtin_tools_manage_service.py @@ -289,7 +289,7 @@ class BuiltinToolManageService: return BuiltinToolProviderSort.sort(result) @staticmethod - def list_apo_tools(user_id: str, tenant_id: str, tool_type: str, query: str|None) -> list[ToolProviderApiEntity]: + def list_apo_tools(user_id: str, tenant_id: str, tool_type: str, query: str|None, language: str) -> list[ToolProviderApiEntity]: """ list apo tools """ @@ -348,9 +348,14 @@ class BuiltinToolManageService: ) ) else: + if language == "zh": + match_raw = [tool.entity.identity.label.zh_Hans for tool in tools] + else: + match_raw = [tool.entity.identity.label.en_US for tool in tools] + match_tools = process.extract( query, - [tool.entity.identity.label.zh_Hans for tool in tools], + match_raw, limit=50, ) for match_name, score, index in match_tools or []: @@ -368,7 +373,7 @@ class BuiltinToolManageService: except Exception as e: raise e - return BuiltinToolProviderSort.sort(result) + return result @staticmethod def list_all_apo_tools(user_id: str, tenant_id: str) -> list[ToolProviderApiEntity]: