select-ai 1.0.0b1__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 (69) hide show
  1. select_ai-1.0.0b1/LICENSE.txt +35 -0
  2. select_ai-1.0.0b1/MANIFEST.in +2 -0
  3. select_ai-1.0.0b1/PKG-INFO +117 -0
  4. select_ai-1.0.0b1/README.md +87 -0
  5. select_ai-1.0.0b1/pyproject.toml +63 -0
  6. select_ai-1.0.0b1/samples/async/conversation_chat_session.py +49 -0
  7. select_ai-1.0.0b1/samples/async/conversations_list.py +31 -0
  8. select_ai-1.0.0b1/samples/async/create_ai_credential.py +44 -0
  9. select_ai-1.0.0b1/samples/async/delete_ai_credential.py +32 -0
  10. select_ai-1.0.0b1/samples/async/disable_ai_provider.py +33 -0
  11. select_ai-1.0.0b1/samples/async/enable_ai_provider.py +33 -0
  12. select_ai-1.0.0b1/samples/async/profile_chat.py +41 -0
  13. select_ai-1.0.0b1/samples/async/profile_create.py +50 -0
  14. select_ai-1.0.0b1/samples/async/profile_explain_sql.py +31 -0
  15. select_ai-1.0.0b1/samples/async/profile_gen_multi_table_synthetic_data.py +48 -0
  16. select_ai-1.0.0b1/samples/async/profile_gen_single_table_synthetic_data.py +41 -0
  17. select_ai-1.0.0b1/samples/async/profile_pipeline.py +54 -0
  18. select_ai-1.0.0b1/samples/async/profile_run_sql.py +35 -0
  19. select_ai-1.0.0b1/samples/async/profile_show_sql.py +33 -0
  20. select_ai-1.0.0b1/samples/async/profile_sql_concurrent_tasks.py +42 -0
  21. select_ai-1.0.0b1/samples/async/profiles_list.py +35 -0
  22. select_ai-1.0.0b1/samples/async/vector_index_create.py +58 -0
  23. select_ai-1.0.0b1/samples/async/vector_index_delete.py +29 -0
  24. select_ai-1.0.0b1/samples/async/vector_index_list.py +33 -0
  25. select_ai-1.0.0b1/samples/async/vector_index_rag.py +35 -0
  26. select_ai-1.0.0b1/samples/conversation_chat_session.py +41 -0
  27. select_ai-1.0.0b1/samples/conversation_create.py +31 -0
  28. select_ai-1.0.0b1/samples/conversation_delete.py +30 -0
  29. select_ai-1.0.0b1/samples/conversations_list.py +25 -0
  30. select_ai-1.0.0b1/samples/create_ai_credential.py +38 -0
  31. select_ai-1.0.0b1/samples/delete_ai_credential.py +25 -0
  32. select_ai-1.0.0b1/samples/disable_ai_provider.py +27 -0
  33. select_ai-1.0.0b1/samples/enable_ai_provider.py +28 -0
  34. select_ai-1.0.0b1/samples/profile_chat.py +25 -0
  35. select_ai-1.0.0b1/samples/profile_create.py +43 -0
  36. select_ai-1.0.0b1/samples/profile_delete.py +22 -0
  37. select_ai-1.0.0b1/samples/profile_explain_sql.py +26 -0
  38. select_ai-1.0.0b1/samples/profile_gen_multi_table_synthetic_data.py +42 -0
  39. select_ai-1.0.0b1/samples/profile_gen_single_table_synthetic_data.py +35 -0
  40. select_ai-1.0.0b1/samples/profile_narrate.py +27 -0
  41. select_ai-1.0.0b1/samples/profile_run_sql.py +26 -0
  42. select_ai-1.0.0b1/samples/profile_show_sql.py +25 -0
  43. select_ai-1.0.0b1/samples/profiles_list.py +27 -0
  44. select_ai-1.0.0b1/samples/vector_index_create.py +60 -0
  45. select_ai-1.0.0b1/samples/vector_index_delete.py +23 -0
  46. select_ai-1.0.0b1/samples/vector_index_list.py +27 -0
  47. select_ai-1.0.0b1/samples/vector_index_rag.py +25 -0
  48. select_ai-1.0.0b1/setup.cfg +4 -0
  49. select_ai-1.0.0b1/src/select_ai/__init__.py +59 -0
  50. select_ai-1.0.0b1/src/select_ai/_abc.py +77 -0
  51. select_ai-1.0.0b1/src/select_ai/_enums.py +14 -0
  52. select_ai-1.0.0b1/src/select_ai/action.py +21 -0
  53. select_ai-1.0.0b1/src/select_ai/async_profile.py +528 -0
  54. select_ai-1.0.0b1/src/select_ai/base_profile.py +183 -0
  55. select_ai-1.0.0b1/src/select_ai/conversation.py +274 -0
  56. select_ai-1.0.0b1/src/select_ai/credential.py +135 -0
  57. select_ai-1.0.0b1/src/select_ai/db.py +186 -0
  58. select_ai-1.0.0b1/src/select_ai/errors.py +73 -0
  59. select_ai-1.0.0b1/src/select_ai/profile.py +454 -0
  60. select_ai-1.0.0b1/src/select_ai/provider.py +288 -0
  61. select_ai-1.0.0b1/src/select_ai/sql.py +105 -0
  62. select_ai-1.0.0b1/src/select_ai/synthetic_data.py +90 -0
  63. select_ai-1.0.0b1/src/select_ai/vector_index.py +552 -0
  64. select_ai-1.0.0b1/src/select_ai/version.py +8 -0
  65. select_ai-1.0.0b1/src/select_ai.egg-info/PKG-INFO +117 -0
  66. select_ai-1.0.0b1/src/select_ai.egg-info/SOURCES.txt +67 -0
  67. select_ai-1.0.0b1/src/select_ai.egg-info/dependency_links.txt +1 -0
  68. select_ai-1.0.0b1/src/select_ai.egg-info/requires.txt +2 -0
  69. select_ai-1.0.0b1/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,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: select_ai
3
+ Version: 1.0.0b1
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
+ Keywords: oracle,select-ai,adbs,autonomous database serverless
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Classifier: Topic :: Database
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE.txt
27
+ Requires-Dist: oracledb
28
+ Requires-Dist: pandas==2.2.3
29
+ Dynamic: license-file
30
+
31
+ # Select AI for Python
32
+
33
+
34
+ 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.
35
+
36
+ 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.
37
+
38
+
39
+ ## Installation
40
+
41
+ Run
42
+ ```bash
43
+ python3 -m pip install select_ai
44
+ ```
45
+
46
+ ## Samples
47
+
48
+ Examples can be found in the [/samples][samples] directory
49
+
50
+ ### Basic Example
51
+
52
+ ```python
53
+ import select_ai
54
+
55
+ user = "<your_select_ai_user>"
56
+ password = "<your_select_ai_password>"
57
+ dsn = "<your_select_ai_db_connect_string>"
58
+
59
+ select_ai.connect(user=user, password=password, dsn=dsn)
60
+ profile = select_ai.Profile(profile_name="oci_ai_profile")
61
+ # run_sql returns a pandas dataframe
62
+ df = profile.run_sql(prompt="How many promotions?")
63
+ print(df.columns)
64
+ print(df)
65
+ ```
66
+
67
+ ### Async Example
68
+
69
+ ```python
70
+
71
+ import asyncio
72
+
73
+ import select_ai
74
+
75
+ user = "<your_select_ai_user>"
76
+ password = "<your_select_ai_password>"
77
+ dsn = "<your_select_ai_db_connect_string>"
78
+
79
+ # This example shows how to asynchronously run sql
80
+ async def main():
81
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
82
+ async_profile = await select_ai.AsyncProfile(
83
+ profile_name="async_oci_ai_profile",
84
+ )
85
+ # run_sql returns a pandas df
86
+ df = await async_profile.run_sql("How many promotions?")
87
+ print(df)
88
+
89
+ asyncio.run(main())
90
+
91
+ ```
92
+ ## Help
93
+
94
+ Questions can be asked in [GitHub Discussions][ghdiscussions].
95
+
96
+ Problem reports can be raised in [GitHub Issues][ghissues].
97
+
98
+ ## Contributing
99
+
100
+ This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide][contributing]
101
+
102
+ ## Security
103
+
104
+ Please consult the [security guide][security] for our responsible security vulnerability disclosure process
105
+
106
+ ## License
107
+
108
+ Copyright (c) 2025 Oracle and/or its affiliates.
109
+
110
+ Released under the Universal Permissive License v1.0 as shown at
111
+ <https://oss.oracle.com/licenses/upl/>.
112
+
113
+ [contributing]: https://github.com/oracle/python-select-ai/blob/main/CONTRIBUTING.md
114
+ [ghdiscussions]: https://github.com/oracle/python-select-ai/discussions
115
+ [ghissues]: https://github.com/oracle/python-select-ai/issues
116
+ [samples]: https://github.com/oracle/python-select-ai/tree/main/samples
117
+ [security]: https://github.com/oracle/python-select-ai/blob/main/SECURITY.md
@@ -0,0 +1,87 @@
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
+ ## Samples
17
+
18
+ Examples can be found in the [/samples][samples] directory
19
+
20
+ ### Basic Example
21
+
22
+ ```python
23
+ import select_ai
24
+
25
+ user = "<your_select_ai_user>"
26
+ password = "<your_select_ai_password>"
27
+ dsn = "<your_select_ai_db_connect_string>"
28
+
29
+ select_ai.connect(user=user, password=password, dsn=dsn)
30
+ profile = select_ai.Profile(profile_name="oci_ai_profile")
31
+ # run_sql returns a pandas dataframe
32
+ df = profile.run_sql(prompt="How many promotions?")
33
+ print(df.columns)
34
+ print(df)
35
+ ```
36
+
37
+ ### Async Example
38
+
39
+ ```python
40
+
41
+ import asyncio
42
+
43
+ import select_ai
44
+
45
+ user = "<your_select_ai_user>"
46
+ password = "<your_select_ai_password>"
47
+ dsn = "<your_select_ai_db_connect_string>"
48
+
49
+ # This example shows how to asynchronously run sql
50
+ async def main():
51
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
52
+ async_profile = await select_ai.AsyncProfile(
53
+ profile_name="async_oci_ai_profile",
54
+ )
55
+ # run_sql returns a pandas df
56
+ df = await async_profile.run_sql("How many promotions?")
57
+ print(df)
58
+
59
+ asyncio.run(main())
60
+
61
+ ```
62
+ ## Help
63
+
64
+ Questions can be asked in [GitHub Discussions][ghdiscussions].
65
+
66
+ Problem reports can be raised in [GitHub Issues][ghissues].
67
+
68
+ ## Contributing
69
+
70
+ This project welcomes contributions from the community. Before submitting a pull request, please [review our contribution guide][contributing]
71
+
72
+ ## Security
73
+
74
+ Please consult the [security guide][security] for our responsible security vulnerability disclosure process
75
+
76
+ ## License
77
+
78
+ Copyright (c) 2025 Oracle and/or its affiliates.
79
+
80
+ Released under the Universal Permissive License v1.0 as shown at
81
+ <https://oss.oracle.com/licenses/upl/>.
82
+
83
+ [contributing]: https://github.com/oracle/python-select-ai/blob/main/CONTRIBUTING.md
84
+ [ghdiscussions]: https://github.com/oracle/python-select-ai/discussions
85
+ [ghissues]: https://github.com/oracle/python-select-ai/issues
86
+ [samples]: https://github.com/oracle/python-select-ai/tree/main/samples
87
+ [security]: https://github.com/oracle/python-select-ai/blob/main/SECURITY.md
@@ -0,0 +1,63 @@
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 :: 4 - Beta",
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
+ ]
39
+ dependencies = [
40
+ "oracledb",
41
+ "pandas==2.2.3"
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/oracle/python-select-ai"
46
+ Repository = "https://github.com/oracle/python-select-ai"
47
+ Issues = "https://github.com/oracle/python-select-ai/issues"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
51
+
52
+ [tool.setuptools.dynamic]
53
+ version = { attr = "select_ai.version.__version__" }
54
+
55
+ [tool.black]
56
+ line-length = 79
57
+ target-version = ["py39", "py310", "py311", "py312", "py313"]
58
+ required-version = 24
59
+
60
+ [tool.ruff]
61
+ line-length = 79
62
+ target-version = "py39"
63
+ 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())