This directory contains samples for python-select-ai. To run the scripts, define and export the following environment variables
export SELECT_AI_ADMIN_USER=<db_admin>
export SELECT_AI_ADMIN_PASSWORD=<db_admin_password>
export SELECT_AI_USER=<select_ai_db_user>
export SELECT_AI_PASSWORD=<select_ai_db_password>
export SELECT_AI_DB_CONNECT_STRING=<db_connect_string>
export TNS_ADMIN=<path/to/dir_containing_tnsnames.ora>Note: In production, do not save secrets in environment variables
SELECT_AI_ADMIN_USERandSELECT_AI_ADMIN_PASSWORDare needed only to grant privileges to regular user. They are used in 2 sample scriptsenable_ai_provider.pyanddisable_ai_provider.py
Some of the new samples use this optional environment variable:
SELECT_AI_PROFILE_NAME— existing profile for the conversation and supervised-team, profile lifecycle, translation, and request-attribute samples.SELECT_AI_SHARE_GRANTEE— database user or role used by the sharing sample.SELECT_AI_OWNER,SELECT_AI_VECTOR_INDEX_NAME,SELECT_AI_TEAM_NAME, andSELECT_AI_CREDENTIAL_NAME— optional names used by the sharing sample.
Create a profile and run a test chat against one of the supported cloud AI providers:
export AWS_ACCESS_KEY_ID=<aws_access_key>
export AWS_SECRET_ACCESS_KEY=<aws_secret_key>
python samples/profile_create_aws.py
export AZURE_API_KEY=<azure_api_key>
python samples/profile_create_azure.py
export GOOGLE_API_KEY=<google_api_key>
python samples/profile_create_gcp.pyThe scripts create or replace the provider credential and profile, grant the database user's HTTP access to the provider endpoint, and print a test chat response. See the provider documentation for the provider settings and representative output.
Create a team with a dedicated supervisor agent, run a prompt through the supervisor workflow, and inspect the database-generated supervisor task:
python samples/agent/team_supervisor_inspect.py
python samples/agent/async/team_supervisor_inspect.pyThe samples set AgentAttributes(supervisor=True) on the coordinating agent
and pass that agent's name as TeamAttributes.supervisor_agent. The database
populates supervisor_task when the team is created.
Retrieve a canonical database definition:
python samples/agent/get_definition.py
python samples/agent/async/get_definition.pyInspect and directly invoke a PL/SQL tool:
python samples/agent/tool_run_describe.py
python samples/agent/async/tool_run_describe.pyThe supervised-team samples above also demonstrate
Team.describe_team()/AsyncTeam.describe_team() and
Team.list_tools()/AsyncTeam.list_tools().
Inspect the latest team execution and its related task and tool history:
python samples/agent/history_list.py
python samples/agent/async/agent_history_list.pyThe async sample uses AsyncTeamHistory, AsyncTaskHistory, and
AsyncToolHistory with async iteration.
Disable and re-enable an existing profile without deleting it:
python samples/profile_enable_disable.py
python samples/async/profile_enable_disable.pyThe scripts use SELECT_AI_PROFILE_NAME when set; otherwise they use the
sample profile name oci_ai_profile.
Translate text while letting the provider detect the source language:
python samples/profile_translate.py
python samples/async/profile_translate.pyThese samples use SELECT_AI_PROFILE_NAME when set and pass only the target
language at the call site. The default profile names are oci_ai_profile for
the synchronous sample and async_oci_ai_profile for the asynchronous sample.
Profile-level language defaults can be configured with ProfileAttributes when
the target is also omitted.
Override profile attributes for one request without changing the saved profile:
python samples/profile_request_attributes.py
python samples/async/profile_request_attributes.pyThe samples demonstrate additional_instructions, integer seed, and source
and target language settings passed through the attributes mapping.
Inspect owner-qualified profiles and vector indexes and grant/revoke access to profiles, vector indexes, teams, and credentials:
python samples/sharing.py
python samples/async/sharing.pySet SELECT_AI_SHARE_GRANTEE before running the scripts. The objects must
already exist, and the scripts should run as their owner. The credential
creation and deletion samples also create and remove a public synonym.
Create a conversation, list its stored prompts, delete a prompt, and manage conversation tags:
python samples/conversation_prompts_tags.py
python samples/async/conversation_prompts_tags.pyThe scripts use SELECT_AI_PROFILE_NAME when set; otherwise they use the
sample profile name oci_ai_profile. See the conversation user guide for
representative output.
Start a Select AI A2A server before running these samples:
select-ai a2a serve --team ORACLE_AI_DATABASE_AGENT --port 8000After starting a local A2A server, run the fixed sales-analysis prompt as a non-blocking task and poll it until completion:
python samples/a2a/task_poll.pyThe sample sends the A2A v0.3 message/send request with
configuration.blocking: false, prints the returned task ID, and polls
tasks/get. Edit ENDPOINT or PROMPT at the top of the script if needed.
Representative output is:
Task 42b...: submitted
Task 42b...: working
Task 42b...: completed
{
"id": "42b...",
"status": {"state": "completed", "timestamp": "..."},
"artifacts": [{"name": "database-agent-result", "parts": ["..."]}]
}
Task IDs, timestamps, and database answers vary between runs.
To compare it with the default blocking behavior, run:
python samples/a2a/blocking_task.pyThis sample intentionally omits configuration.blocking. The server waits
for the database work to finish and returns the completed Task in the initial
message/send response; no polling is needed.
Representative output is:
Task 7e1...: completed
{
"id": "7e1...",
"status": {"state": "completed", "timestamp": "..."},
"artifacts": [{"name": "database-agent-result", "parts": ["..."]}]
}
The dynamic gateway samples submit the A2UI database connection form, open a
temporary worker session, and execute database tasks. The gateway advertises
streaming: false and supports non-blocking task execution with
configuration.blocking: false and tasks/get.
Gateway-specific samples that perform the form handshake and then execute a real database task are in a2a/gateway:
python samples/a2a/gateway/blocking_task.py
python samples/a2a/gateway/task_poll.pySee that README for local Consul, worker, and gateway startup instructions.
The full A2A architecture, protocol details, session lifecycle, and Google Cloud deployment explanation are in the A2A user guide.
SELECT_AI_DB_CONNECT_STRING can be in any one of the following formats
-
TNS alias
export SELECT_AI_DB_CONNECT_STRING=db2025adb_mediumEnsure there is an entry in
$TNS_ADMIN/tnsnames.oramapping to the connect descriptor>> tnsnames.ora db2025adb_medium = (description= (retry_count=20)(retry_delay=3) (address=(protocol=tcps)(port=1521)(host=adb.<region>.oraclecloud.com)) (connect_data=(service_name=db2025adb_medium.adb.oraclecloud.com)) (security=(ssl_server_dn_match=yes)))
-
Complete connect string
export SELECT_AI_DB_CONNECT_STRING="(description= (retry_count=20)(retry_delay=3) (address=(protocol=tcps)(port=1521)(host=adb.<region>.oraclecloud.com)) (connect_data=(service_name=db2025adb_medium.adb.oraclecloud.com)) (security=(ssl_server_dn_match=yes)))"
-
Simplified connect string
export SELECT_AI_DB_CONNECT_STRING="tcps://adb.<region>.oraclecloud.com:1521/db2025adb_medium.adb.oraclecloud.com?retry_count=2&retry_delay=3"