select-ai 1.0.0__tar.gz

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.

Potentially problematic release.


This version of select-ai might be problematic. Click here for more details.

Files changed (70) hide show
  1. select_ai-1.0.0/LICENSE.txt +35 -0
  2. select_ai-1.0.0/MANIFEST.in +2 -0
  3. select_ai-1.0.0/PKG-INFO +125 -0
  4. select_ai-1.0.0/README.md +92 -0
  5. select_ai-1.0.0/pyproject.toml +66 -0
  6. select_ai-1.0.0/samples/async/conversation_chat_session.py +49 -0
  7. select_ai-1.0.0/samples/async/conversations_list.py +31 -0
  8. select_ai-1.0.0/samples/async/create_ai_credential.py +44 -0
  9. select_ai-1.0.0/samples/async/delete_ai_credential.py +32 -0
  10. select_ai-1.0.0/samples/async/disable_ai_provider.py +33 -0
  11. select_ai-1.0.0/samples/async/enable_ai_provider.py +33 -0
  12. select_ai-1.0.0/samples/async/profile_chat.py +41 -0
  13. select_ai-1.0.0/samples/async/profile_create.py +50 -0
  14. select_ai-1.0.0/samples/async/profile_explain_sql.py +31 -0
  15. select_ai-1.0.0/samples/async/profile_gen_multi_table_synthetic_data.py +48 -0
  16. select_ai-1.0.0/samples/async/profile_gen_single_table_synthetic_data.py +41 -0
  17. select_ai-1.0.0/samples/async/profile_pipeline.py +54 -0
  18. select_ai-1.0.0/samples/async/profile_run_sql.py +35 -0
  19. select_ai-1.0.0/samples/async/profile_show_sql.py +33 -0
  20. select_ai-1.0.0/samples/async/profile_sql_concurrent_tasks.py +42 -0
  21. select_ai-1.0.0/samples/async/profiles_list.py +35 -0
  22. select_ai-1.0.0/samples/async/vector_index_create.py +58 -0
  23. select_ai-1.0.0/samples/async/vector_index_delete.py +29 -0
  24. select_ai-1.0.0/samples/async/vector_index_list.py +33 -0
  25. select_ai-1.0.0/samples/async/vector_index_rag.py +35 -0
  26. select_ai-1.0.0/samples/conversation_chat_session.py +41 -0
  27. select_ai-1.0.0/samples/conversation_create.py +31 -0
  28. select_ai-1.0.0/samples/conversation_delete.py +30 -0
  29. select_ai-1.0.0/samples/conversations_list.py +25 -0
  30. select_ai-1.0.0/samples/create_ai_credential.py +38 -0
  31. select_ai-1.0.0/samples/delete_ai_credential.py +25 -0
  32. select_ai-1.0.0/samples/disable_ai_provider.py +27 -0
  33. select_ai-1.0.0/samples/enable_ai_provider.py +28 -0
  34. select_ai-1.0.0/samples/profile_chat.py +25 -0
  35. select_ai-1.0.0/samples/profile_create.py +43 -0
  36. select_ai-1.0.0/samples/profile_delete.py +22 -0
  37. select_ai-1.0.0/samples/profile_explain_sql.py +26 -0
  38. select_ai-1.0.0/samples/profile_gen_multi_table_synthetic_data.py +42 -0
  39. select_ai-1.0.0/samples/profile_gen_single_table_synthetic_data.py +35 -0
  40. select_ai-1.0.0/samples/profile_narrate.py +27 -0
  41. select_ai-1.0.0/samples/profile_run_sql.py +26 -0
  42. select_ai-1.0.0/samples/profile_show_sql.py +25 -0
  43. select_ai-1.0.0/samples/profiles_list.py +27 -0
  44. select_ai-1.0.0/samples/vector_index_create.py +60 -0
  45. select_ai-1.0.0/samples/vector_index_delete.py +23 -0
  46. select_ai-1.0.0/samples/vector_index_list.py +27 -0
  47. select_ai-1.0.0/samples/vector_index_rag.py +25 -0
  48. select_ai-1.0.0/setup.cfg +4 -0
  49. select_ai-1.0.0/src/select_ai/__init__.py +59 -0
  50. select_ai-1.0.0/src/select_ai/_abc.py +77 -0
  51. select_ai-1.0.0/src/select_ai/_enums.py +14 -0
  52. select_ai-1.0.0/src/select_ai/_validations.py +123 -0
  53. select_ai-1.0.0/src/select_ai/action.py +21 -0
  54. select_ai-1.0.0/src/select_ai/async_profile.py +534 -0
  55. select_ai-1.0.0/src/select_ai/base_profile.py +184 -0
  56. select_ai-1.0.0/src/select_ai/conversation.py +274 -0
  57. select_ai-1.0.0/src/select_ai/credential.py +135 -0
  58. select_ai-1.0.0/src/select_ai/db.py +186 -0
  59. select_ai-1.0.0/src/select_ai/errors.py +73 -0
  60. select_ai-1.0.0/src/select_ai/profile.py +460 -0
  61. select_ai-1.0.0/src/select_ai/provider.py +293 -0
  62. select_ai-1.0.0/src/select_ai/sql.py +105 -0
  63. select_ai-1.0.0/src/select_ai/synthetic_data.py +90 -0
  64. select_ai-1.0.0/src/select_ai/vector_index.py +562 -0
  65. select_ai-1.0.0/src/select_ai/version.py +8 -0
  66. select_ai-1.0.0/src/select_ai.egg-info/PKG-INFO +125 -0
  67. select_ai-1.0.0/src/select_ai.egg-info/SOURCES.txt +68 -0
  68. select_ai-1.0.0/src/select_ai.egg-info/dependency_links.txt +1 -0
  69. select_ai-1.0.0/src/select_ai.egg-info/requires.txt +2 -0
  70. select_ai-1.0.0/src/select_ai.egg-info/top_level.txt +1 -0
@@ -0,0 +1,35 @@
1
+ Copyright (c) 2025, Oracle and/or its affiliates.
2
+
3
+ The Universal Permissive License (UPL), Version 1.0
4
+
5
+ Subject to the condition set forth below, permission is hereby granted to any
6
+ person obtaining a copy of this software, associated documentation and/or data
7
+ (collectively the "Software"), free of charge and under any and all copyright
8
+ rights in the Software, and any and all patent rights owned or freely
9
+ licensable by each licensor hereunder covering either (i) the unmodified
10
+ Software as contributed to or provided by such licensor, or (ii) the Larger
11
+ Works (as defined below), to deal in both
12
+
13
+ (a) the Software, and
14
+ (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15
+ one is included with the Software (each a "Larger Work" to which the Software
16
+ is contributed by such licensors),
17
+
18
+ without restriction, including without limitation the rights to copy, create
19
+ derivative works of, display, perform, and distribute the Software and make,
20
+ use, sell, offer for sale, import, export, have made, and have sold the
21
+ Software and the Larger Work(s), and to sublicense the foregoing rights on
22
+ either these or other terms.
23
+
24
+ This license is subject to the following condition:
25
+ The above copyright notice and either this complete permission notice or at
26
+ a minimum a reference to the UPL must be included in all copies or
27
+ substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ recursive-include tests *.py
2
+ recursive-include samples *.py
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: select_ai
3
+ Version: 1.0.0
4
+ Summary: Select AI for Python
5
+ Author-email: Abhishek Singh <abhishek.o.singh@oracle.com>
6
+ Maintainer-email: Abhishek Singh <abhishek.o.singh@oracle.com>
7
+ License-Expression: UPL-1.0
8
+ Project-URL: Homepage, https://github.com/oracle/python-select-ai
9
+ Project-URL: Repository, https://github.com/oracle/python-select-ai
10
+ Project-URL: Issues, https://github.com/oracle/python-select-ai/issues
11
+ Project-URL: Documentation, https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/
12
+ Keywords: oracle,select-ai,adbs,autonomous database serverless
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: English
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE.txt
30
+ Requires-Dist: oracledb
31
+ Requires-Dist: pandas==2.2.3
32
+ Dynamic: license-file
33
+
34
+ # Select AI for Python
35
+
36
+
37
+ Select AI for Python enables you to ask questions of your database data using natural language (text-to-SQL), get generative AI responses using your trusted content (retrieval augmented generation), generate synthetic data using large language models, and other features – all from Python. With the general availability of Select AI Python, Python developers have access to the functionality of Select AI on Oracle Autonomous Database.
38
+
39
+ Select AI for Python enables you to leverage the broader Python ecosystem in combination with generative AI and database functionality - bridging the gap between the DBMS_CLOUD_AI PL/SQL package and Python's rich ecosystem. It provides intuitive objects and methods for AI model interaction.
40
+
41
+
42
+ ## Installation
43
+
44
+ Run
45
+ ```bash
46
+ python3 -m pip install select_ai
47
+ ```
48
+
49
+ ## Documentation
50
+
51
+ See [Select AI for Python documentation][documentation]
52
+
53
+ ## Samples
54
+
55
+ Examples can be found in the [/samples][samples] directory
56
+
57
+ ### Basic Example
58
+
59
+ ```python
60
+ import select_ai
61
+
62
+ user = "<your_select_ai_user>"
63
+ password = "<your_select_ai_password>"
64
+ dsn = "<your_select_ai_db_connect_string>"
65
+
66
+ select_ai.connect(user=user, password=password, dsn=dsn)
67
+ profile = select_ai.Profile(profile_name="oci_ai_profile")
68
+ # run_sql returns a pandas dataframe
69
+ df = profile.run_sql(prompt="How many promotions?")
70
+ print(df.columns)
71
+ print(df)
72
+ ```
73
+
74
+ ### Async Example
75
+
76
+ ```python
77
+
78
+ import asyncio
79
+
80
+ import select_ai
81
+
82
+ user = "<your_select_ai_user>"
83
+ password = "<your_select_ai_password>"
84
+ dsn = "<your_select_ai_db_connect_string>"
85
+
86
+ # This example shows how to asynchronously run sql
87
+ async def main():
88
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
89
+ async_profile = await select_ai.AsyncProfile(
90
+ profile_name="async_oci_ai_profile",
91
+ )
92
+ # run_sql returns a pandas df
93
+ df = await async_profile.run_sql("How many promotions?")
94
+ print(df)
95
+
96
+ asyncio.run(main())
97
+
98
+ ```
99
+ ## Help
100
+
101
+ Questions can be asked in [GitHub Discussions][ghdiscussions].
102
+
103
+ Problem reports can be raised in [GitHub Issues][ghissues].
104
+
105
+ ## Contributing
106
+
107
+ This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide][contributing]
108
+
109
+ ## Security
110
+
111
+ Please consult the [security guide][security] for our responsible security vulnerability disclosure process
112
+
113
+ ## License
114
+
115
+ Copyright (c) 2025 Oracle and/or its affiliates.
116
+
117
+ Released under the Universal Permissive License v1.0 as shown at
118
+ <https://oss.oracle.com/licenses/upl/>.
119
+
120
+ [contributing]: https://github.com/oracle/python-select-ai/blob/main/CONTRIBUTING.md
121
+ [documentation]: https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/
122
+ [ghdiscussions]: https://github.com/oracle/python-select-ai/discussions
123
+ [ghissues]: https://github.com/oracle/python-select-ai/issues
124
+ [samples]: https://github.com/oracle/python-select-ai/tree/main/samples
125
+ [security]: https://github.com/oracle/python-select-ai/blob/main/SECURITY.md
@@ -0,0 +1,92 @@
1
+ # Select AI for Python
2
+
3
+
4
+ Select AI for Python enables you to ask questions of your database data using natural language (text-to-SQL), get generative AI responses using your trusted content (retrieval augmented generation), generate synthetic data using large language models, and other features – all from Python. With the general availability of Select AI Python, Python developers have access to the functionality of Select AI on Oracle Autonomous Database.
5
+
6
+ Select AI for Python enables you to leverage the broader Python ecosystem in combination with generative AI and database functionality - bridging the gap between the DBMS_CLOUD_AI PL/SQL package and Python's rich ecosystem. It provides intuitive objects and methods for AI model interaction.
7
+
8
+
9
+ ## Installation
10
+
11
+ Run
12
+ ```bash
13
+ python3 -m pip install select_ai
14
+ ```
15
+
16
+ ## Documentation
17
+
18
+ See [Select AI for Python documentation][documentation]
19
+
20
+ ## Samples
21
+
22
+ Examples can be found in the [/samples][samples] directory
23
+
24
+ ### Basic Example
25
+
26
+ ```python
27
+ import select_ai
28
+
29
+ user = "<your_select_ai_user>"
30
+ password = "<your_select_ai_password>"
31
+ dsn = "<your_select_ai_db_connect_string>"
32
+
33
+ select_ai.connect(user=user, password=password, dsn=dsn)
34
+ profile = select_ai.Profile(profile_name="oci_ai_profile")
35
+ # run_sql returns a pandas dataframe
36
+ df = profile.run_sql(prompt="How many promotions?")
37
+ print(df.columns)
38
+ print(df)
39
+ ```
40
+
41
+ ### Async Example
42
+
43
+ ```python
44
+
45
+ import asyncio
46
+
47
+ import select_ai
48
+
49
+ user = "<your_select_ai_user>"
50
+ password = "<your_select_ai_password>"
51
+ dsn = "<your_select_ai_db_connect_string>"
52
+
53
+ # This example shows how to asynchronously run sql
54
+ async def main():
55
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
56
+ async_profile = await select_ai.AsyncProfile(
57
+ profile_name="async_oci_ai_profile",
58
+ )
59
+ # run_sql returns a pandas df
60
+ df = await async_profile.run_sql("How many promotions?")
61
+ print(df)
62
+
63
+ asyncio.run(main())
64
+
65
+ ```
66
+ ## Help
67
+
68
+ Questions can be asked in [GitHub Discussions][ghdiscussions].
69
+
70
+ Problem reports can be raised in [GitHub Issues][ghissues].
71
+
72
+ ## Contributing
73
+
74
+ This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide][contributing]
75
+
76
+ ## Security
77
+
78
+ Please consult the [security guide][security] for our responsible security vulnerability disclosure process
79
+
80
+ ## License
81
+
82
+ Copyright (c) 2025 Oracle and/or its affiliates.
83
+
84
+ Released under the Universal Permissive License v1.0 as shown at
85
+ <https://oss.oracle.com/licenses/upl/>.
86
+
87
+ [contributing]: https://github.com/oracle/python-select-ai/blob/main/CONTRIBUTING.md
88
+ [documentation]: https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/
89
+ [ghdiscussions]: https://github.com/oracle/python-select-ai/discussions
90
+ [ghissues]: https://github.com/oracle/python-select-ai/issues
91
+ [samples]: https://github.com/oracle/python-select-ai/tree/main/samples
92
+ [security]: https://github.com/oracle/python-select-ai/blob/main/SECURITY.md
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "select_ai"
7
+ dynamic = ["version"]
8
+ description = "Select AI for Python"
9
+ readme = {file = "README.md", content-type = "text/markdown"}
10
+ requires-python = ">=3.9"
11
+ authors = [
12
+ {name="Abhishek Singh", email="abhishek.o.singh@oracle.com"}
13
+ ]
14
+ maintainers =[
15
+ {name="Abhishek Singh", email="abhishek.o.singh@oracle.com"}
16
+ ]
17
+ keywords = [
18
+ "oracle",
19
+ "select-ai",
20
+ "adbs",
21
+ "autonomous database serverless"
22
+ ]
23
+ license = " UPL-1.0"
24
+ license-files = ["LICENSE.txt"]
25
+ classifiers = [
26
+ "Development Status :: 5 - Production/Stable",
27
+ "Intended Audience :: Developers",
28
+ "Natural Language :: English",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: Implementation :: CPython",
37
+ "Topic :: Database",
38
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
39
+ "Topic :: Software Development :: Libraries :: Python Modules"
40
+ ]
41
+ dependencies = [
42
+ "oracledb",
43
+ "pandas==2.2.3"
44
+ ]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/oracle/python-select-ai"
48
+ Repository = "https://github.com/oracle/python-select-ai"
49
+ Issues = "https://github.com/oracle/python-select-ai/issues"
50
+ Documentation = "https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/"
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [tool.setuptools.dynamic]
56
+ version = { attr = "select_ai.version.__version__" }
57
+
58
+ [tool.black]
59
+ line-length = 79
60
+ target-version = ["py39", "py310", "py311", "py312", "py313"]
61
+ required-version = 24
62
+
63
+ [tool.ruff]
64
+ line-length = 79
65
+ target-version = "py39"
66
+ per-file-ignores = { "__init__.py" = ["F401"] }
@@ -0,0 +1,49 @@
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
+ # async/conversation_chat_session.py
9
+ #
10
+ # Demonstrates context aware conversation using AI Profile
11
+ # -----------------------------------------------------------------------------
12
+
13
+ import asyncio
14
+ import os
15
+
16
+ import select_ai
17
+
18
+ user = os.getenv("SELECT_AI_USER")
19
+ password = os.getenv("SELECT_AI_PASSWORD")
20
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
21
+
22
+
23
+ async def main():
24
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
25
+ async_profile = await select_ai.AsyncProfile(
26
+ profile_name="async_oci_ai_profile"
27
+ )
28
+ conversation_attributes = select_ai.ConversationAttributes(
29
+ title="History of Science",
30
+ description="LLM's understanding of history of science",
31
+ )
32
+ async_conversation = select_ai.AsyncConversation(
33
+ attributes=conversation_attributes
34
+ )
35
+
36
+ async with async_profile.chat_session(
37
+ conversation=async_conversation, delete=True
38
+ ) as async_session:
39
+ response = await async_session.chat(
40
+ prompt="What is importance of history of science ?"
41
+ )
42
+ print(response)
43
+ response = await async_session.chat(
44
+ prompt="Elaborate more on 'Learning from past mistakes'"
45
+ )
46
+ print(response)
47
+
48
+
49
+ asyncio.run(main())
@@ -0,0 +1,31 @@
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
+ # async/conversations_list.py
10
+ #
11
+ # List all conversations saved in the database
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import select_ai
18
+
19
+ user = os.getenv("SELECT_AI_USER")
20
+ password = os.getenv("SELECT_AI_PASSWORD")
21
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
22
+
23
+
24
+ async def main():
25
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
26
+ async for conversation in select_ai.AsyncConversation().list():
27
+ print(conversation.conversation_id)
28
+ print(conversation.attributes)
29
+
30
+
31
+ asyncio.run(main())
@@ -0,0 +1,44 @@
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
+ # async/create_ai_credential.py
10
+ #
11
+ # Async API to create credential
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import oci
18
+ import select_ai
19
+
20
+ user = os.getenv("SELECT_AI_USER")
21
+ password = os.getenv("SELECT_AI_PASSWORD")
22
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
23
+
24
+
25
+ async def main():
26
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
27
+ default_config = oci.config.from_file()
28
+ oci.config.validate_config(default_config)
29
+ with open(default_config["key_file"]) as fp:
30
+ key_contents = fp.read()
31
+ credential = {
32
+ "credential_name": "my_oci_ai_profile_key",
33
+ "user_ocid": default_config["user"],
34
+ "tenancy_ocid": default_config["tenancy"],
35
+ "private_key": key_contents,
36
+ "fingerprint": default_config["fingerprint"],
37
+ }
38
+ await select_ai.async_create_credential(
39
+ credential=credential, replace=True
40
+ )
41
+ print("Created credential: ", credential["credential_name"])
42
+
43
+
44
+ asyncio.run(main())
@@ -0,0 +1,32 @@
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
+ # async/delete_ai_credential
10
+ #
11
+ # Async API to delete credential
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import select_ai
18
+
19
+ user = os.getenv("SELECT_AI_USER")
20
+ password = os.getenv("SELECT_AI_PASSWORD")
21
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
22
+
23
+
24
+ async def main():
25
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
26
+ await select_ai.async_delete_credential(
27
+ credential_name="my_oci_ai_profile_key", force=True
28
+ )
29
+ print("Deleted credential: my_oci_ai_profile_key")
30
+
31
+
32
+ asyncio.run(main())
@@ -0,0 +1,33 @@
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
+ # async/disable_ai_provider.py
10
+ #
11
+ # Async API to disable AI provider for database users
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import select_ai
18
+
19
+ admin_user = os.getenv("SELECT_AI_ADMIN_USER")
20
+ password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
21
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
22
+ select_ai_user = os.getenv("SELECT_AI_USER")
23
+
24
+
25
+ async def main():
26
+ await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
27
+ await select_ai.async_disable_provider(
28
+ users=select_ai_user, provider_endpoint="*.openai.azure.com"
29
+ )
30
+ print("Disabled AI provider for user: ", select_ai_user)
31
+
32
+
33
+ asyncio.run(main())
@@ -0,0 +1,33 @@
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
+ # async/enable_ai_provider.py
10
+ #
11
+ # Async API to enable AI provider for database users
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import select_ai
18
+
19
+ admin_user = os.getenv("SELECT_AI_ADMIN_USER")
20
+ password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
21
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
22
+ select_ai_user = os.getenv("SELECT_AI_USER")
23
+
24
+
25
+ async def main():
26
+ await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
27
+ await select_ai.async_enable_provider(
28
+ users=select_ai_user, provider_endpoint="*.openai.azure.com"
29
+ )
30
+ print("Enabled AI provider for user: ", select_ai_user)
31
+
32
+
33
+ asyncio.run(main())
@@ -0,0 +1,41 @@
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
+ # async/profile_chat.py
10
+ #
11
+ # Chat using an AI Profile
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+
17
+ import select_ai
18
+
19
+ user = os.getenv("SELECT_AI_USER")
20
+ password = os.getenv("SELECT_AI_PASSWORD")
21
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
22
+
23
+
24
+ async def main():
25
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
26
+ async_profile = await select_ai.AsyncProfile(
27
+ profile_name="async_oci_ai_profile"
28
+ )
29
+
30
+ # Asynchronously send multiple chat prompts
31
+ chat_tasks = [
32
+ async_profile.chat(prompt="What is OCI ?"),
33
+ async_profile.chat(prompt="What is OML4PY?"),
34
+ async_profile.chat(prompt="What is Autonomous Database ?"),
35
+ ]
36
+ for chat_task in asyncio.as_completed(chat_tasks):
37
+ result = await chat_task
38
+ print(result)
39
+
40
+
41
+ asyncio.run(main())
@@ -0,0 +1,50 @@
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
+ # async/profile_create.py
10
+ #
11
+ # Create an OCI Gen AI profile
12
+ # -----------------------------------------------------------------------------
13
+
14
+ import asyncio
15
+ import os
16
+ from pprint import pformat
17
+
18
+ import select_ai
19
+
20
+ user = os.getenv("SELECT_AI_USER")
21
+ password = os.getenv("SELECT_AI_PASSWORD")
22
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
23
+
24
+
25
+ # This example shows how to asynchronously generate SQLs nad run SQLs
26
+ async def main():
27
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
28
+ provider = select_ai.OCIGenAIProvider(
29
+ region="us-chicago-1", oci_apiformat="GENERIC"
30
+ )
31
+ profile_attributes = select_ai.ProfileAttributes(
32
+ credential_name="my_oci_ai_profile_key",
33
+ object_list=[{"owner": "SH"}],
34
+ provider=provider,
35
+ )
36
+ async_profile = await select_ai.AsyncProfile(
37
+ profile_name="async_oci_ai_profile",
38
+ attributes=profile_attributes,
39
+ description="MY OCI AI Profile",
40
+ replace=True,
41
+ )
42
+ print("Created async profile ", async_profile.profile_name)
43
+ profile_attributes = await async_profile.get_attributes()
44
+ print(
45
+ "Profile attributes: ",
46
+ pformat(profile_attributes.dict(exclude_null=False)),
47
+ )
48
+
49
+
50
+ asyncio.run(main())
@@ -0,0 +1,31 @@
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
+ # async/profile_explain_sql.py
10
+ # -----------------------------------------------------------------------------
11
+
12
+ import asyncio
13
+ import os
14
+
15
+ import select_ai
16
+
17
+ user = os.getenv("SELECT_AI_USER")
18
+ password = os.getenv("SELECT_AI_PASSWORD")
19
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
20
+
21
+
22
+ async def main():
23
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
24
+ async_profile = await select_ai.AsyncProfile(
25
+ profile_name="async_oci_ai_profile",
26
+ )
27
+ response = await async_profile.explain_sql("How many promotions ?")
28
+ print(response)
29
+
30
+
31
+ asyncio.run(main())