select-ai 1.0.0.dev5__tar.gz → 1.0.0.dev6__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.
- {select_ai-1.0.0.dev5/src/select_ai.egg-info → select_ai-1.0.0.dev6}/PKG-INFO +1 -1
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/conversation_chat_session.py +6 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/conversations_list.py +7 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_chat.py +8 -3
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_create.py +9 -6
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_explain_sql.py +5 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_pipeline.py +7 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_run_sql.py +7 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_show_sql.py +7 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_sql_concurrent_tasks.py +8 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profiles_list.py +7 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/vector_index_create.py +12 -5
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/vector_index_delete.py +5 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/vector_index_list.py +8 -2
- {select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/vector_index_rag.py +11 -3
- select_ai-1.0.0.dev6/samples/conversation_chat_session.py +40 -0
- select_ai-1.0.0.dev6/samples/conversation_create.py +30 -0
- select_ai-1.0.0.dev6/samples/conversation_delete.py +30 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/conversations_list.py +10 -11
- select_ai-1.0.0.dev6/samples/create_ai_credential.py +37 -0
- select_ai-1.0.0.dev6/samples/disable_ai_provider.py +27 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/enable_ai_provider.py +11 -4
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profile_chat.py +10 -9
- select_ai-1.0.0.dev6/samples/profile_create.py +43 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profile_delete.py +7 -9
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profile_explain_sql.py +13 -17
- select_ai-1.0.0.dev6/samples/profile_gen_multi_table_synthetic_data.py +42 -0
- select_ai-1.0.0.dev6/samples/profile_gen_single_table_synthetic_data.py +35 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profile_narrate.py +14 -17
- select_ai-1.0.0.dev6/samples/profile_run_sql.py +28 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profile_show_sql.py +12 -15
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/profiles_list.py +11 -11
- select_ai-1.0.0.dev6/samples/vector_index_create.py +60 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/vector_index_delete.py +8 -10
- select_ai-1.0.0.dev6/samples/vector_index_list.py +27 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/samples/vector_index_rag.py +10 -10
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/__init__.py +2 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/_abc.py +5 -2
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/admin.py +11 -3
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/async_profile.py +36 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/base_profile.py +14 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/conversation.py +19 -6
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/db.py +24 -9
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/errors.py +24 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/profile.py +32 -2
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/provider.py +0 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/sql.py +1 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/vector_index.py +8 -5
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/version.py +1 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6/src/select_ai.egg-info}/PKG-INFO +1 -1
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai.egg-info/SOURCES.txt +14 -14
- select_ai-1.0.0.dev5/samples/conversation_chat_session.py +0 -46
- select_ai-1.0.0.dev5/samples/conversation_create.py +0 -35
- select_ai-1.0.0.dev5/samples/conversation_delete.py +0 -31
- select_ai-1.0.0.dev5/samples/create_ai_credential.py +0 -38
- select_ai-1.0.0.dev5/samples/disable_ai_provider.py +0 -27
- select_ai-1.0.0.dev5/samples/profile_create.py +0 -47
- select_ai-1.0.0.dev5/samples/profile_gen_multi_table_synthetic_data.py +0 -44
- select_ai-1.0.0.dev5/samples/profile_gen_single_table_synthetic_data.py +0 -38
- select_ai-1.0.0.dev5/samples/profile_run_sql.py +0 -34
- select_ai-1.0.0.dev5/samples/vector_index_create.py +0 -58
- select_ai-1.0.0.dev5/samples/vector_index_list.py +0 -26
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/LICENSE.txt +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/MANIFEST.in +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/README.md +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/pyproject.toml +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/setup.cfg +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/_enums.py +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/action.py +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai/synthetic_data.py +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai.egg-info/dependency_links.txt +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai.egg-info/requires.txt +0 -0
- {select_ai-1.0.0.dev5 → select_ai-1.0.0.dev6}/src/select_ai.egg-info/top_level.txt +0 -0
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
|
+
# ------------------------------------------------------------------------------
|
|
8
|
+
# async/conversation_chat_session.py
|
|
9
|
+
#
|
|
10
|
+
# Demonstrates context aware conversation using AI Profile
|
|
11
|
+
# ------------------------------------------------------------------------------
|
|
7
12
|
|
|
8
13
|
import asyncio
|
|
9
14
|
import os
|
|
@@ -41,5 +46,4 @@ async def main():
|
|
|
41
46
|
print(response)
|
|
42
47
|
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
asyncio.run(main())
|
|
49
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/conversations_list.py
|
|
10
|
+
#
|
|
11
|
+
# List all conversations saved in the database
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -22,5 +28,4 @@ async def main():
|
|
|
22
28
|
print(conversation.attributes)
|
|
23
29
|
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
asyncio.run(main())
|
|
31
|
+
asyncio.run(main())
|
{select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_chat.py
RENAMED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_chat.py
|
|
10
|
+
#
|
|
11
|
+
# Chat using an AI Profile
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -21,7 +27,7 @@ async def main():
|
|
|
21
27
|
profile_name="async_oci_ai_profile"
|
|
22
28
|
)
|
|
23
29
|
|
|
24
|
-
# Asynchronously send multiple prompts
|
|
30
|
+
# Asynchronously send multiple chat prompts
|
|
25
31
|
chat_tasks = [
|
|
26
32
|
async_profile.chat(prompt="What is OCI ?"),
|
|
27
33
|
async_profile.chat(prompt="What is OML4PY?"),
|
|
@@ -32,5 +38,4 @@ async def main():
|
|
|
32
38
|
print(result)
|
|
33
39
|
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
asyncio.run(main())
|
|
41
|
+
asyncio.run(main())
|
{select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_create.py
RENAMED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_create.py
|
|
10
|
+
#
|
|
11
|
+
# Create an OCI Gen AI profile
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
from pprint import pformat
|
|
@@ -33,15 +39,12 @@ async def main():
|
|
|
33
39
|
description="MY OCI AI Profile",
|
|
34
40
|
replace=True,
|
|
35
41
|
)
|
|
36
|
-
|
|
42
|
+
print("Created async profile ", async_profile.profile_name)
|
|
37
43
|
profile_attributes = await async_profile.get_attributes()
|
|
38
|
-
|
|
39
|
-
print("Profile attributes are: ", profile_attributes)
|
|
40
44
|
print(
|
|
41
|
-
"Profile attributes
|
|
45
|
+
"Profile attributes: ",
|
|
42
46
|
pformat(profile_attributes.dict(exclude_null=False)),
|
|
43
47
|
)
|
|
44
48
|
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
asyncio.run(main())
|
|
50
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_explain_sql.py
|
|
10
|
+
# ------------------------------------------------------------------------------
|
|
11
|
+
|
|
8
12
|
import asyncio
|
|
9
13
|
import os
|
|
10
14
|
|
|
@@ -25,5 +29,4 @@ async def main():
|
|
|
25
29
|
print(response)
|
|
26
30
|
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
asyncio.run(main())
|
|
32
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_pipeline.py
|
|
10
|
+
#
|
|
11
|
+
# Demonstrates sending multiple prompts using a single Database round-trip
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -45,5 +51,4 @@ async def main():
|
|
|
45
51
|
)
|
|
46
52
|
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
asyncio.run(main())
|
|
54
|
+
asyncio.run(main())
|
{select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profile_run_sql.py
RENAMED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_run_sql.py
|
|
10
|
+
#
|
|
11
|
+
# Return a pandas.Dataframe built using the resultset of the generated SQL
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -26,5 +32,4 @@ async def main():
|
|
|
26
32
|
print(df)
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
asyncio.run(main())
|
|
35
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_show_sql.py
|
|
10
|
+
#
|
|
11
|
+
# Show the generated SQL without executing it
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -24,5 +30,4 @@ async def main():
|
|
|
24
30
|
print(response)
|
|
25
31
|
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
asyncio.run(main())
|
|
33
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_sql_concurrent_tasks.py
|
|
10
|
+
#
|
|
11
|
+
# Demonstrates sending multiple prompts concurrently using asyncio
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
|
|
8
15
|
import asyncio
|
|
9
16
|
import os
|
|
10
17
|
|
|
@@ -32,5 +39,4 @@ async def main():
|
|
|
32
39
|
print(result)
|
|
33
40
|
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
asyncio.run(main())
|
|
42
|
+
asyncio.run(main())
|
{select_ai-1.0.0.dev5/samples/async_samples → select_ai-1.0.0.dev6/samples/async}/profiles_list.py
RENAMED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/profile_list.py
|
|
10
|
+
#
|
|
11
|
+
# List all the profile names matching a certain pattern
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import asyncio
|
|
9
15
|
import os
|
|
10
16
|
|
|
@@ -26,5 +32,4 @@ async def main():
|
|
|
26
32
|
print(p.profile_name)
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
asyncio.run(main())
|
|
35
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/vector_index_create.py
|
|
10
|
+
#
|
|
11
|
+
# Create a vector index for Retrieval Augmented Generation (RAG)
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
|
|
8
15
|
import asyncio
|
|
9
16
|
import os
|
|
10
17
|
|
|
@@ -19,8 +26,9 @@ async def main():
|
|
|
19
26
|
await select_ai.async_connect(user=user, password=password, dsn=dsn)
|
|
20
27
|
|
|
21
28
|
provider = select_ai.OCIGenAIProvider(
|
|
22
|
-
region="us-chicago-1",
|
|
23
|
-
|
|
29
|
+
region="us-chicago-1",
|
|
30
|
+
oci_apiformat="GENERIC",
|
|
31
|
+
embedding_model="cohere.embed-english-v3.0",
|
|
24
32
|
)
|
|
25
33
|
profile_attributes = select_ai.ProfileAttributes(
|
|
26
34
|
credential_name="my_oci_ai_profile_key",
|
|
@@ -45,8 +53,7 @@ async def main():
|
|
|
45
53
|
profile=async_profile,
|
|
46
54
|
)
|
|
47
55
|
await async_vector_index.create(replace=True)
|
|
48
|
-
print("
|
|
56
|
+
print("Created vector index: test_vector_index")
|
|
49
57
|
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
asyncio.run(main())
|
|
59
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/vector_index_delete.py
|
|
10
|
+
# ------------------------------------------------------------------------------
|
|
11
|
+
|
|
8
12
|
import asyncio
|
|
9
13
|
import os
|
|
10
14
|
|
|
@@ -22,5 +26,4 @@ async def main():
|
|
|
22
26
|
print("Vector index deleted")
|
|
23
27
|
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
asyncio.run(main())
|
|
29
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/vector_index_list.py
|
|
10
|
+
#
|
|
11
|
+
# List all the vector indexes and associated profile where the index name
|
|
12
|
+
# matches a certain pattern
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
14
|
+
|
|
8
15
|
import asyncio
|
|
9
16
|
import os
|
|
10
17
|
|
|
@@ -23,5 +30,4 @@ async def main():
|
|
|
23
30
|
print("Vector index profile", index.profile)
|
|
24
31
|
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
asyncio.run(main())
|
|
33
|
+
asyncio.run(main())
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# async/vector_index_rag.py
|
|
10
|
+
#
|
|
11
|
+
# Demonstrates Retrieval Augmented Generation (RAG) using ai_profile.narrate()
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
|
|
8
15
|
import asyncio
|
|
9
16
|
import os
|
|
10
17
|
|
|
@@ -20,9 +27,10 @@ async def main():
|
|
|
20
27
|
async_profile = await select_ai.AsyncProfile(
|
|
21
28
|
profile_name="async_oci_vector_ai_profile"
|
|
22
29
|
)
|
|
23
|
-
r = await async_profile.narrate(
|
|
30
|
+
r = await async_profile.narrate(
|
|
31
|
+
"list the conda environments in my object store"
|
|
32
|
+
)
|
|
24
33
|
print(r)
|
|
25
34
|
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
asyncio.run(main())
|
|
36
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
# conversation_chat_session.py
|
|
10
|
+
#
|
|
11
|
+
# Demonstrates context aware conversation using AI Profile
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
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
|
+
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(conversation=conversation, delete=True) as session:
|
|
29
|
+
print(
|
|
30
|
+
"Conversation ID for this session is:",
|
|
31
|
+
conversation.conversation_id,
|
|
32
|
+
)
|
|
33
|
+
response = session.chat(
|
|
34
|
+
prompt="What is importance of history of science ?"
|
|
35
|
+
)
|
|
36
|
+
print(response)
|
|
37
|
+
response = session.chat(
|
|
38
|
+
prompt="Elaborate more on 'Learning from past mistakes'"
|
|
39
|
+
)
|
|
40
|
+
print(response)
|
|
@@ -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
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# conversation_create.py
|
|
10
|
+
#
|
|
11
|
+
# Create a new conversation given a title and description. The created
|
|
12
|
+
# conversation can be used in profile.chat_session()
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
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
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
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
|
+
conversation_id = conversation.create()
|
|
29
|
+
|
|
30
|
+
print("Created conversation with conversation id: ", conversation_id)
|
|
@@ -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
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# conversation_delete.py
|
|
10
|
+
#
|
|
11
|
+
# Delete conversation given a conversation id
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
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
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
23
|
+
conversation = select_ai.Conversation(
|
|
24
|
+
conversation_id="37DDC22E-11C8-3D49-E063-D81A000A85FE"
|
|
25
|
+
)
|
|
26
|
+
conversation.delete(force=True)
|
|
27
|
+
print(
|
|
28
|
+
"Deleted conversation with conversation id: ",
|
|
29
|
+
conversation.conversation_id,
|
|
30
|
+
)
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# conversations_list.py
|
|
10
|
+
#
|
|
11
|
+
# List all conversations saved in the database
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import os
|
|
9
15
|
|
|
10
16
|
import select_ai
|
|
@@ -13,14 +19,7 @@ user = os.getenv("SELECT_AI_USER")
|
|
|
13
19
|
password = os.getenv("SELECT_AI_PASSWORD")
|
|
14
20
|
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for conversation in select_ai.Conversation().list():
|
|
21
|
-
print(conversation.conversation_id)
|
|
22
|
-
print(conversation.attributes)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if __name__ == "__main__":
|
|
26
|
-
main()
|
|
22
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
23
|
+
for conversation in select_ai.Conversation().list():
|
|
24
|
+
print(conversation.conversation_id)
|
|
25
|
+
print(conversation.attributes)
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
# create_ai_credential.py
|
|
10
|
+
#
|
|
11
|
+
# Create a Database credential storing OCI Gen AI's credentials
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
import os
|
|
14
|
+
|
|
15
|
+
import oci
|
|
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
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
23
|
+
|
|
24
|
+
# Default config file and profile
|
|
25
|
+
default_config = oci.config.from_file()
|
|
26
|
+
oci.config.validate_config(default_config)
|
|
27
|
+
with open(default_config["key_file"]) as fp:
|
|
28
|
+
key_contents = fp.read()
|
|
29
|
+
credential = {
|
|
30
|
+
"credential_name": "my_oci_ai_profile_key",
|
|
31
|
+
"user_ocid": default_config["user"],
|
|
32
|
+
"tenancy_ocid": default_config["tenancy"],
|
|
33
|
+
"private_key": key_contents,
|
|
34
|
+
"fingerprint": default_config["fingerprint"],
|
|
35
|
+
}
|
|
36
|
+
select_ai.create_credential(credential=credential, replace=True)
|
|
37
|
+
print("Created credential: ", credential["credential_name"])
|
|
@@ -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
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# disable_ai_provider.py
|
|
10
|
+
#
|
|
11
|
+
# Revokes privileges from the database user and removes ACL to invoke the AI
|
|
12
|
+
# Provider endpoint
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
import select_ai
|
|
17
|
+
|
|
18
|
+
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
|
|
19
|
+
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
|
|
20
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
21
|
+
select_ai_user = os.getenv("SELECT_AI_USER")
|
|
22
|
+
|
|
23
|
+
select_ai.connect(user=admin_user, password=password, dsn=dsn)
|
|
24
|
+
select_ai.disable_provider(
|
|
25
|
+
users=select_ai_user, provider_endpoint="*.openai.azure.com"
|
|
26
|
+
)
|
|
27
|
+
print("Disabled AI provider for user: ", select_ai_user)
|
|
@@ -5,22 +5,29 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# enable_ai_provider.py
|
|
10
|
+
#
|
|
11
|
+
# Grants privileges to the database user and add ACL to invoke the AI Provider
|
|
12
|
+
# endpoint
|
|
13
|
+
# ------------------------------------------------------------------------------
|
|
14
|
+
|
|
8
15
|
import os
|
|
9
16
|
|
|
10
17
|
import select_ai
|
|
11
18
|
|
|
12
19
|
admin_user = os.getenv("SELECT_AI_ADMIN_USER")
|
|
13
|
-
password = os.getenv("
|
|
20
|
+
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
|
|
14
21
|
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
15
|
-
|
|
22
|
+
select_ai_user = os.getenv("SELECT_AI_USER")
|
|
16
23
|
|
|
17
24
|
|
|
18
25
|
def main():
|
|
19
26
|
select_ai.connect(user=admin_user, password=password, dsn=dsn)
|
|
20
27
|
select_ai.enable_provider(
|
|
21
|
-
users=
|
|
28
|
+
users=select_ai_user, provider_endpoint="*.openai.azure.com"
|
|
22
29
|
)
|
|
23
|
-
print("Enabled AI provider for
|
|
30
|
+
print("Enabled AI provider for user: ", select_ai_user)
|
|
24
31
|
|
|
25
32
|
|
|
26
33
|
if __name__ == "__main__":
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# http://oss.oracle.com/licenses/upl.
|
|
6
6
|
# -----------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# profile_chat.py
|
|
10
|
+
#
|
|
11
|
+
# Chat using an AI Profile
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
8
14
|
import os
|
|
9
15
|
|
|
10
16
|
import select_ai
|
|
@@ -13,12 +19,7 @@ user = os.getenv("SELECT_AI_USER")
|
|
|
13
19
|
password = os.getenv("SELECT_AI_PASSWORD")
|
|
14
20
|
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
print(profile.chat(prompt="What is OCI ?"))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if __name__ == "__main__":
|
|
24
|
-
main()
|
|
22
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
23
|
+
profile = select_ai.Profile(profile_name="oci_ai_profile")
|
|
24
|
+
response = profile.chat(prompt="What is OCI ?")
|
|
25
|
+
print(response)
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
# profile_create.py
|
|
10
|
+
#
|
|
11
|
+
# Create an OCI Gen AI profile
|
|
12
|
+
# ------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
from pprint import pformat
|
|
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
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
24
|
+
provider = select_ai.OCIGenAIProvider(
|
|
25
|
+
region="us-chicago-1", oci_apiformat="GENERIC"
|
|
26
|
+
)
|
|
27
|
+
profile_attributes = select_ai.ProfileAttributes(
|
|
28
|
+
credential_name="my_oci_ai_profile_key",
|
|
29
|
+
object_list=[{"owner": "SH"}],
|
|
30
|
+
provider=provider,
|
|
31
|
+
)
|
|
32
|
+
profile = select_ai.Profile(
|
|
33
|
+
profile_name="oci_ai_profile",
|
|
34
|
+
attributes=profile_attributes,
|
|
35
|
+
description="MY OCI AI Profile",
|
|
36
|
+
replace=True,
|
|
37
|
+
)
|
|
38
|
+
print("Created profile ", profile.profile_name)
|
|
39
|
+
profile_attributes = profile.get_attributes()
|
|
40
|
+
print(
|
|
41
|
+
"Profile attributes are: ",
|
|
42
|
+
pformat(profile_attributes.dict(exclude_null=False)),
|
|
43
|
+
)
|