Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions samples/agent/tool_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@

select_ai.connect(user=user, password=password, dsn=dsn)

tool = select_ai.agent.Tool("LLM_CHAT_TOOL")
tool.delete(force=True)
select_ai.agent.Tool.delete_tool("LLM_CHAT_TOOL", force=True)
3 changes: 1 addition & 2 deletions samples/profile_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")

select_ai.connect(user=user, password=password, dsn=dsn)
profile = select_ai.Profile(profile_name="oci_ai_profile")
profile.delete()
profile = select_ai.Profile.delete_profile(profile_name="oci_ai_profile")
36 changes: 31 additions & 5 deletions src/select_ai/agent/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
Expand Down Expand Up @@ -173,11 +173,23 @@ def delete(self, force: Optional[bool] = False):
},
)

@classmethod
def delete_agent(cls, agent_name: str, force: Optional[bool] = False):
"""
Class method to delete AI Agent from the database

:param str agent_name: The name of the AI Agent
:param bool force: Force the deletion. Default value is False.

"""
agent = cls(agent_name=agent_name)
agent.delete(force=force)

def disable(self):
"""
Disable AI Agent
"""
with cursor as cr:
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
keyword_parameters={
Expand All @@ -189,7 +201,7 @@ def enable(self):
"""
Enable AI Agent
"""
with cursor as cr:
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
keyword_parameters={
Expand Down Expand Up @@ -390,11 +402,25 @@ async def delete(self, force: Optional[bool] = False):
},
)

@classmethod
async def delete_agent(
cls, agent_name: str, force: Optional[bool] = False
):
"""
Class method to delete AI Agent from the database

:param str agent_name: The name of the AI Agent
:param bool force: Force the deletion. Default value is False.

"""
agent = cls(agent_name=agent_name)
await agent.delete(force=force)

async def disable(self):
"""
Disable AI Agent
"""
async with async_cursor as cr:
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
keyword_parameters={
Expand All @@ -406,7 +432,7 @@ async def enable(self):
"""
Enable AI Agent
"""
async with async_cursor as cr:
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
keyword_parameters={
Expand Down
22 changes: 22 additions & 0 deletions src/select_ai/agent/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ def delete(self, force: bool = False):
},
)

@classmethod
def delete_task(cls, task_name: str, force: bool = False):
"""
Class method to delete AI Task from the database

:param str task_name: The name of the AI Task
:param bool force: Force the deletion. Default value is False.
"""
task = cls(task_name=task_name)
task.delete(force=force)

def disable(self):
"""
Disable AI Task
Expand Down Expand Up @@ -406,6 +417,17 @@ async def delete(self, force: bool = False):
},
)

@classmethod
async def delete_task(cls, task_name: str, force: bool = False):
"""
Class method to delete AI Task from the database

:param str task_name: The name of the AI Task
:param bool force: Force the deletion. Default value is False.
"""
task = cls(task_name=task_name)
await task.delete(force=force)

async def disable(self):
"""
Disable AI Task
Expand Down
26 changes: 24 additions & 2 deletions src/select_ai/agent/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class BaseTeam(ABC):
def __init__(
self,
team_name: str,
attributes: TeamAttributes,
attributes: Optional[TeamAttributes] = None,
description: Optional[str] = None,
):
if not isinstance(attributes, TeamAttributes):
if attributes and not isinstance(attributes, TeamAttributes):
raise TypeError(
f"attributes must be an object of type "
f"select_ai.agent.TeamAttributes instance"
Expand Down Expand Up @@ -180,6 +180,17 @@ def delete(self, force: Optional[bool] = False):
},
)

@classmethod
def delete_team(cls, team_name: str, force: Optional[bool] = False):
"""
Class method to delete an AI agent team from the database

:param str team_name: The name of the AI team
:param bool force: Force the deletion. Default value is False.
"""
team = cls(team_name=team_name)
team.delete(force=force)

def disable(self):
"""
Disable the AI agent team
Expand Down Expand Up @@ -435,6 +446,17 @@ async def delete(self, force: Optional[bool] = False):
},
)

@classmethod
async def delete_team(cls, team_name: str, force: Optional[bool] = False):
"""
Class method to delete an AI agent team from the database

:param str team_name: The name of the AI team
:param bool force: Force the deletion. Default value is False.
"""
team = cls(team_name=team_name)
await team.delete(force=force)

async def disable(self):
"""
Disable the AI agent team
Expand Down
52 changes: 42 additions & 10 deletions src/select_ai/agent/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ class ToolType(StrEnum):
Built-in Tool Types
"""

EMAIL = "EMAIL"
HUMAN = "HUMAN"
HTTP = "HTTP"
RAG = "RAG"
SQL = "SQL"
SLACK = "SLACK"
WEBSEARCH = "WEBSEARCH"
NOTIFICATION = "NOTIFICATION"


@dataclass
Expand Down Expand Up @@ -103,6 +102,12 @@ def __post_init__(self):
@classmethod
def create(cls, *, tool_type: Optional[ToolType] = None, **kwargs):
tool_params_cls = ToolTypeParams.get(tool_type, ToolParams)
if "notification_type" in kwargs:
notification_type = kwargs["notification_type"]
if notification_type == NotificationType.SLACK:
tool_params_cls = SlackNotificationToolParams
elif notification_type == NotificationType.EMAIL:
tool_params_cls = EmailNotificationToolParams
return tool_params_cls(**kwargs)

@classmethod
Expand Down Expand Up @@ -132,14 +137,20 @@ class RAGToolParams(ToolParams):


@dataclass
class SlackNotificationToolParams(ToolParams):
class NotificationToolParams(ToolParams):

notification_type = NotificationType


@dataclass
class SlackNotificationToolParams(NotificationToolParams):

_REQUIRED_FIELDS = ["credential_name", "slack_channel"]
notification_type: NotificationType = NotificationType.SLACK


@dataclass
class EmailNotificationToolParams(ToolParams):
class EmailNotificationToolParams(NotificationToolParams):

_REQUIRED_FIELDS = ["credential_name", "recipient", "sender", "smtp_host"]
notification_type: NotificationType = NotificationType.EMAIL
Expand Down Expand Up @@ -222,8 +233,7 @@ def create(cls, **kwargs):


ToolTypeParams = {
ToolType.EMAIL: EmailNotificationToolParams,
ToolType.SLACK: SlackNotificationToolParams,
ToolType.NOTIFICATION: NotificationToolParams,
ToolType.HTTP: HTTPToolParams,
ToolType.RAG: RAGToolParams,
ToolType.SQL: SQLToolParams,
Expand Down Expand Up @@ -401,7 +411,7 @@ def create_email_notification_tool(
)
return cls.create_built_in_tool(
tool_name=tool_name,
tool_type=ToolType.EMAIL,
tool_type=ToolType.NOTIFICATION,
tool_params=email_notification_tool_params,
description=description,
replace=replace,
Expand Down Expand Up @@ -534,7 +544,7 @@ def create_slack_notification_tool(
)
return cls.create_built_in_tool(
tool_name=tool_name,
tool_type=ToolType.SLACK,
tool_type=ToolType.NOTIFICATION,
tool_params=slack_notification_tool_params,
description=description,
replace=replace,
Expand Down Expand Up @@ -585,6 +595,17 @@ def delete(self, force: bool = False):
},
)

@classmethod
def delete_tool(cls, tool_name: str, force: bool = False):
"""
Class method to delete AI Tool from the database

:param str tool_name: The name of the tool
:param bool force: Force the deletion. Default value is False.
"""
tool = cls(tool_name=tool_name)
tool.delete(force=force)

def disable(self):
"""
Disable AI Tool
Expand Down Expand Up @@ -835,7 +856,7 @@ async def create_email_notification_tool(
)
return await cls.create_built_in_tool(
tool_name=tool_name,
tool_type=ToolType.EMAIL,
tool_type=ToolType.NOTIFICATION,
tool_params=email_notification_tool_params,
description=description,
replace=replace,
Expand Down Expand Up @@ -968,7 +989,7 @@ async def create_slack_notification_tool(
)
return await cls.create_built_in_tool(
tool_name=tool_name,
tool_type=ToolType.SLACK,
tool_type=ToolType.NOTIFICATION,
tool_params=slack_notification_tool_params,
description=description,
replace=replace,
Expand Down Expand Up @@ -1019,6 +1040,17 @@ async def delete(self, force: bool = False):
},
)

@classmethod
async def delete_tool(cls, tool_name: str, force: bool = False):
"""
Class method ot delete AI Tool from the database

:param str tool_name: The name of the tool
:param bool force: Force the deletion. Default value is False.
"""
tool = cls(tool_name=tool_name)
await tool.delete(force=force)

async def disable(self):
"""
Disable AI Tool
Expand Down
39 changes: 27 additions & 12 deletions src/select_ai/async_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from select_ai.base_profile import (
BaseProfile,
ProfileAttributes,
no_data_for_prompt,
convert_json_rows_to_df,
validate_params_for_feedback,
validate_params_for_summary,
)
Expand Down Expand Up @@ -248,23 +248,40 @@ async def create(self, replace: Optional[int] = False) -> None:
else:
raise

async def delete(self, force=False) -> None:
"""Asynchronously deletes an AI profile from the database

:param bool force: Ignores errors if AI profile does not exist.
:return: None
:raises: oracledb.DatabaseError

@staticmethod
async def _delete(profile_name: str, force: bool = False):
"""
Internal method to delete AI profile from the database
"""
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI.DROP_PROFILE",
keyword_parameters={
"profile_name": self.profile_name,
"profile_name": profile_name,
"force": force,
},
)

async def delete(self, force=False) -> None:
"""Asynchronously deletes an AI profile from the database

:param bool force: Ignores errors if AI profile does not exist.
:return: None
:raises: oracledb.DatabaseError
"""
await self._delete(profile_name=self.profile_name, force=force)

@classmethod
async def delete_profile(cls, profile_name: str, force: bool = False):
"""Asynchronously deletes an AI profile from the database

:param str profile_name: Name of the AI profile
:param bool force: Ignores errors if AI profile does not exist.
:return: None
:raises: oracledb.DatabaseError
"""
await cls._delete(profile_name=profile_name, force=force)

@classmethod
async def fetch(cls, profile_name: str) -> "AsyncProfile":
"""Asynchronously create an AI Profile object from attributes
Expand Down Expand Up @@ -423,9 +440,7 @@ async def generate(
else:
result = None
if action == Action.RUNSQL:
if no_data_for_prompt(result): # empty dataframe
return pandas.DataFrame()
return pandas.DataFrame(json.loads(result))
return convert_json_rows_to_df(result)
else:
return result

Expand Down
Loading