Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions samples/async/create_ai_credential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# async/create_ai_credential.py
#
# Async API to create credential
# -----------------------------------------------------------------------------

import asyncio
import os

import oci
import select_ai

user = os.getenv("SELECT_AI_USER")
password = os.getenv("SELECT_AI_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")


async def main():
await select_ai.async_connect(user=user, password=password, dsn=dsn)
default_config = oci.config.from_file()
oci.config.validate_config(default_config)
with open(default_config["key_file"]) as fp:
key_contents = fp.read()
credential = {
"credential_name": "my_oci_ai_profile_key",
"user_ocid": default_config["user"],
"tenancy_ocid": default_config["tenancy"],
"private_key": key_contents,
"fingerprint": default_config["fingerprint"],
}
await select_ai.async_create_credential(
credential=credential, replace=True
)
print("Created credential: ", credential["credential_name"])


asyncio.run(main())
32 changes: 32 additions & 0 deletions samples/async/delete_ai_credential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# async/delete_ai_credential
#
# Async API to delete credential
# -----------------------------------------------------------------------------

import asyncio
import os

import select_ai

user = os.getenv("SELECT_AI_USER")
password = os.getenv("SELECT_AI_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")


async def main():
await select_ai.async_connect(user=user, password=password, dsn=dsn)
await select_ai.async_delete_credential(
credential_name="my_oci_ai_profile_key", force=True
)
print("Deleted credential: my_oci_ai_profile_key")


asyncio.run(main())
33 changes: 33 additions & 0 deletions samples/async/disable_ai_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# async/disable_ai_provider.py
#
# Async API to disable AI provider for database users
# -----------------------------------------------------------------------------

import asyncio
import os

import select_ai

admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")


async def main():
await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
await select_ai.async_disable_provider(
users=select_ai_user, provider_endpoint="*.openai.azure.com"
)
print("Disabled AI provider for user: ", select_ai_user)


asyncio.run(main())
33 changes: 33 additions & 0 deletions samples/async/enable_ai_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# async/enable_ai_provider.py
#
# Async API to enable AI provider for database users
# -----------------------------------------------------------------------------

import asyncio
import os

import select_ai

admin_user = os.getenv("SELECT_AI_ADMIN_USER")
password = os.getenv("SELECT_AI_ADMIN_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
select_ai_user = os.getenv("SELECT_AI_USER")


async def main():
await select_ai.async_connect(user=admin_user, password=password, dsn=dsn)
await select_ai.async_enable_provider(
users=select_ai_user, provider_endpoint="*.openai.azure.com"
)
print("Enabled AI provider for user: ", select_ai_user)


asyncio.run(main())
25 changes: 25 additions & 0 deletions samples/delete_ai_credential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -----------------------------------------------------------------------------
# Copyright (c) 2025, Oracle and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# delete_ai_credential.py
#
# Delete AI credential
# -----------------------------------------------------------------------------
import os

import select_ai

user = os.getenv("SELECT_AI_USER")
password = os.getenv("SELECT_AI_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")

select_ai.connect(user=user, password=password, dsn=dsn)
select_ai.delete_credential(
credential_name="my_oci_ai_profile_key", force=True
)
print("Deleted credential: my_oci_ai_profile_key")
15 changes: 10 additions & 5 deletions src/select_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
# -----------------------------------------------------------------------------

from .action import Action
from .admin import (
create_credential,
disable_provider,
enable_provider,
)
from .async_profile import AsyncProfile
from .base_profile import BaseProfile, ProfileAttributes
from .conversation import (
AsyncConversation,
Conversation,
ConversationAttributes,
)
from .credential import (
async_create_credential,
async_delete_credential,
create_credential,
delete_credential,
)
from .db import (
async_connect,
async_cursor,
Expand All @@ -39,6 +40,10 @@
OCIGenAIProvider,
OpenAIProvider,
Provider,
async_disable_provider,
async_enable_provider,
disable_provider,
enable_provider,
)
from .synthetic_data import (
SyntheticDataAttributes,
Expand Down
116 changes: 0 additions & 116 deletions src/select_ai/admin.py

This file was deleted.

Loading