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
2 changes: 1 addition & 1 deletion samples/async/vector_index_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def main():
description="Vector index for conda environments",
profile=async_profile,
)
await async_vector_index.create(replace=True)
await async_vector_index.create(replace=True, wait_for_completion=True)
print("Created vector index: test_vector_index")


Expand Down
1 change: 1 addition & 0 deletions samples/async/vector_index_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def main():
)
print(async_vector_index.attributes)
print(async_vector_index.profile)
print(await async_vector_index.get_next_refresh_timestamp())


asyncio.run(main())
2 changes: 1 addition & 1 deletion samples/vector_index_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
description="Test vector index",
profile=profile,
)
vector_index.create(replace=True)
vector_index.create(replace=True, wait_for_completion=True)
print("Created vector index: test_vector_index")
1 change: 1 addition & 0 deletions samples/vector_index_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
vector_index = select_ai.VectorIndex.fetch(index_name="test_vector_index")
print(vector_index.attributes)
print(vector_index.profile)
print(vector_index.get_next_refresh_timestamp())
4 changes: 3 additions & 1 deletion src/select_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
# Copyright (c) 2026, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
Expand All @@ -25,6 +25,8 @@
async_disconnect,
async_is_connected,
connect,
create_pool,
create_pool_async,
cursor,
disconnect,
is_connected,
Expand Down
2 changes: 1 addition & 1 deletion src/select_ai/_abc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
# Copyright (c) 2026, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
Expand Down
2 changes: 1 addition & 1 deletion src/select_ai/_enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
# Copyright (c) 2026, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
Expand Down
2 changes: 1 addition & 1 deletion src/select_ai/_validations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
# Copyright (c) 2026, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
Expand Down
2 changes: 1 addition & 1 deletion src/select_ai/action.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
# Copyright (c) 2026, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
Expand Down
39 changes: 14 additions & 25 deletions src/select_ai/agent/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
LIST_USER_AI_AGENTS,
)
from select_ai.db import async_cursor, cursor
from select_ai.errors import AgentNotFoundError
from select_ai.errors import AgentAttributesEmptyError, AgentNotFoundError


@dataclass
Expand Down Expand Up @@ -97,7 +97,7 @@ def _get_attributes(agent_name: str) -> AgentAttributes:
post_processed_attributes[k] = v
return AgentAttributes(**post_processed_attributes)
else:
raise AgentNotFoundError(agent_name=agent_name)
raise AgentAttributesEmptyError(agent_name=agent_name)

@staticmethod
def _get_description(agent_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -223,7 +223,10 @@ def fetch(cls, agent_name: str) -> "Agent":
If the AI Agent is not found

"""
attributes = cls._get_attributes(agent_name=agent_name)
try:
attributes = cls._get_attributes(agent_name=agent_name)
except AgentAttributesEmptyError:
attributes = None
description = cls._get_description(agent_name=agent_name)
return cls(
agent_name=agent_name,
Expand Down Expand Up @@ -251,16 +254,7 @@ def list(
)
for row in cr.fetchall():
agent_name = row[0]
if row[1]:
description = row[1].read() # Oracle.LOB
else:
description = None
attributes = cls._get_attributes(agent_name=agent_name)
yield cls(
agent_name=agent_name,
description=description,
attributes=attributes,
)
yield cls.fetch(agent_name=agent_name)

def set_attributes(self, attributes: AgentAttributes) -> None:
"""
Expand Down Expand Up @@ -326,7 +320,7 @@ async def _get_attributes(agent_name: str) -> AgentAttributes:
post_processed_attributes[k] = v
return AgentAttributes(**post_processed_attributes)
else:
raise AgentNotFoundError(agent_name=agent_name)
raise AgentAttributesEmptyError(agent_name=agent_name)

@staticmethod
async def _get_description(agent_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -454,7 +448,10 @@ async def fetch(cls, agent_name: str) -> "AsyncAgent":
If the AI Agent is not found

"""
attributes = await cls._get_attributes(agent_name=agent_name)
try:
attributes = await cls._get_attributes(agent_name=agent_name)
except AgentAttributesEmptyError:
attributes = None
description = await cls._get_description(agent_name=agent_name)
return cls(
agent_name=agent_name,
Expand Down Expand Up @@ -483,16 +480,8 @@ async def list(
rows = await cr.fetchall()
for row in rows:
agent_name = row[0]
if row[1]:
description = await row[1].read() # Oracle.AsyncLOB
else:
description = None
attributes = await cls._get_attributes(agent_name=agent_name)
yield cls(
agent_name=agent_name,
description=description,
attributes=attributes,
)
agent = await cls.fetch(agent_name=agent_name)
yield agent

async def set_attributes(self, attributes: AgentAttributes) -> None:
"""
Expand Down
35 changes: 22 additions & 13 deletions src/select_ai/agent/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,30 @@
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

import json
from abc import ABC
from dataclasses import dataclass
from typing import (
Any,
AsyncGenerator,
Iterator,
List,
Mapping,
Optional,
Union,
)

import oracledb

from select_ai import BaseProfile
from select_ai._abc import SelectAIDataClass
from select_ai._enums import StrEnum
from select_ai.agent.sql import (
GET_USER_AI_AGENT_TASK,
GET_USER_AI_AGENT_TASK_ATTRIBUTES,
LIST_USER_AI_AGENT_TASKS,
)
from select_ai.async_profile import AsyncProfile
from select_ai.db import async_cursor, cursor
from select_ai.errors import AgentTaskNotFoundError
from select_ai.profile import Profile
from select_ai.errors import (
AgentTaskAttributesEmptyError,
AgentTaskNotFoundError,
)


@dataclass
Expand Down Expand Up @@ -111,7 +108,7 @@ def _get_attributes(task_name: str) -> TaskAttributes:
post_processed_attributes[k] = v
return TaskAttributes(**post_processed_attributes)
else:
raise AgentTaskNotFoundError(task_name=task_name)
raise AgentTaskAttributesEmptyError(task_name=task_name)

@staticmethod
def _get_description(task_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -244,7 +241,10 @@ def list(cls, task_name_pattern: Optional[str] = ".*") -> Iterator["Task"]:
description = row[1].read() # Oracle.LOB
else:
description = None
attributes = cls._get_attributes(task_name=task_name)
try:
attributes = cls._get_attributes(task_name=task_name)
except AgentTaskAttributesEmptyError:
attributes = None
yield cls(
task_name=task_name,
description=description,
Expand All @@ -264,7 +264,10 @@ def fetch(cls, task_name: str) -> "Task":
:raises select_ai.errors.AgentTaskNotFoundError:
If the AI Task is not found
"""
attributes = cls._get_attributes(task_name=task_name)
try:
attributes = cls._get_attributes(task_name=task_name)
except AgentTaskAttributesEmptyError:
attributes = None
description = cls._get_description(task_name=task_name)
return cls(
task_name=task_name,
Expand Down Expand Up @@ -338,7 +341,7 @@ async def _get_attributes(task_name: str) -> TaskAttributes:
post_processed_attributes[k] = v
return TaskAttributes(**post_processed_attributes)
else:
raise AgentTaskNotFoundError(task_name=task_name)
raise AgentTaskAttributesEmptyError(task_name=task_name)

@staticmethod
async def _get_description(task_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -476,7 +479,10 @@ async def list(
description = await row[1].read() # Oracle.AsyncLOB
else:
description = None
attributes = await cls._get_attributes(task_name=task_name)
try:
attributes = await cls._get_attributes(task_name=task_name)
except AgentTaskAttributesEmptyError:
attributes = None
yield cls(
task_name=task_name,
description=description,
Expand All @@ -496,7 +502,10 @@ async def fetch(cls, task_name: str) -> "AsyncTask":
:raises select_ai.errors.AgentTaskNotFoundError:
If the AI Task is not found
"""
attributes = await cls._get_attributes(task_name=task_name)
try:
attributes = await cls._get_attributes(task_name=task_name)
except AgentTaskAttributesEmptyError:
attributes = None
description = await cls._get_description(task_name=task_name)
return cls(
task_name=task_name,
Expand Down
33 changes: 22 additions & 11 deletions src/select_ai/agent/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@

import oracledb

from select_ai import BaseProfile
from select_ai._abc import SelectAIDataClass
from select_ai._enums import StrEnum
from select_ai.agent.sql import (
GET_USER_AI_AGENT_TEAM,
GET_USER_AI_AGENT_TEAM_ATTRIBUTES,
LIST_USER_AI_AGENT_TEAMS,
)
from select_ai.async_profile import AsyncProfile
from select_ai.db import async_cursor, cursor
from select_ai.errors import AgentTeamNotFoundError
from select_ai.profile import Profile
from select_ai.errors import (
AgentTeamAttributesEmptyError,
AgentTeamNotFoundError,
)


@dataclass
Expand Down Expand Up @@ -105,7 +104,7 @@ def _get_attributes(team_name: str) -> TeamAttributes:
post_processed_attributes[k] = v
return TeamAttributes(**post_processed_attributes)
else:
raise AgentTeamNotFoundError(team_name=team_name)
raise AgentTeamAttributesEmptyError(team_name=team_name)

@staticmethod
def _get_description(team_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -228,7 +227,10 @@ def fetch(cls, team_name: str) -> "Team":
:raises select_ai.errors.AgentTeamNotFoundError:
If the AI Team is not found
"""
attributes = cls._get_attributes(team_name)
try:
attributes = cls._get_attributes(team_name)
except AgentTeamAttributesEmptyError:
attributes = None
description = cls._get_description(team_name)
return cls(
team_name=team_name,
Expand Down Expand Up @@ -259,7 +261,10 @@ def list(cls, team_name_pattern: Optional[str] = ".*") -> Iterator["Team"]:
description = row[1].read() # Oracle.LOB
else:
description = None
attributes = cls._get_attributes(team_name=team_name)
try:
attributes = cls._get_attributes(team_name=team_name)
except AgentTeamAttributesEmptyError:
attributes = None
yield cls(
team_name=team_name,
description=description,
Expand Down Expand Up @@ -369,7 +374,7 @@ async def _get_attributes(team_name: str) -> TeamAttributes:
post_processed_attributes[k] = v
return TeamAttributes(**post_processed_attributes)
else:
raise AgentTeamNotFoundError(team_name=team_name)
raise AgentTeamAttributesEmptyError(team_name=team_name)

@staticmethod
async def _get_description(team_name: str) -> Union[str, None]:
Expand Down Expand Up @@ -494,7 +499,10 @@ async def fetch(cls, team_name: str) -> "AsyncTeam":
:raises select_ai.errors.AgentTeamNotFoundError:
If the AI Team is not found
"""
attributes = await cls._get_attributes(team_name)
try:
attributes = await cls._get_attributes(team_name)
except AgentTeamAttributesEmptyError:
attributes = None
description = await cls._get_description(team_name)
return cls(
team_name=team_name,
Expand Down Expand Up @@ -528,7 +536,10 @@ async def list(
description = await row[1].read() # Oracle.AsyncLOB
else:
description = None
attributes = await cls._get_attributes(team_name=team_name)
try:
attributes = await cls._get_attributes(team_name=team_name)
except AgentTeamAttributesEmptyError:
attributes = None
yield cls(
team_name=team_name,
description=description,
Expand Down
Loading