select-ai 1.0.0.dev4__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 (58) hide show
  1. select_ai-1.0.0.dev4/LICENSE.txt +35 -0
  2. select_ai-1.0.0.dev4/MANIFEST.in +2 -0
  3. select_ai-1.0.0.dev4/PKG-INFO +25 -0
  4. select_ai-1.0.0.dev4/README.md +14 -0
  5. select_ai-1.0.0.dev4/pyproject.toml +57 -0
  6. select_ai-1.0.0.dev4/samples/async_samples/conversation_chat_session.py +45 -0
  7. select_ai-1.0.0.dev4/samples/async_samples/conversations_list.py +26 -0
  8. select_ai-1.0.0.dev4/samples/async_samples/profile_chat.py +36 -0
  9. select_ai-1.0.0.dev4/samples/async_samples/profile_create.py +47 -0
  10. select_ai-1.0.0.dev4/samples/async_samples/profile_explain_sql.py +29 -0
  11. select_ai-1.0.0.dev4/samples/async_samples/profile_pipeline.py +49 -0
  12. select_ai-1.0.0.dev4/samples/async_samples/profile_run_sql.py +30 -0
  13. select_ai-1.0.0.dev4/samples/async_samples/profile_show_sql.py +28 -0
  14. select_ai-1.0.0.dev4/samples/async_samples/profile_sql_concurrent_tasks.py +36 -0
  15. select_ai-1.0.0.dev4/samples/async_samples/profiles_list.py +30 -0
  16. select_ai-1.0.0.dev4/samples/async_samples/vector_index_create.py +51 -0
  17. select_ai-1.0.0.dev4/samples/async_samples/vector_index_list.py +27 -0
  18. select_ai-1.0.0.dev4/samples/conversation_chat_session.py +46 -0
  19. select_ai-1.0.0.dev4/samples/conversation_create.py +35 -0
  20. select_ai-1.0.0.dev4/samples/conversation_delete.py +31 -0
  21. select_ai-1.0.0.dev4/samples/conversations_list.py +26 -0
  22. select_ai-1.0.0.dev4/samples/create_ai_credential.py +38 -0
  23. select_ai-1.0.0.dev4/samples/disable_ai_provider.py +27 -0
  24. select_ai-1.0.0.dev4/samples/enable_ai_provider.py +27 -0
  25. select_ai-1.0.0.dev4/samples/profile_chat.py +24 -0
  26. select_ai-1.0.0.dev4/samples/profile_create.py +47 -0
  27. select_ai-1.0.0.dev4/samples/profile_delete.py +24 -0
  28. select_ai-1.0.0.dev4/samples/profile_explain_sql.py +32 -0
  29. select_ai-1.0.0.dev4/samples/profile_gen_multi_table_synthetic_data.py +44 -0
  30. select_ai-1.0.0.dev4/samples/profile_gen_single_table_synthetic_data.py +38 -0
  31. select_ai-1.0.0.dev4/samples/profile_narrate.py +32 -0
  32. select_ai-1.0.0.dev4/samples/profile_run_sql.py +34 -0
  33. select_ai-1.0.0.dev4/samples/profile_show_sql.py +30 -0
  34. select_ai-1.0.0.dev4/samples/profiles_list.py +27 -0
  35. select_ai-1.0.0.dev4/samples/vector_index_create.py +57 -0
  36. select_ai-1.0.0.dev4/samples/vector_index_list.py +26 -0
  37. select_ai-1.0.0.dev4/setup.cfg +4 -0
  38. select_ai-1.0.0.dev4/src/select_ai/__init__.py +52 -0
  39. select_ai-1.0.0.dev4/src/select_ai/_abc.py +74 -0
  40. select_ai-1.0.0.dev4/src/select_ai/_enums.py +14 -0
  41. select_ai-1.0.0.dev4/src/select_ai/action.py +21 -0
  42. select_ai-1.0.0.dev4/src/select_ai/admin.py +108 -0
  43. select_ai-1.0.0.dev4/src/select_ai/async_profile.py +468 -0
  44. select_ai-1.0.0.dev4/src/select_ai/base_profile.py +166 -0
  45. select_ai-1.0.0.dev4/src/select_ai/conversation.py +249 -0
  46. select_ai-1.0.0.dev4/src/select_ai/db.py +171 -0
  47. select_ai-1.0.0.dev4/src/select_ai/errors.py +49 -0
  48. select_ai-1.0.0.dev4/src/select_ai/profile.py +397 -0
  49. select_ai-1.0.0.dev4/src/select_ai/provider.py +187 -0
  50. select_ai-1.0.0.dev4/src/select_ai/sql.py +105 -0
  51. select_ai-1.0.0.dev4/src/select_ai/synthetic_data.py +84 -0
  52. select_ai-1.0.0.dev4/src/select_ai/vector_index.py +542 -0
  53. select_ai-1.0.0.dev4/src/select_ai/version.py +8 -0
  54. select_ai-1.0.0.dev4/src/select_ai.egg-info/PKG-INFO +25 -0
  55. select_ai-1.0.0.dev4/src/select_ai.egg-info/SOURCES.txt +56 -0
  56. select_ai-1.0.0.dev4/src/select_ai.egg-info/dependency_links.txt +1 -0
  57. select_ai-1.0.0.dev4/src/select_ai.egg-info/requires.txt +2 -0
  58. select_ai-1.0.0.dev4/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,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: select_ai
3
+ Version: 1.0.0.dev4
4
+ Summary: Python API for Select AI
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
+ Keywords: oracle,select-ai,adbs,autonomous database serverless
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Classifier: Topic :: Database
21
+ Requires-Python: >=3.9
22
+ License-File: LICENSE.txt
23
+ Requires-Dist: oracledb
24
+ Requires-Dist: pandas==2.2.3
25
+ Dynamic: license-file
@@ -0,0 +1,14 @@
1
+ # select-ai
2
+
3
+ Python API for Select AI
4
+
5
+ ## Install
6
+
7
+ Run
8
+ ```bash
9
+ python3 -m pip install select_ai
10
+ ```
11
+
12
+ ## Samples
13
+
14
+ Examples can be found in the samples directory
@@ -0,0 +1,57 @@
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 = "Python API for Select AI"
9
+ requires-python = ">=3.9"
10
+ authors = [
11
+ {name="Abhishek Singh", email="abhishek.o.singh@oracle.com"}
12
+ ]
13
+ maintainers =[
14
+ {name="Abhishek Singh", email="abhishek.o.singh@oracle.com"}
15
+ ]
16
+ keywords = [
17
+ "oracle",
18
+ "select-ai",
19
+ "adbs",
20
+ "autonomous database serverless"
21
+ ]
22
+ license = " UPL-1.0"
23
+ license-files = ["LICENSE.txt"]
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Developers",
27
+ "Natural Language :: English",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3 :: Only",
30
+ "Programming Language :: Python :: 3.9",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Programming Language :: Python :: Implementation :: CPython",
36
+ "Topic :: Database"
37
+ ]
38
+ dependencies = [
39
+ "oracledb",
40
+ "pandas==2.2.3"
41
+ ]
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
45
+
46
+ [tool.setuptools.dynamic]
47
+ version = { attr = "select_ai.version.__version__" }
48
+
49
+ [tool.black]
50
+ line-length = 79
51
+ target-version = ["py39", "py310", "py311", "py312", "py313"]
52
+ required-version = 24
53
+
54
+ [tool.ruff]
55
+ line-length = 79
56
+ target-version = "py39"
57
+ per-file-ignores = { "__init__.py" = ["F401"] }
@@ -0,0 +1,45 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile(
21
+ profile_name="async_oci_ai_profile"
22
+ )
23
+ conversation_attributes = select_ai.ConversationAttributes(
24
+ title="History of Science",
25
+ description="LLM's understanding of history of science",
26
+ )
27
+ async_conversation = select_ai.AsyncConversation(
28
+ attributes=conversation_attributes
29
+ )
30
+
31
+ async with async_profile.chat_session(
32
+ conversation=async_conversation, delete=True
33
+ ) as async_session:
34
+ response = await async_session.chat(
35
+ prompt="What is importance of history of science ?"
36
+ )
37
+ print(response)
38
+ response = await async_session.chat(
39
+ prompt="Elaborate more on 'Learning from past mistakes'"
40
+ )
41
+ print(response)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ asyncio.run(main())
@@ -0,0 +1,26 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async for conversation in select_ai.AsyncConversation().list():
21
+ print(conversation.conversation_id)
22
+ print(conversation.attributes)
23
+
24
+
25
+ if __name__ == "__main__":
26
+ asyncio.run(main())
@@ -0,0 +1,36 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile(
21
+ profile_name="async_oci_ai_profile"
22
+ )
23
+
24
+ # Asynchronously send multiple prompts
25
+ chat_tasks = [
26
+ async_profile.chat(prompt="What is OCI ?"),
27
+ async_profile.chat(prompt="What is OML4PY?"),
28
+ async_profile.chat(prompt="What is Autonomous Database ?"),
29
+ ]
30
+ for chat_task in asyncio.as_completed(chat_tasks):
31
+ result = await chat_task
32
+ print(result)
33
+
34
+
35
+ if __name__ == "__main__":
36
+ asyncio.run(main())
@@ -0,0 +1,47 @@
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 asyncio
9
+ import os
10
+ from pprint import pformat
11
+
12
+ import select_ai
13
+
14
+ user = os.getenv("SELECT_AI_USER")
15
+ password = os.getenv("SELECT_AI_PASSWORD")
16
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
17
+
18
+
19
+ # This example shows how to asynchronously generate SQLs nad run SQLs
20
+ async def main():
21
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
22
+ provider = select_ai.OCIGenAIProvider(
23
+ region="us-chicago-1", oci_apiformat="GENERIC"
24
+ )
25
+ profile_attributes = select_ai.ProfileAttributes(
26
+ credential_name="my_oci_ai_profile_key",
27
+ object_list=[{"owner": "SH"}],
28
+ provider=provider,
29
+ )
30
+ async_profile = await select_ai.AsyncProfile(
31
+ profile_name="async_oci_ai_profile",
32
+ attributes=profile_attributes,
33
+ description="MY OCI AI Profile",
34
+ replace=True,
35
+ )
36
+
37
+ profile_attributes = await async_profile.get_attributes()
38
+
39
+ print("Profile attributes are: ", profile_attributes)
40
+ print(
41
+ "Profile attributes as Python dict: ",
42
+ pformat(profile_attributes.dict(exclude_null=False)),
43
+ )
44
+
45
+
46
+ if __name__ == "__main__":
47
+ asyncio.run(main())
@@ -0,0 +1,29 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ # This example shows how to asynchronously ask the LLM to explain SQL
19
+ async def main():
20
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
21
+ async_profile = await select_ai.AsyncProfile(
22
+ profile_name="async_oci_ai_profile",
23
+ )
24
+ response = await async_profile.explain_sql("How many promotions")
25
+ print(response)
26
+
27
+
28
+ if __name__ == "__main__":
29
+ asyncio.run(main())
@@ -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
+ import asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile(
21
+ profile_name="async_oci_ai_profile"
22
+ )
23
+ prompt_specifications = [
24
+ ("What is Oracle Autonomous Database?", select_ai.Action.CHAT),
25
+ ("Generate SQL to list all customers?", select_ai.Action.SHOWSQL),
26
+ (
27
+ "Explain the query: SELECT * FROM sh.products",
28
+ select_ai.Action.EXPLAINSQL,
29
+ ),
30
+ ("Explain the query: SELECT * FROM sh.products", "INVALID ACTION"),
31
+ ]
32
+
33
+ # 1. Multiple prompts are sent in a single roundtrip to the Database
34
+ # 2. Results are returned as soon as Database has executed all prompts
35
+ # 3. Application doesn't have to wait on one response before sending
36
+ # the next prompts
37
+ # 4. Fewer round trips and database is kept busy
38
+ # 5. Efficient network usage
39
+ results = await async_profile.run_pipeline(
40
+ prompt_specifications, continue_on_error=True
41
+ )
42
+ for i, result in enumerate(results):
43
+ print(
44
+ f"Result {i} for prompt '{prompt_specifications[i][0]}' is: {result}"
45
+ )
46
+
47
+
48
+ if __name__ == "__main__":
49
+ asyncio.run(main())
@@ -0,0 +1,30 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ # This example shows how to asynchronously run sql
19
+ async def main():
20
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
21
+ async_profile = await select_ai.AsyncProfile(
22
+ profile_name="async_oci_ai_profile",
23
+ )
24
+ # run_sql returns a pandas df
25
+ df = await async_profile.run_sql("How many promotions")
26
+ print(df)
27
+
28
+
29
+ if __name__ == "__main__":
30
+ asyncio.run(main())
@@ -0,0 +1,28 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile(
21
+ profile_name="async_oci_ai_profile",
22
+ )
23
+ response = await async_profile.show_sql("How many promotions")
24
+ print(response)
25
+
26
+
27
+ if __name__ == "__main__":
28
+ asyncio.run(main())
@@ -0,0 +1,36 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile(
21
+ profile_name="async_oci_ai_profile",
22
+ )
23
+ sql_tasks = [
24
+ async_profile.show_sql(prompt="How many customers?"),
25
+ async_profile.run_sql(prompt="How many promotions"),
26
+ async_profile.explain_sql(prompt="How many promotions"),
27
+ ]
28
+
29
+ # Collect results from multiple asynchronous tasks
30
+ for sql_task in asyncio.as_completed(sql_tasks):
31
+ result = await sql_task
32
+ print(result)
33
+
34
+
35
+ if __name__ == "__main__":
36
+ asyncio.run(main())
@@ -0,0 +1,30 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ async_profile = await select_ai.AsyncProfile()
21
+ # matches the start of string
22
+ async for fetched_profile in async_profile.list(
23
+ profile_name_pattern="^oci"
24
+ ):
25
+ p = await fetched_profile
26
+ print(p.profile_name)
27
+
28
+
29
+ if __name__ == "__main__":
30
+ asyncio.run(main())
@@ -0,0 +1,51 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+
21
+ provider = select_ai.OCIGenAIProvider(
22
+ region="us-chicago-1", oci_apiformat="GENERIC"
23
+ )
24
+ profile_attributes = select_ai.ProfileAttributes(
25
+ credential_name="my_oci_ai_profile_key",
26
+ provider=provider,
27
+ )
28
+ async_profile = await select_ai.AsyncProfile(
29
+ profile_name="async_oci_vector_ai_profile",
30
+ attributes=profile_attributes,
31
+ description="MY OCI AI Profile",
32
+ replace=True,
33
+ )
34
+
35
+ vector_index_attributes = select_ai.OracleVectorIndexAttributes(
36
+ location="https://objectstorage.us-ashburn-1.oraclecloud.com/n/dwcsdev/b/conda-environment/o/tenant1-pdb3/graph",
37
+ object_storage_credential_name="my_oci_ai_profile_key",
38
+ )
39
+
40
+ async_vector_index = select_ai.AsyncVectorIndex(
41
+ index_name="test_vector_index",
42
+ attributes=vector_index_attributes,
43
+ description="Vector index for conda environments",
44
+ profile=async_profile,
45
+ )
46
+ await async_vector_index.create(replace=True)
47
+ print("created vector index: test_vector_index")
48
+
49
+
50
+ if __name__ == "__main__":
51
+ asyncio.run(main())
@@ -0,0 +1,27 @@
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 asyncio
9
+ import os
10
+
11
+ import select_ai
12
+
13
+ user = os.getenv("SELECT_AI_USER")
14
+ password = os.getenv("SELECT_AI_PASSWORD")
15
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
16
+
17
+
18
+ async def main():
19
+ await select_ai.async_connect(user=user, password=password, dsn=dsn)
20
+ vector_index = select_ai.AsyncVectorIndex()
21
+ async for index in vector_index.list(index_name_pattern="^test"):
22
+ print("Vector index", index.index_name)
23
+ print("Vector index profile", index.profile)
24
+
25
+
26
+ if __name__ == "__main__":
27
+ asyncio.run(main())
@@ -0,0 +1,46 @@
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 os
9
+
10
+ import select_ai
11
+
12
+ user = os.getenv("SELECT_AI_USER")
13
+ password = os.getenv("SELECT_AI_PASSWORD")
14
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
15
+
16
+ # This example shows how to have a context-aware
17
+ # conversation
18
+
19
+
20
+ def main():
21
+ select_ai.connect(user=user, password=password, dsn=dsn)
22
+ profile = select_ai.Profile(profile_name="oci_ai_profile")
23
+ conversation_attributes = select_ai.ConversationAttributes(
24
+ title="History of Science",
25
+ description="LLM's understanding of history of science",
26
+ )
27
+ conversation = select_ai.Conversation(attributes=conversation_attributes)
28
+ with profile.chat_session(
29
+ conversation=conversation, delete=True
30
+ ) as session:
31
+ print(
32
+ "Conversation ID for this session is:",
33
+ conversation.conversation_id,
34
+ )
35
+ response = session.chat(
36
+ prompt="What is importance of history of science ?"
37
+ )
38
+ print(response)
39
+ response = session.chat(
40
+ prompt="Elaborate more on 'Learning from past mistakes'"
41
+ )
42
+ print(response)
43
+
44
+
45
+ if __name__ == "__main__":
46
+ main()
@@ -0,0 +1,35 @@
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 os
9
+
10
+ import select_ai
11
+
12
+ user = os.getenv("SELECT_AI_USER")
13
+ password = os.getenv("SELECT_AI_PASSWORD")
14
+ dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
15
+
16
+
17
+ # This example shows how to create a conversation
18
+ def main():
19
+ select_ai.connect(user=user, password=password, dsn=dsn)
20
+ conversation_attributes = select_ai.ConversationAttributes(
21
+ title="History of Science",
22
+ description="LLM's understanding of history of science",
23
+ )
24
+
25
+ conversation = select_ai.Conversation(attributes=conversation_attributes)
26
+ conversation.create()
27
+
28
+ print(
29
+ "Created conversation with conversation id: ",
30
+ conversation.conversation_id,
31
+ )
32
+
33
+
34
+ if __name__ == "__main__":
35
+ main()