Skip to content

Commit 7c37644

Browse files
committed
Merge branch 'refactor/api_design' into 'main'
refactoring of APIs See merge request adbs/python-select-ai!1
2 parents e210728 + 40b4ea0 commit 7c37644

21 files changed

+388
-339
lines changed

examples/3_show_sql.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99

1010
def main():
1111
select_ai.connect(user=user, password=password, dsn=dsn)
12-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
13-
region="us-chicago-1",
12+
13+
provider = select_ai.OCIGenAIProvider(
14+
region="us-chicago-1", oci_apiformat="GENERIC"
15+
)
16+
17+
profile_attributes = select_ai.ProfileAttributes(
1418
credential_name="my_oci_ai_profile_key",
15-
oci_apiformat="GENERIC",
1619
object_list=[{"owner": "SH"}],
20+
provider=provider,
1721
)
22+
1823
profile = select_ai.Profile(
1924
profile_name="oci_ai_profile",
20-
attributes=oci_provider_attributes,
25+
attributes=profile_attributes,
2126
description="MY OCI AI Profile",
2227
replace=True,
2328
)

examples/4_run_sql.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,11 @@
99

1010
def main():
1111
select_ai.connect(user=user, password=password, dsn=dsn)
12-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
13-
region="us-chicago-1",
14-
credential_name="my_oci_ai_profile_key",
15-
oci_apiformat="GENERIC",
16-
object_list=[{"owner": "SH"}],
17-
)
18-
profile = select_ai.Profile(
19-
profile_name="oci_ai_profile",
20-
attributes=oci_provider_attributes,
21-
description="MY OCI AI Profile",
22-
replace=True,
23-
)
24-
# profile.set_attributes(attributes=oci_provider_attributes)
12+
profile = select_ai.Profile(profile_name="oci_ai_profile")
2513
profile.set_attribute(
2614
attribute_name="model", attribute_value="meta.llama-3.1-70b-instruct"
2715
)
16+
print(profile)
2817
prompts = [
2918
"How many promotions are there in the sh database?",
3019
"How many products are there in the sh database ?",

examples/5_chat.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99

1010
def main():
1111
select_ai.connect(user=user, password=password, dsn=dsn)
12-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
13-
model="meta.llama-3.1-70b-instruct"
14-
)
15-
profile = select_ai.Profile(
16-
profile_name="oci_ai_profile",
17-
attributes=oci_provider_attributes,
18-
description="MY OCI AI Profile",
19-
fetch_and_merge_attributes=True,
20-
)
12+
profile = select_ai.Profile(profile_name="oci_ai_profile")
2113
print(profile)
2214
print(profile.chat(prompt="What is OCI ?"))
2315

examples/7_vector_index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
def main():
1111
select_ai.connect(user=user, password=password, dsn=dsn)
12-
profile = select_ai.Profile(
13-
profile_name="oci_ai_profile", fetch_and_merge_attributes=True
14-
)
12+
profile = select_ai.Profile(profile_name="oci_ai_profile", merge=True)
1513
print("fetched profile: ", profile)
1614
vector_index_attributes = select_ai.VectorIndexAttributes(
1715
location="https://objectstorage.us-ashburn-1.oraclecloud.com/n/dwcsdev/b/conda-environment/o/tenant1-pdb3/graph",

examples/8_generate_synthetic_data.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@
77
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
88

99

10+
# This example show how to generate multi-table synthetic data
1011
def main():
1112
select_ai.connect(user=user, password=password, dsn=dsn)
12-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
13-
model="meta.llama-3.1-70b-instruct"
14-
)
15-
profile = select_ai.Profile(
16-
profile_name="oci_ai_profile",
17-
attributes=oci_provider_attributes,
18-
description="MY OCI AI Profile",
19-
fetch_and_merge_attributes=True,
20-
)
13+
profile = select_ai.Profile(profile_name="oci_ai_profile", merge=True)
2114
synthetic_data_params = select_ai.SyntheticDataParams(
2215
sample_rows=100, table_statistics=True, priority="HIGH"
2316
)

examples/9_conversation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
password = os.getenv("SELECT_AI_PASSWORD")
77
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
88

9+
# This example shows how to have a context-aware
10+
# conversation
11+
912

1013
def main():
1114
select_ai.connect(user=user, password=password, dsn=dsn)
12-
profile = select_ai.Profile(
13-
profile_name="oci_ai_profile",
14-
fetch_and_merge_attributes=True,
15-
)
15+
profile = select_ai.Profile(profile_name="oci_ai_profile", merge=True)
1616
conversation_attributes = select_ai.ConversationAttributes(
1717
title="History of Science",
1818
description="LLM's understanding of history of science",

examples/async_examples/1_sql.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
99

1010

11+
# This example shows how to asynchronously generate SQLs nad run SQLs
1112
async def main():
1213
await select_ai.async_connect(user=user, password=password, dsn=dsn)
1314

14-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
15-
region="us-chicago-1",
15+
provider = select_ai.OCIGenAIProvider(
16+
region="us-chicago-1", oci_apiformat="GENERIC"
17+
)
18+
19+
profile_attributes = select_ai.ProfileAttributes(
1620
credential_name="my_oci_ai_profile_key",
17-
oci_apiformat="GENERIC",
1821
object_list=[{"owner": "SH"}],
22+
provider=provider,
1923
)
2024

2125
async_profile = await select_ai.AsyncProfile(
2226
profile_name="async_oci_ai_profile",
23-
attributes=oci_provider_attributes,
27+
attributes=profile_attributes,
2428
description="MY OCI AI Profile",
2529
replace=True,
2630
)

examples/async_examples/2_chat.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010

1111
async def main():
1212
await select_ai.async_connect(user=user, password=password, dsn=dsn)
13-
oci_provider_attributes = select_ai.OCIGenAIProviderAttributes(
14-
model="meta.llama-3.1-70b-instruct"
15-
)
1613
async_profile = await select_ai.AsyncProfile(
17-
profile_name="async_oci_ai_profile",
18-
attributes=oci_provider_attributes,
19-
description="MY OCI AI Profile",
20-
fetch_and_merge_attributes=True,
14+
profile_name="async_oci_ai_profile"
2115
)
22-
2316
# Asynchronously send multiple prompts
2417
chat_tasks = [
2518
async_profile.chat(prompt="What is OCI ?"),

examples/async_examples/3_pipeline.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
async def main():
1212
await select_ai.async_connect(user=user, password=password, dsn=dsn)
1313
async_profile = await select_ai.AsyncProfile(
14-
profile_name="async_oci_ai_profile",
15-
fetch_and_merge_attributes=True,
14+
profile_name="async_oci_ai_profile"
1615
)
1716
prompt_specifications = [
1817
("What is Oracle Autonomous Database?", select_ai.Action.CHAT),

examples/async_examples/4_conversation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
async def main():
1212
await select_ai.async_connect(user=user, password=password, dsn=dsn)
1313
async_profile = await select_ai.AsyncProfile(
14-
profile_name="async_oci_ai_profile",
15-
fetch_and_merge_attributes=True,
14+
profile_name="async_oci_ai_profile"
1615
)
1716
conversation_attributes = select_ai.ConversationAttributes(
1817
title="History of Science",

0 commit comments

Comments
 (0)