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
28 changes: 14 additions & 14 deletions src/select_ai/agent/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ def create(
with cursor() as cr:
try:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
keyword_parameters=parameters,
)
except oracledb.Error as err:
(err_obj,) = err.args
if err_obj.code in (20050, 20052) and replace:
self.delete(force=True)
cr.callproc(
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
keyword_parameters=parameters,
)
else:
Expand All @@ -169,7 +169,7 @@ def delete(self, force: Optional[bool] = False):
"""
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.DROP_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.DROP_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
"force": force,
Expand All @@ -194,7 +194,7 @@ def disable(self):
"""
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
},
Expand All @@ -206,7 +206,7 @@ def enable(self):
"""
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
},
Expand Down Expand Up @@ -273,7 +273,7 @@ def set_attributes(self, attributes: AgentAttributes) -> None:
}
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTES",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTES",
keyword_parameters=parameters,
)
self.attributes = self._get_attributes(agent_name=self.agent_name)
Expand All @@ -290,7 +290,7 @@ def set_attribute(self, attribute_name: str, attribute_value: Any) -> None:
}
with cursor() as cr:
cr.callproc(
"DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTE",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTE",
keyword_parameters=parameters,
)
self.attributes = self._get_attributes(agent_name=self.agent_name)
Expand Down Expand Up @@ -369,15 +369,15 @@ async def create(
async with async_cursor() as cr:
try:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
keyword_parameters=parameters,
)
except oracledb.Error as err:
(err_obj,) = err.args
if err_obj.code in (20050, 20052) and replace:
await self.delete(force=True)
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
keyword_parameters=parameters,
)
else:
Expand All @@ -392,7 +392,7 @@ async def delete(self, force: Optional[bool] = False):
"""
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.DROP_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.DROP_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
"force": force,
Expand All @@ -419,7 +419,7 @@ async def disable(self):
"""
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.DISABLE_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
},
Expand All @@ -431,7 +431,7 @@ async def enable(self):
"""
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.ENABLE_AGENT",
keyword_parameters={
"agent_name": self.agent_name,
},
Expand Down Expand Up @@ -500,7 +500,7 @@ async def set_attributes(self, attributes: AgentAttributes) -> None:
}
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTES",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTES",
keyword_parameters=parameters,
)
self.attributes = await self._get_attributes(
Expand All @@ -521,7 +521,7 @@ async def set_attribute(
}
async with async_cursor() as cr:
await cr.callproc(
"DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTE",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.SET_ATTRIBUTE",
keyword_parameters=parameters,
)
self.attributes = await self._get_attributes(
Expand Down
4 changes: 2 additions & 2 deletions src/select_ai/agent/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_definition(object_type: str, object_name: str) -> Optional[str]:
"""
with cursor() as cr:
data = cr.callfunc(
"DBMS_CLOUD_AI_AGENT.GET_DEFINITION",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.GET_DEFINITION",
oracledb.DB_TYPE_CLOB,
keyword_parameters={
"object_type": object_type,
Expand All @@ -42,7 +42,7 @@ async def async_get_definition(
"""
async with async_cursor() as cr:
data = await cr.callfunc(
"DBMS_CLOUD_AI_AGENT.GET_DEFINITION",
"C##CLOUD$SERVICE.DBMS_CLOUD_AI_AGENT.GET_DEFINITION",
oracledb.DB_TYPE_CLOB,
keyword_parameters={
"object_type": object_type,
Expand Down
21 changes: 12 additions & 9 deletions src/select_ai/agent/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

@dataclass
class TeamHistoryEvent(SelectAIDataClass):
"""One row from ``USER_AI_AGENT_TEAM_HISTORY``."""
"""One row from ``C##CLOUD$SERVICE.USER_AI_AGENT_TEAM_HISTORY``."""

team_exec_id: str
team_name: str
Expand All @@ -46,7 +46,7 @@ class TeamHistoryEvent(SelectAIDataClass):

@dataclass
class TaskHistoryEvent(SelectAIDataClass):
"""One row from ``USER_AI_AGENT_TASK_HISTORY``."""
"""One row from ``C##CLOUD$SERVICE.USER_AI_AGENT_TASK_HISTORY``."""

team_exec_id: str
team_name: str
Expand All @@ -63,7 +63,7 @@ class TaskHistoryEvent(SelectAIDataClass):

@dataclass
class ToolHistoryEvent(SelectAIDataClass):
"""One row from ``USER_AI_AGENT_TOOL_HISTORY``."""
"""One row from ``C##CLOUD$SERVICE.USER_AI_AGENT_TOOL_HISTORY``."""

invocation_id: int
team_exec_id: str
Expand Down Expand Up @@ -151,7 +151,7 @@ async def _async_events(


class TeamHistory:
"""Read runs from ``USER_AI_AGENT_TEAM_HISTORY``."""
"""Read runs from ``C##CLOUD$SERVICE.USER_AI_AGENT_TEAM_HISTORY``."""

@classmethod
def list(
Expand All @@ -170,7 +170,7 @@ def list(


class TaskHistory:
"""Read task runs from ``USER_AI_AGENT_TASK_HISTORY``."""
"""Read task runs from ``C##CLOUD$SERVICE.USER_AI_AGENT_TASK_HISTORY``."""

@classmethod
def list(
Expand All @@ -196,7 +196,7 @@ def list(


class ToolHistory:
"""Read tool calls from ``USER_AI_AGENT_TOOL_HISTORY``."""
"""Read tool calls from ``C##CLOUD$SERVICE.USER_AI_AGENT_TOOL_HISTORY``."""

@classmethod
def list(
Expand All @@ -222,7 +222,8 @@ def list(


class AsyncTeamHistory:
"""Asynchronously read runs from ``USER_AI_AGENT_TEAM_HISTORY``."""
"""Asynchronously read runs from
``C##CLOUD$SERVICE.USER_AI_AGENT_TEAM_HISTORY``."""

@classmethod
async def list(
Expand All @@ -242,7 +243,8 @@ async def list(


class AsyncTaskHistory:
"""Asynchronously read task runs from ``USER_AI_AGENT_TASK_HISTORY``."""
"""Asynchronously read task runs from
``C##CLOUD$SERVICE.USER_AI_AGENT_TASK_HISTORY``."""

@classmethod
async def list(
Expand All @@ -269,7 +271,8 @@ async def list(


class AsyncToolHistory:
"""Asynchronously read tool calls from ``USER_AI_AGENT_TOOL_HISTORY``."""
"""Asynchronously read tool calls from
``C##CLOUD$SERVICE.USER_AI_AGENT_TOOL_HISTORY``."""

@classmethod
async def list(
Expand Down
30 changes: 15 additions & 15 deletions src/select_ai/agent/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,84 @@

GET_USER_AI_AGENT = """
SELECT a.agent_name, a.description
from USER_AI_AGENTS a
from C##CLOUD$SERVICE.USER_AI_AGENTS a
where a.agent_name = :agent_name
"""

GET_USER_AI_AGENT_ATTRIBUTES = """
SELECT attribute_name, attribute_value
FROM USER_AI_AGENT_ATTRIBUTES
FROM C##CLOUD$SERVICE.USER_AI_AGENT_ATTRIBUTES
WHERE agent_name = :agent_name
"""

LIST_USER_AI_AGENTS = """
SELECT a.agent_name, a.description
from USER_AI_AGENTS a
from C##CLOUD$SERVICE.USER_AI_AGENTS a
where REGEXP_LIKE(a.agent_name, :agent_name_pattern, 'i')
"""

GET_USER_AI_AGENT_TASK = """
SELECT t.task_name, t.description
FROM USER_AI_AGENT_TASKS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TASKS t
WHERE t.task_name= :task_name
"""

GET_USER_AI_AGENT_TASK_ATTRIBUTES = """
SELECT attribute_name, attribute_value
FROM USER_AI_AGENT_TASK_ATTRIBUTES
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TASK_ATTRIBUTES
WHERE task_name= :task_name
"""

LIST_USER_AI_AGENT_TASKS = """
SELECT t.task_name, t.description
FROM USER_AI_AGENT_TASKS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TASKS t
WHERE REGEXP_LIKE(t.task_name, :task_name_pattern, 'i')
"""

GET_USER_AI_AGENT_TOOL = """
SELECT t.tool_name, t.description
FROM USER_AI_AGENT_TOOLS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TOOLS t
WHERE t.tool_name = :tool_name
"""

GET_USER_AI_AGENT_TOOL_ATTRIBUTES = """
SELECT attribute_name, attribute_value
FROM USER_AI_AGENT_TOOL_ATTRIBUTES
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TOOL_ATTRIBUTES
WHERE tool_name = :tool_name
"""

LIST_USER_AI_AGENT_TOOLS = """
SELECT t.tool_name, t.description
FROM USER_AI_AGENT_TOOLS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TOOLS t
WHERE REGEXP_LIKE(t.tool_name, :tool_name_pattern, 'i')
"""


GET_USER_AI_AGENT_TEAM = """
SELECT t.agent_team_name as team_name, t.description
FROM USER_AI_AGENT_TEAMS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TEAMS t
WHERE t.agent_team_name = :team_name
"""


GET_USER_AI_AGENT_TEAM_ATTRIBUTES = """
SELECT attribute_name, attribute_value
FROM USER_AI_AGENT_TEAM_ATTRIBUTES
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TEAM_ATTRIBUTES
WHERE agent_team_name = :team_name
"""


LIST_USER_AI_AGENT_TEAMS = """
SELECT t.AGENT_TEAM_NAME as team_name, description
FROM USER_AI_AGENT_TEAMS t
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TEAMS t
WHERE REGEXP_LIKE(t.AGENT_TEAM_NAME, :team_name_pattern, 'i')
"""


LIST_USER_AI_AGENT_TEAM_HISTORY = """
SELECT team_exec_id, team_name, state, start_date, end_date, conversation_id,
params
FROM user_ai_agent_team_history
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TEAM_HISTORY
WHERE (:team_name IS NULL OR team_name = :team_name)
AND (:team_exec_id IS NULL OR team_exec_id = :team_exec_id)
ORDER BY start_date DESC NULLS LAST
Expand All @@ -95,7 +95,7 @@
LIST_USER_AI_AGENT_TASK_HISTORY = """
SELECT team_exec_id, team_name, task_order, agent_name, task_name,
conversation_params, input, result, state, start_date, end_date
FROM user_ai_agent_task_history
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TASK_HISTORY
WHERE (:team_name IS NULL OR team_name = :team_name)
AND (:task_name IS NULL OR task_name = :task_name)
AND (:agent_name IS NULL OR agent_name = :agent_name)
Expand All @@ -107,7 +107,7 @@
LIST_USER_AI_AGENT_TOOL_HISTORY = """
SELECT invocation_id, team_exec_id, task_order, tool_name, agent_name,
task_name, start_date, end_date, input, output, tool_output
FROM user_ai_agent_tool_history
FROM C##CLOUD$SERVICE.USER_AI_AGENT_TOOL_HISTORY
WHERE (:tool_name IS NULL OR tool_name = :tool_name)
AND (:task_name IS NULL OR task_name = :task_name)
AND (:agent_name IS NULL OR agent_name = :agent_name)
Expand Down
Loading