@@ -48,13 +48,12 @@ class ToolType(StrEnum):
4848 Built-in Tool Types
4949 """
5050
51- EMAIL = "EMAIL"
5251 HUMAN = "HUMAN"
5352 HTTP = "HTTP"
5453 RAG = "RAG"
5554 SQL = "SQL"
56- SLACK = "SLACK"
5755 WEBSEARCH = "WEBSEARCH"
56+ NOTIFICATION = "NOTIFICATION"
5857
5958
6059@dataclass
@@ -103,6 +102,12 @@ def __post_init__(self):
103102 @classmethod
104103 def create (cls , * , tool_type : Optional [ToolType ] = None , ** kwargs ):
105104 tool_params_cls = ToolTypeParams .get (tool_type , ToolParams )
105+ if "notification_type" in kwargs :
106+ notification_type = kwargs ["notification_type" ]
107+ if notification_type == NotificationType .SLACK :
108+ tool_params_cls = SlackNotificationToolParams
109+ elif notification_type == NotificationType .EMAIL :
110+ tool_params_cls = EmailNotificationToolParams
106111 return tool_params_cls (** kwargs )
107112
108113 @classmethod
@@ -132,14 +137,20 @@ class RAGToolParams(ToolParams):
132137
133138
134139@dataclass
135- class SlackNotificationToolParams (ToolParams ):
140+ class NotificationToolParams (ToolParams ):
141+
142+ notification_type = NotificationType
143+
144+
145+ @dataclass
146+ class SlackNotificationToolParams (NotificationToolParams ):
136147
137148 _REQUIRED_FIELDS = ["credential_name" , "slack_channel" ]
138149 notification_type : NotificationType = NotificationType .SLACK
139150
140151
141152@dataclass
142- class EmailNotificationToolParams (ToolParams ):
153+ class EmailNotificationToolParams (NotificationToolParams ):
143154
144155 _REQUIRED_FIELDS = ["credential_name" , "recipient" , "sender" , "smtp_host" ]
145156 notification_type : NotificationType = NotificationType .EMAIL
@@ -222,8 +233,7 @@ def create(cls, **kwargs):
222233
223234
224235ToolTypeParams = {
225- ToolType .EMAIL : EmailNotificationToolParams ,
226- ToolType .SLACK : SlackNotificationToolParams ,
236+ ToolType .NOTIFICATION : NotificationToolParams ,
227237 ToolType .HTTP : HTTPToolParams ,
228238 ToolType .RAG : RAGToolParams ,
229239 ToolType .SQL : SQLToolParams ,
@@ -401,7 +411,7 @@ def create_email_notification_tool(
401411 )
402412 return cls .create_built_in_tool (
403413 tool_name = tool_name ,
404- tool_type = ToolType .EMAIL ,
414+ tool_type = ToolType .NOTIFICATION ,
405415 tool_params = email_notification_tool_params ,
406416 description = description ,
407417 replace = replace ,
@@ -534,7 +544,7 @@ def create_slack_notification_tool(
534544 )
535545 return cls .create_built_in_tool (
536546 tool_name = tool_name ,
537- tool_type = ToolType .SLACK ,
547+ tool_type = ToolType .NOTIFICATION ,
538548 tool_params = slack_notification_tool_params ,
539549 description = description ,
540550 replace = replace ,
@@ -585,6 +595,17 @@ def delete(self, force: bool = False):
585595 },
586596 )
587597
598+ @classmethod
599+ def delete_tool (cls , tool_name : str , force : bool = False ):
600+ """
601+ Class method to delete AI Tool from the database
602+
603+ :param str tool_name: The name of the tool
604+ :param bool force: Force the deletion. Default value is False.
605+ """
606+ tool = cls (tool_name = tool_name )
607+ tool .delete (force = force )
608+
588609 def disable (self ):
589610 """
590611 Disable AI Tool
@@ -835,7 +856,7 @@ async def create_email_notification_tool(
835856 )
836857 return await cls .create_built_in_tool (
837858 tool_name = tool_name ,
838- tool_type = ToolType .EMAIL ,
859+ tool_type = ToolType .NOTIFICATION ,
839860 tool_params = email_notification_tool_params ,
840861 description = description ,
841862 replace = replace ,
@@ -968,7 +989,7 @@ async def create_slack_notification_tool(
968989 )
969990 return await cls .create_built_in_tool (
970991 tool_name = tool_name ,
971- tool_type = ToolType .SLACK ,
992+ tool_type = ToolType .NOTIFICATION ,
972993 tool_params = slack_notification_tool_params ,
973994 description = description ,
974995 replace = replace ,
@@ -1019,6 +1040,17 @@ async def delete(self, force: bool = False):
10191040 },
10201041 )
10211042
1043+ @classmethod
1044+ async def delete_tool (cls , tool_name : str , force : bool = False ):
1045+ """
1046+ Class method ot delete AI Tool from the database
1047+
1048+ :param str tool_name: The name of the tool
1049+ :param bool force: Force the deletion. Default value is False.
1050+ """
1051+ tool = cls (tool_name = tool_name )
1052+ await tool .delete (force = force )
1053+
10221054 async def disable (self ):
10231055 """
10241056 Disable AI Tool
0 commit comments