2024-05-27 22:01:11 +08:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from core.tools.entities.api_entities import UserToolProviderTypeLiteral
|
|
|
|
from core.tools.tool_manager import ToolManager
|
|
|
|
from services.tools.tools_transform_service import ToolTransformService
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class ToolCommonService:
|
|
|
|
@staticmethod
|
|
|
|
def list_tool_providers(user_id: str, tenant_id: str, typ: UserToolProviderTypeLiteral = None):
|
|
|
|
"""
|
2024-08-26 13:43:57 +08:00
|
|
|
list tool providers
|
2024-05-27 22:01:11 +08:00
|
|
|
|
2024-08-26 13:43:57 +08:00
|
|
|
:return: the list of tool providers
|
2024-05-27 22:01:11 +08:00
|
|
|
"""
|
2024-08-26 13:43:57 +08:00
|
|
|
providers = ToolManager.user_list_providers(user_id, tenant_id, typ)
|
2024-05-27 22:01:11 +08:00
|
|
|
|
|
|
|
# add icon
|
|
|
|
for provider in providers:
|
|
|
|
ToolTransformService.repack_provider(provider)
|
|
|
|
|
|
|
|
result = [provider.to_dict() for provider in providers]
|
|
|
|
|
|
|
|
return result
|