select-ai 1.2.0rc3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
select_ai/__init__.py ADDED
@@ -0,0 +1,66 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+ from .action import Action
9
+ from .async_profile import AsyncProfile
10
+ from .base_profile import BaseProfile, ProfileAttributes
11
+ from .conversation import (
12
+ AsyncConversation,
13
+ Conversation,
14
+ ConversationAttributes,
15
+ )
16
+ from .credential import (
17
+ async_create_credential,
18
+ async_delete_credential,
19
+ create_credential,
20
+ delete_credential,
21
+ )
22
+ from .db import (
23
+ async_connect,
24
+ async_cursor,
25
+ async_disconnect,
26
+ async_is_connected,
27
+ connect,
28
+ cursor,
29
+ disconnect,
30
+ is_connected,
31
+ )
32
+ from .errors import *
33
+ from .privilege import (
34
+ async_grant_http_access,
35
+ async_grant_privileges,
36
+ async_revoke_http_access,
37
+ async_revoke_privileges,
38
+ grant_http_access,
39
+ grant_privileges,
40
+ revoke_http_access,
41
+ revoke_privileges,
42
+ )
43
+ from .profile import Profile
44
+ from .provider import (
45
+ AnthropicProvider,
46
+ AWSProvider,
47
+ AzureProvider,
48
+ CohereProvider,
49
+ GoogleProvider,
50
+ HuggingFaceProvider,
51
+ OCIGenAIProvider,
52
+ OpenAIProvider,
53
+ Provider,
54
+ )
55
+ from .synthetic_data import (
56
+ SyntheticDataAttributes,
57
+ SyntheticDataParams,
58
+ )
59
+ from .vector_index import (
60
+ AsyncVectorIndex,
61
+ OracleVectorIndexAttributes,
62
+ VectorDistanceMetric,
63
+ VectorIndex,
64
+ VectorIndexAttributes,
65
+ )
66
+ from .version import __version__ as __version__
select_ai/_abc.py ADDED
@@ -0,0 +1,82 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+ import json
9
+ import typing
10
+ from abc import ABC
11
+ from dataclasses import dataclass, fields
12
+ from typing import Any, List, Mapping
13
+
14
+ __all__ = ["SelectAIDataClass"]
15
+
16
+
17
+ def _bool(value: Any) -> bool:
18
+ if isinstance(value, bool):
19
+ return value
20
+ if isinstance(value, int):
21
+ return bool(value)
22
+ if value.lower() in ("yes", "true", "t", "y", "1"):
23
+ return True
24
+ elif value.lower() in ("no", "false", "f", "n", "0"):
25
+ return False
26
+ else:
27
+ raise ValueError(f"Invalid boolean value: {value}")
28
+
29
+
30
+ def _is_json(field, value) -> bool:
31
+ if field.type in (
32
+ typing.List[Mapping],
33
+ typing.Optional[Mapping],
34
+ typing.Optional[List[str]],
35
+ typing.Optional[List[typing.Mapping]],
36
+ ) and isinstance(value, (str, bytes, bytearray)):
37
+ return True
38
+ return False
39
+
40
+
41
+ @dataclass
42
+ class SelectAIDataClass(ABC):
43
+ """SelectAIDataClass is an abstract container for all data
44
+ models defined in the select_ai Python module
45
+ """
46
+
47
+ def __getitem__(self, item):
48
+ return getattr(self, item)
49
+
50
+ def __setitem__(self, key, value):
51
+ setattr(self, key, value)
52
+
53
+ @classmethod
54
+ def keys(cls):
55
+ return set([field.name for field in fields(cls)])
56
+
57
+ def dict(self, exclude_null=True):
58
+ attributes = {}
59
+ for k, v in self.__dict__.items():
60
+ if v is not None or not exclude_null:
61
+ attributes[k] = v
62
+ return attributes
63
+
64
+ def json(self, exclude_null=True):
65
+ return json.dumps(self.dict(exclude_null=exclude_null))
66
+
67
+ def __post_init__(self):
68
+ for field in fields(self):
69
+ value = getattr(self, field.name)
70
+ if value is not None:
71
+ if field.type is typing.Optional[int]:
72
+ setattr(self, field.name, int(value))
73
+ elif field.type is typing.Optional[str]:
74
+ setattr(self, field.name, str(value))
75
+ elif field.type is typing.Optional[bool]:
76
+ setattr(self, field.name, _bool(value))
77
+ elif field.type is typing.Optional[float]:
78
+ setattr(self, field.name, float(value))
79
+ elif _is_json(field, value):
80
+ setattr(self, field.name, json.loads(value))
81
+ else:
82
+ setattr(self, field.name, value)
select_ai/_enums.py ADDED
@@ -0,0 +1,14 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+ import enum
9
+
10
+
11
+ class StrEnum(str, enum.Enum):
12
+
13
+ def __str__(self):
14
+ return self.value
@@ -0,0 +1,123 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+ import inspect
9
+ from collections.abc import Mapping, Sequence, Set
10
+ from functools import wraps
11
+ from typing import Any, get_args, get_origin, get_type_hints
12
+
13
+ NoneType = type(None)
14
+
15
+
16
+ def _match(value, annot) -> bool:
17
+ """Recursively validate value against a typing annotation."""
18
+ if annot is Any:
19
+ return True
20
+
21
+ origin = get_origin(annot)
22
+ args = get_args(annot)
23
+
24
+ # Handle Annotated[T, ...] → treat as T
25
+ if origin is getattr(__import__("typing"), "Annotated", None):
26
+ annot = args[0]
27
+ origin = get_origin(annot)
28
+ args = get_args(annot)
29
+
30
+ # Optional[T] is Union[T, NoneType]
31
+ if origin is getattr(__import__("typing"), "Union", None):
32
+ return any(_match(value, a) for a in args)
33
+
34
+ # Literal[…]
35
+ if origin is getattr(__import__("typing"), "Literal", None):
36
+ return any(value == lit for lit in args)
37
+
38
+ # Tuple cases
39
+ if origin is tuple:
40
+ if not isinstance(value, tuple):
41
+ return False
42
+ if len(args) == 2 and args[1] is Ellipsis:
43
+ # tuple[T, ...]
44
+ return all(_match(v, args[0]) for v in value)
45
+ if len(args) != len(value):
46
+ return False
47
+ return all(_match(v, a) for v, a in zip(value, args))
48
+
49
+ # Mappings (dict-like)
50
+ if origin in (dict, Mapping):
51
+ if not isinstance(value, Mapping):
52
+ return False
53
+ k_annot, v_annot = args if args else (Any, Any)
54
+ return all(
55
+ _match(k, k_annot) and _match(v, v_annot) for k, v in value.items()
56
+ )
57
+
58
+ # Sequences (list, Sequence) – but not str/bytes
59
+ if origin in (list, Sequence):
60
+ if isinstance(value, (str, bytes)):
61
+ return False
62
+ if not isinstance(value, Sequence):
63
+ return False
64
+ elem_annot = args[0] if args else Any
65
+ return all(_match(v, elem_annot) for v in value)
66
+
67
+ # Sets
68
+ if origin in (set, frozenset, Set):
69
+ if not isinstance(value, (set, frozenset)):
70
+ return False
71
+ elem_annot = args[0] if args else Any
72
+ return all(_match(v, elem_annot) for v in value)
73
+
74
+ # Fall back to normal isinstance for non-typing classes
75
+ if isinstance(annot, type):
76
+ return isinstance(value, annot)
77
+
78
+ # If annot is a typing alias like 'list' without args
79
+ if origin is not None:
80
+ # Treat bare containers as accepting anything inside
81
+ return isinstance(value, origin)
82
+
83
+ # Unknown/unsupported typing form: accept conservatively
84
+ return True
85
+
86
+
87
+ def enforce_types(func):
88
+ # Resolve ForwardRefs using function globals (handles "User" as a string, etc.)
89
+ hints = get_type_hints(
90
+ func, globalns=func.__globals__, include_extras=True
91
+ )
92
+ sig = inspect.signature(func)
93
+
94
+ def _check(bound):
95
+ for name, val in bound.arguments.items():
96
+ if name in hints:
97
+ annot = hints[name]
98
+ if not _match(val, annot):
99
+ raise TypeError(
100
+ f"Argument '{name}' failed type check: expected {annot!r}, "
101
+ f"got {type(val).__name__} -> {val!r}"
102
+ )
103
+
104
+ if inspect.iscoroutinefunction(func):
105
+
106
+ @wraps(func)
107
+ async def aw(*args, **kwargs):
108
+ bound = sig.bind(*args, **kwargs)
109
+ bound.apply_defaults()
110
+ _check(bound)
111
+ return await func(*args, **kwargs)
112
+
113
+ return aw
114
+ else:
115
+
116
+ @wraps(func)
117
+ def w(*args, **kwargs):
118
+ bound = sig.bind(*args, **kwargs)
119
+ bound.apply_defaults()
120
+ _check(bound)
121
+ return func(*args, **kwargs)
122
+
123
+ return w
select_ai/action.py ADDED
@@ -0,0 +1,23 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+ from select_ai._enums import StrEnum
9
+
10
+ __all__ = ["Action"]
11
+
12
+
13
+ class Action(StrEnum):
14
+ """Supported Select AI actions"""
15
+
16
+ RUNSQL = "runsql"
17
+ SHOWSQL = "showsql"
18
+ EXPLAINSQL = "explainsql"
19
+ NARRATE = "narrate"
20
+ CHAT = "chat"
21
+ SHOWPROMPT = "showprompt"
22
+ FEEDBACK = "feedback"
23
+ SUMMARIZE = "summarize"
@@ -0,0 +1,25 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright (c) 2025, Oracle and/or its affiliates.
3
+ #
4
+ # Licensed under the Universal Permissive License v 1.0 as shown at
5
+ # http://oss.oracle.com/licenses/upl.
6
+ # -----------------------------------------------------------------------------
7
+
8
+
9
+ from .core import Agent, AgentAttributes, AsyncAgent
10
+ from .task import AsyncTask, Task, TaskAttributes
11
+ from .team import AsyncTeam, Team, TeamAttributes
12
+ from .tool import (
13
+ AsyncTool,
14
+ EmailNotificationToolParams,
15
+ HTTPToolParams,
16
+ HumanToolParams,
17
+ RAGToolParams,
18
+ SlackNotificationToolParams,
19
+ SQLToolParams,
20
+ Tool,
21
+ ToolAttributes,
22
+ ToolParams,
23
+ ToolType,
24
+ WebSearchToolParams,
25
+ )