select_ai.agent adds a thin Python layer over Oracle Autonomous Database’s
DBMS_CLOUD_AI_AGENT package so you can define tools, compose tasks, wire up
agents and run teams from Python using the existing Select AI connection
objects.
Keep agent state and orchestration in the database
Register callable tools (PL/SQL procedure or functions, SQL, external HTTP endpoints, Slack or Email notifications) and attach them to tasks
Group agents into teams and invoke them with a single API call
Agent workflows build on the same setup used by profiles: connect to Oracle Database, create or reuse a Select AI profile, create credentials for any external service used by tools, and grant network access for external endpoints. See Connection, Profile, Credential, and Privileges.
The usual agent workflow is:
Create tools that an agent can use.
Create tasks that describe the work and list the tools available for that task.
Create an agent with a role and an LLM profile.
Create a team that pairs agents with tasks.
Run the team with a user prompt.
Tools, tasks, agents, and teams are database objects. Use replace=True when
you want to recreate an existing object with the same name, and force=True
when cleanup should succeed even if the object does not exist.
1. Tool¶
A callable which Select AI agent can invoke to accomplish a certain task. Users can either register built-in tools or create a custom tool using a PL/SQL stored procedure.
Use focused tools with clear instructions. The task and agent prompts decide when tools are used, so tool names, descriptions, and instructions should be specific enough for the model to choose the right tool.
1.1. Supported Tools¶
Following class methods of select_ai.agent.Tool class
can be used to create tools. Invoking them will create a proxy object in the
Python layer and persist the tool in the Database using
DBMS_CLOUD_AI_AGENT.CREATE_TOOL
Tool Type |
Class Method |
Arguments |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.2. Tool selection¶
Tool type |
Use case |
|---|---|
|
Ask questions over database objects using a Select AI profile. |
|
Answer questions using content indexed by a vector index profile. |
|
Search public web content using a web search credential. |
|
Send a Slack notification from an agent workflow. |
|
Send an email notification from an agent workflow. |
|
Call a database procedure or function for application-specific work. |
Notification and web search tools require credentials and network access for the external service. SQL and RAG tools require existing Select AI profiles.
- class select_ai.agent.ToolAttributes(instruction: str | None = None, function: str | None = None, tool_params: ToolParams | None = None, tool_inputs: List[Mapping] | None = None, tool_type: ToolType | None = None)¶
AI Tool attributes
- Parameters:
instruction (str) – Statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
function – Specifies the PL/SQL procedure or function to call when the tool is used
tool_params (select_ai.agent.ToolParams) – Tool parameters for built-in tools
tool_inputs (List[Mapping]) – Describes input arguments. Similar to column comments in a table. Each mapping can include keys such as
nameanddescription.
- class select_ai.agent.ToolParams(_REQUIRED_FIELDS: List | None = None, credential_name: str | None = None, endpoint: str | None = None, notification_type: NotificationType | None = None, profile_name: str | None = None, recipient: str | None = None, sender: str | None = None, channel: str | None = None, smtp_host: str | None = None, subject: str | None = None)¶
Parameters to register a built-in Tool
- Parameters:
credential_name (str) – Used by SLACK, EMAIL and WEBSEARCH tools
endpoint (str) – Send HTTP requests to this endpoint
select_ai.agent.NotificationType – Either SLACK or EMAIL
profile_name (str) – Name of AI profile to use
recipient (str) – Recipient used for EMAIL notification
sender (str) – Sender used for EMAIL notification
channel (str) – Slack channel to use
smtp_host (str) – SMTP host to use for EMAIL notification
subject (str) – Email subject to use
- class select_ai.agent.Tool(tool_name: str | None = None, description: str | None = None, attributes: ToolAttributes | None = None)¶
- classmethod create_built_in_tool(tool_name: str, tool_params: ToolParams, tool_type: ToolType, description: str | None = None, replace: bool | None = False, instruction: str | None = None) Tool¶
Register a built-in tool
- Parameters:
tool_name (str) – The name of the tool
tool_params (select_ai.agent.ToolParams) – Parameters required by built-in tool
tool_type (select_ai.agent.ToolType) – The built-in tool type
description (str) – Description of the tool
replace (bool) – Whether to replace the existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- Returns:
select_ai.agent.Tool
- classmethod create_email_notification_tool(tool_name: str, credential_name: str, recipient: str, sender: str, smtp_host: str, description: str | None, subject: str | None = None, replace: bool = False, instruction: str | None = None) Tool¶
Register an email notification tool
- Parameters:
tool_name (str) – The name of the tool
credential_name (str) – The name of the credential
recipient (str) – The recipient of the email
sender (str) – The sender of the email
smtp_host (str) – The SMTP host of the email server
description (str) – The description of the tool
subject (str) – Subject of the email.
replace (bool) – Whether to replace the existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- Returns:
select_ai.agent.Tool
- classmethod create_pl_sql_tool(tool_name: str, function: str, description: str | None = None, replace: bool = False, instruction: str | None = None) Tool¶
Create a custom tool to invoke PL/SQL procedure or function
- Parameters:
tool_name (str) – The name of the tool
function (str) – The name of the PL/SQL procedure or function
description (str) – The description of the tool
replace (bool) – Whether to replace existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- classmethod create_rag_tool(tool_name: str, profile_name: str, description: str | None = None, replace: bool = False, instruction: str | None = None) Tool¶
Register a RAG tool, which will use a VectorIndex linked AI Profile
- Parameters:
tool_name (str) – The name of the tool
profile_name (str) – The name of the profile to use for Vector Index based RAG
description (str) – The description of the tool
replace (bool) – Whether to replace existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- classmethod create_slack_notification_tool(tool_name: str, credential_name: str, channel: str, description: str | None = None, replace: bool = False, instruction: str | None = None) Tool¶
Register a Slack notification tool
- Parameters:
tool_name (str) – The name of the Slack notification tool
credential_name (str) – The name of the Slack credential
channel (str) – The name of the Slack channel
description (str) – The description of the Slack notification tool
replace (bool) – Whether to replace existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- classmethod create_sql_tool(tool_name: str, profile_name: str, description: str | None = None, replace: bool = False, instruction: str | None = None) Tool¶
Register a SQL tool to perform natural language to SQL translation
- Parameters:
tool_name (str) – The name of the tool
profile_name (str) – The name of the profile to use for SQL translation
description (str) – The description of the tool
replace (bool) – Whether to replace existing tool. Default value is False
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- classmethod create_websearch_tool(tool_name: str, credential_name: str, description: str | None, replace: bool = False, instruction: str | None = None) Tool¶
Register a built-in websearch tool to search information on the web
- Parameters:
tool_name (str) – The name of the tool
credential_name (str) – The name of the credential object storing OpenAI credentials
description (str) – The description of the tool
replace (bool) – Whether to replace the existing tool
instruction (str) – A clear, concise statement that describes what the tool should accomplish and how to do it. This text is included in the prompt sent to the LLM.
- delete(force: bool = False)¶
Delete AI Tool from the database
- Parameters:
force (bool) – Force the deletion. Default value is False.
- classmethod delete_tool(tool_name: str, force: bool = False)¶
Class method to delete AI Tool from the database
- Parameters:
tool_name (str) – The name of the tool
force (bool) – Force the deletion. Default value is False.
- disable()¶
Disable AI Tool
- enable()¶
Enable AI Tool
- classmethod fetch(tool_name: str) Tool¶
Fetch AI Tool attributes from the Database and build a proxy object in the Python layer
- Parameters:
tool_name (str) – The name of the AI Task
- Returns:
select_ai.agent.Tool
- Raises:
select_ai.errors.AgentToolNotFoundError – If the AI Tool is not found
- classmethod list(tool_name_pattern: str = '.*') Iterator[Tool]¶
List AI Tools
- Parameters:
tool_name_pattern (str) – Regular expressions can be used to specify a pattern. Function REGEXP_LIKE is used to perform the match. Default value is “.*” i.e. match all tool name.
- Returns:
Iterator[Tool]
- set_attribute(attribute_name: str, attribute_value: Any) None¶
Set the attribute of the AI Agent tool specified by attribute_name and attribute_value.
- set_attributes(attributes: ToolAttributes) None¶
Set the attributes of the AI Agent tool
1.3. Create Tool¶
The following example shows creation of an AI agent tool to perform natural language translation to SQL using an OCI AI profile
import os
from pprint import pformat
import select_ai
import select_ai.agent
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)
profile_attributes = select_ai.ProfileAttributes(
credential_name="my_oci_ai_profile_key",
object_list=[
{"owner": user, "name": "MOVIE"},
{"owner": user, "name": "ACTOR"},
{"owner": user, "name": "DIRECTOR"},
],
provider=select_ai.OCIGenAIProvider(
region="us-chicago-1",
oci_apiformat="GENERIC",
model="meta.llama-4-maverick-17b-128e-instruct-fp8",
),
)
profile = select_ai.Profile(
profile_name="LLAMA_4_MAVERICK",
attributes=profile_attributes,
description="MY OCI AI Profile",
replace=True,
)
# Use the OCI AI Profile to perform natural
# language SQL translation
sql_tool = select_ai.agent.Tool.create_sql_tool(
tool_name="MOVIE_SQL_TOOL",
description="My Select AI MOVIE SQL agent tool",
profile_name="LLAMA_4_MAVERICK",
replace=True,
)
print(sql_tool.tool_name)
print(pformat(sql_tool.attributes))
output:
MOVIE_SQL_TOOL
ToolAttributes(instruction=None,
function=None,
tool_params=SQLToolParams(_REQUIRED_FIELDS=None,
credential_name=None,
endpoint=None,
notification_type=None,
profile_name='oci_ai_profile',
recipient=None,
sender=None,
channel=None,
smtp_host=None),
tool_inputs=None,
tool_type=<ToolType.SQL: 'SQL'>)
1.4. List Tools¶
import os
import select_ai
import select_ai.agent
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)
for tool in select_ai.agent.Tool.list():
print(tool.tool_name)
output:
WEB_SEARCH_TOOL
MOVIE_SQL_TOOL
LLM_CHAT_TOOL
2. Task¶
Each task is identified by a task_name and includes a set of attributes that
guide the agent’s behavior during execution.
Key attributes include the instruction, which describes the task’s purpose and
provides context for the agent to reason about when and how to use it,
and the tools list, which specifies which tools the agent can choose from to
accomplish the task. An optional input field allows a task to depend on the
output of prior tasks, enabling task chaining and multi-step workflows.
- class select_ai.agent.TaskAttributes(instruction: str, tools: List[str] | None = None, input: str | None = None, enable_human_tool: bool | None = True)¶
AI Task attributes
- Parameters:
instruction (str) – Statement describing what the task is meant to accomplish
tools (List[str]) – List of tools the agent can use to execute the task
input (str) – Task name whose output will be automatically provided by select ai to LLM
enable_human_tool (bool) – Enable agent to ask question to user when it requires information or clarification during a task. Default value is True.
- class select_ai.agent.Task(task_name: str | None = None, description: str | None = None, attributes: TaskAttributes | None = None)¶
select_ai.agent.Task class lets you create, delete, enable, disable and list AI Tasks
- Parameters:
task_name (str) – The name of the AI task
description (str) – Optional description of the AI task
attributes (select_ai.agent.TaskAttributes) – AI task attributes
- create(enabled: bool | None = True, replace: bool | None = False)¶
Create a task that a Select AI agent can include in its reasoning process
- Parameters:
enabled (bool) – Whether the AI Task should be enabled. Default value is True.
replace (bool) – Whether the AI Task should be replaced. Default value is False.
- delete(force: bool = False)¶
Delete AI Task from the database
- Parameters:
force (bool) – Force the deletion. Default value is False.
- classmethod delete_task(task_name: str, force: bool = False)¶
Class method to delete AI Task from the database
- Parameters:
task_name (str) – The name of the AI Task
force (bool) – Force the deletion. Default value is False.
- disable()¶
Disable AI Task
- enable()¶
Enable AI Task
- classmethod fetch(task_name: str) Task¶
Fetch AI Task attributes from the Database and build a proxy object in the Python layer
- Parameters:
task_name (str) – The name of the AI Task
- Returns:
select_ai.agent.Task
- Raises:
select_ai.errors.AgentTaskNotFoundError – If the AI Task is not found
- classmethod list(task_name_pattern: str | None = '.*') Iterator[Task]¶
List AI Tasks
- Parameters:
task_name_pattern (str) – Regular expressions can be used to specify a pattern. Function REGEXP_LIKE is used to perform the match. Default value is “.*” i.e. match all tasks.
- Returns:
Iterator[Task]
- set_attribute(attribute_name: str, attribute_value: Any)¶
Set a single AI Task attribute specified using name and value
- Parameters:
attribute_name (str) – The name of the AI Task attribute
attribute_value (str) – The value of the AI Task attribute
- set_attributes(attributes: TaskAttributes)¶
Set AI Task attributes
- Parameters:
attributes (select_ai.agent.TaskAttributes) – Multiple attributes can be specified by passing a TaskAttributes object
2.1. Create Task¶
In the following task, we use the MOVIE_SQL_TOOL created in the
previous step
The instruction is the main task prompt. Use placeholders such as
{query} when the user prompt should be inserted into the task. The
tools list limits which tools the agent can use for the task.
import os
from pprint import pformat
import select_ai
import select_ai.agent
from select_ai.agent import Task, TaskAttributes
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)
task = Task(
task_name="ANALYZE_MOVIE_TASK",
description="Search for movies in the database",
attributes=TaskAttributes(
instruction="Help the user with their request about movies. "
"User question: {query}. "
"You can use SQL tool to search the data from database",
tools=["MOVIE_SQL_TOOL"],
enable_human_tool=False,
),
)
task.create(replace=True)
print(task.task_name)
print(pformat(task.attributes))
output:
ANALYZE_MOVIE_TASK
TaskAttributes(instruction='Help the user with their request about movies. '
'User question: {query}. You can use SQL tool to '
'search the data from database',
tools=['MOVIE_SQL_TOOL'],
input=None,
enable_human_tool=False)
2.2. List Tasks¶
import os
import select_ai
import select_ai.agent
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)
for task in select_ai.agent.Task.list():
print(task.task_name)
output:
WEB_SEARCH_TASK
ANALYZE_MOVIE_TASK
3. Agent¶
A Select AI Agent is defined using agent_name, its attributes and an
optional description. The attributes must include key agent properties such as
profile_name which specifies the LLM profile used for prompt generation
and role, which outlines the agent’s intended role and behavioral context.
The agent profile supplies the model used for planning and reasoning. The role should describe the agent’s domain, boundaries, and expected behavior. Keep the role specific to the tasks assigned to the agent.
- class select_ai.agent.AgentAttributes(profile_name: str, role: str, enable_human_tool: bool | None = True)¶
AI Agent Attributes
- Parameters:
profile_name (str) – Name of the AI Profile which agent will use to send request to LLM
role (str) – Agent’s role also sent to LLM
enable_human_tool (bool) – Enable human tool support. Agent will ask question to the user for any clarification
- class select_ai.agent.Agent(agent_name: str | None = None, description: str | None = None, attributes: AgentAttributes | None = None)¶
select_ai.agent.Agent class lets you create, delete, enable, disable and list AI agents
- Parameters:
agent_name (str) – The name of the AI Agent
description (str) – Optional description of the AI agent
attributes (select_ai.agent.AgentAttributes) – AI agent attributes
- create(enabled: bool | None = True, replace: bool | None = False)¶
Register a new AI Agent within the Select AI framework
- Parameters:
enabled (bool) – Whether the AI Agent should be enabled. Default value is True.
replace (bool) – Whether the AI Agent should be replaced. Default value is False.
- delete(force: bool | None = False)¶
Delete AI Agent from the database
- Parameters:
force (bool) – Force the deletion. Default value is False.
- classmethod delete_agent(agent_name: str, force: bool | None = False)¶
Class method to delete AI Agent from the database
- Parameters:
agent_name (str) – The name of the AI Agent
force (bool) – Force the deletion. Default value is False.
- disable()¶
Disable AI Agent
- enable()¶
Enable AI Agent
- classmethod fetch(agent_name: str) Agent¶
Fetch AI Agent attributes from the Database and build a proxy object in the Python layer
- Parameters:
agent_name (str) – The name of the AI Agent
- Returns:
select_ai.agent.Agent
- Raises:
select_ai.errors.AgentNotFoundError – If the AI Agent is not found
- classmethod list(agent_name_pattern: str | None = '.*') Iterator[Agent]¶
List AI agents matching a pattern
- Parameters:
agent_name_pattern (str) – Regular expressions can be used to specify a pattern. Function REGEXP_LIKE is used to perform the match. Default value is “.*” i.e. match all agent names.
- Returns:
Iterator[Agent]
- set_attribute(attribute_name: str, attribute_value: Any) None¶
Set a single AI Agent attribute specified using name and value
- set_attributes(attributes: AgentAttributes) None¶
Set AI Agent attributes
- Parameters:
attributes (select_ai.agent.AgentAttributes) – Multiple attributes can be specified by passing an AgentAttributes object
3.1. Create Agent¶
import os
import select_ai
from select_ai.agent import (
Agent,
AgentAttributes,
)
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)
agent_attributes = AgentAttributes(
profile_name="LLAMA_4_MAVERICK",
role="You are an AI Movie Analyst. "
"Your can help answer a variety of questions related to movies. ",
enable_human_tool=False,
)
agent = Agent(
agent_name="MOVIE_ANALYST",
attributes=agent_attributes,
)
agent.create(enabled=True, replace=True)
print("Created Agent:", agent)
output:
Created Agent: Agent(agent_name=MOVIE_ANALYST,
attributes=AgentAttributes(profile_name='LLAMA_4_MAVERICK',
role='You are an AI Movie Analyst.
Your can help answer a variety of questions related to movies. ',
enable_human_tool=False), description=None)
4. Team¶
AI Agent Team coordinates the execution of multiple agents working together to
fulfill a user request. Each team is uniquely identified by a team_name and
configured through a set of attributes that define its composition and
execution strategy. The agents attribute specifies an array of agent-task
pairings, allowing users to assign specific tasks to designated agents. User
can perform multiple tasks by assigning the same agent to different tasks.
The process attribute defines how tasks should be executed.
Currently, process="sequential" is used to execute task assignments in
order. Reuse the same agent in multiple team entries when the agent should
perform multiple tasks.
For example:
attributes = TeamAttributes(
agents=[
{"name": "MOVIE_ANALYST", "task": "ANALYZE_MOVIE_TASK"},
{"name": "MOVIE_ANALYST", "task": "SUMMARIZE_MOVIE_TASK"},
],
process="sequential",
)
- class select_ai.agent.TeamAttributes(agents: List[Mapping], process: str = 'sequential')¶
AI agent team attributes
- Parameters:
agents (List[Mapping]) – A List of Python dictionaries, each defining the agent and the task name. [{“name”: “<agent_name>”, “task”: “<task_name>”}]
process (str) – Execution order of tasks. Currently only “sequential” is supported.
- class select_ai.agent.Team(team_name: str, attributes: TeamAttributes | None = None, description: str | None = None)¶
A Team of AI agents work together to accomplish tasks select_ai.agent.Team class lets you create, delete, enable, disable and list AI Tasks.
- Parameters:
team_name (str) – The name of the AI team
description (str) – Optional description of the AI team
attributes (select_ai.agent.TeamAttributes) – AI team attributes
- create(enabled: bool | None = True, replace: bool | None = False)¶
Create a team of AI agents that work together to accomplish tasks.
- Parameters:
enabled (bool) – Whether the AI agent team should be enabled. Default value is True.
replace (bool) – Whether the AI agent team should be replaced. Default value is False.
- delete(force: bool | None = False)¶
Delete an AI agent team from the database
- Parameters:
force (bool) – Force the deletion. Default value is False.
- classmethod delete_team(team_name: str, force: bool | None = False)¶
Class method to delete an AI agent team from the database
- Parameters:
team_name (str) – The name of the AI team
force (bool) – Force the deletion. Default value is False.
- disable()¶
Disable the AI agent team
- enable()¶
Enable the AI agent team
- export(object_storage_credential_name: str | None = None, location: str | None = None, params: str | Mapping | None = None) str | None¶
Export this AI agent team specification.
If object storage details are provided, the specification is written to the given location and None is returned. Otherwise, the specification is returned as a string.
- Parameters:
object_storage_credential_name (str) – Optional credential name used to write the exported specification to object storage. Must be specified together with
location.location (str) – Optional object storage URI where the exported specification should be written. Must be specified together with
object_storage_credential_name.params (str or Mapping) – Optional export parameters. May be a JSON string or a Python mapping.
- Returns:
Exported team specification as a JSON string when exporting inline, or None when exporting to object storage.
- Return type:
str or None
- classmethod export_team(team_name: str, object_storage_credential_name: str | None = None, location: str | None = None, params: str | Mapping | None = None) str | None¶
Export an AI agent team specification.
If object storage details are provided, the specification is written to the given location and None is returned. Otherwise, the specification is returned as a string.
- Parameters:
team_name (str) – Name of the AI agent team to export.
object_storage_credential_name (str) – Optional credential name used to write the exported specification to object storage. Must be specified together with
location.location (str) – Optional object storage URI where the exported specification should be written. Must be specified together with
object_storage_credential_name.params (str or Mapping) – Optional export parameters. May be a JSON string or a Python mapping.
- Returns:
Exported team specification as a JSON string when exporting inline, or None when exporting to object storage.
- Return type:
str or None
- classmethod fetch(team_name: str) Team¶
Fetch AI Team attributes from the Database and build a proxy object in the Python layer
- Parameters:
team_name (str) – The name of the AI Team
- Returns:
select_ai.agent.Team
- Raises:
select_ai.errors.AgentTeamNotFoundError – If the AI Team is not found
- classmethod import_team(profile_name: str, team_name: str | None = None, specification: str | Mapping | None = None, object_storage_credential_name: str | None = None, location: str | None = None, force: bool | None = False, params: str | Mapping | None = None) None¶
Import an AI agent team specification and create the associated team, agents, tasks, and tools in the database.
- Parameters:
profile_name (str) – Name of the Select AI profile to use for the imported team and agents in the target database.
team_name (str) – Optional name for the imported team. If omitted, the team name from the specification is used.
specification (str or Mapping) – Team specification to import. May be a JSON string or a Python mapping. Omit this when importing from object storage.
object_storage_credential_name (str) – Optional credential name used to read the specification from object storage. Must be specified together with
location.location (str) – Optional object storage URI of the specification to import. Must be specified together with
object_storage_credential_name.force (bool) – Whether to replace conflicting database objects during import. Default value is False.
params (str or Mapping) – Optional import parameters. May be a JSON string or a Python mapping.
- classmethod list(team_name_pattern: str | None = '.*') Iterator[Team]¶
List AI Agent Teams
- Parameters:
team_name_pattern (str) – Regular expressions can be used to specify a pattern. Function REGEXP_LIKE is used to perform the match. Default value is “.*” i.e. match all teams.
- Returns:
Iterator[Team]
- run(prompt: str = None, params: Mapping = None)¶
Start a new AI agent team or resume a paused one that is waiting for human input. If you provide an existing process ID and the associated team process is in the WAITING_FOR_HUMAN state, the function resumes the workflow using the input you provide as the human response
- Parameters:
prompt (str) – Optional prompt for the user. If the task is in the RUNNING state, the input acts as a placeholder for the {query} in the task instruction. If the task is in the WAITING_FOR_HUMAN state, the input serves as the human response.
params (Mapping[str, str]) – Optional parameters for the task. Supported keys include
conversation_id, which identifies the conversation session associated with the agent team, andvariables, which provides additional key-value input to the agent team.
- set_attribute(attribute_name: str, attribute_value: Any) None¶
Set the attribute of the AI Agent team specified by attribute_name and attribute_value.
- set_attributes(attributes: TeamAttributes) None¶
Set the attributes of the AI Agent team
4.1. Run Team¶
Team.run(...) starts the team workflow. The prompt argument is passed to
the task and can be referenced by task instructions using {query}.
params can include conversation_id to associate multiple runs with the
same conversation and variables to pass additional key-value inputs.
result = team.run(
prompt="Could you list the movies in the database?",
params={
"conversation_id": conversation_id,
"variables": {"audience": "analyst"},
},
)
import os
import uuid
import select_ai
from select_ai.agent import (
Team,
TeamAttributes,
)
conversation_id = str(uuid.uuid4())
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)
# Team
team = Team(
team_name="MOVIE_AGENT_TEAM",
attributes=TeamAttributes(
agents=[{"name": "MOVIE_ANALYST", "task": "ANALYZE_MOVIE_TASK"}],
process="sequential",
),
)
team.create(enabled=True, replace=True)
print(
team.run(
prompt="Could you list the movies in the database?",
params={"conversation_id": conversation_id},
)
)
output:
The database contains 100 movies with various titles, genres, and release
dates. The list includes a wide range of genres such as Action, Comedy, Drama,
Thriller, Romance, Adventure, Mystery, Sci-Fi, Historical, Biography, War,
Sports, Music, Documentary, Animated, Fantasy, Horror, Western, Family,
and more. The release dates are primarily in January and February of 2019.
Here is a summary of the movies:
1. Action Movie (Action, 2019-01-01)
2. Comedy Film (Comedy, 2019-01-02)
3. Drama Series (Drama, 2019-01-03)
4. Thriller Night (Thriller, 2019-01-04)
5. Romance Story (Romance, 2019-01-05)
6. Adventure Time (Adventure, 2019-01-06)
7. Mystery Solver (Mystery, 2019-01-07)
8. Sci-Fi World (Sci-Fi, 2019-01-08)
9. Historical Epic (Historical, 2019-01-09)
10. Biographical (Biography, 2019-01-10)
... (list continues up to 100 movies)
4.2. Export and Import Team¶
Select AI agent teams can be exported into a portable specification and imported into the same database, a different database, or another Select AI service. The specification describes the team composition and the associated agent, task, and tool definitions that are needed to recreate the team.
Team.export_team() returns the specification as a JSON string by default.
Team.import_team() accepts either that JSON string or a Python mapping
containing the same team definition structure. In most cases, pass a dict,
for example the result of json.loads(exported_spec). Other
JSON-serializable collections.abc.Mapping
objects, such as OrderedDict, can also be used. On import,
profile_name identifies the Select AI profile to use in the target
database. team_name can be provided to create the imported team under a new
name; this is useful when importing into the same database as the source team.
If imported object names conflict with existing agents, tasks, tools, or teams,
set force=True to let the database replace the conflicting objects. Use this
carefully when importing into a shared schema because conflicting components can
be dropped and recreated.
import json
import os
import select_ai
from select_ai.agent import (
Agent,
AgentAttributes,
Task,
TaskAttributes,
Team,
TeamAttributes,
)
user = os.getenv("SELECT_AI_USER")
password = os.getenv("SELECT_AI_PASSWORD")
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
profile_name = os.getenv("SELECT_AI_PROFILE_NAME", "LLAMA_4_MAVERICK")
select_ai.connect(user=user, password=password, dsn=dsn)
task = Task(
task_name="EXPORT_IMPORT_MOVIE_TASK",
description="Task used by the team export/import sample",
attributes=TaskAttributes(
instruction="Help the user with movie questions. Question: {query}",
tools=[],
enable_human_tool=False,
),
)
task.create(replace=True)
agent = Agent(
agent_name="EXPORT_IMPORT_MOVIE_ANALYST",
description="Agent used by the team export/import sample",
attributes=AgentAttributes(
profile_name=profile_name,
role="You are an AI Movie Analyst.",
enable_human_tool=False,
),
)
agent.create(enabled=True, replace=True)
source_team = Team(
team_name="EXPORT_IMPORT_MOVIE_TEAM",
attributes=TeamAttributes(
agents=[
{
"name": agent.agent_name,
"task": task.task_name,
}
],
process="sequential",
),
)
source_team.create(enabled=True, replace=True)
specification = json.loads(source_team.export())
print("Exported specification:")
print(json.dumps(specification, indent=2))
specification["name"] = "IMPORTED_MOVIE_ANALYST"
specification["task"]["task_name"] = "IMPORTED_ANALYZE_MOVIE_TASK"
Team.import_team(
profile_name=profile_name,
team_name="IMPORTED_MOVIE_AGENT_TEAM",
specification=specification,
force=True,
)
team = Team.fetch("IMPORTED_MOVIE_AGENT_TEAM")
print("Imported team:", team)
output:
Exported specification:
{
"name": "EXPORT_IMPORT_MOVIE_ANALYST",
"component_type": "Agent",
"task": {
"task_name": "EXPORT_IMPORT_MOVIE_TASK",
"instruction": "Help the user with movie questions. Question: {query}",
"task_attributes": {
"enable_human_tool": "false",
"tools": []
}
},
"llm_config": {
"name": "LLAMA_4_MAVERICK",
"component_type": "oci"
}
}
Imported team: Team(team_name=IMPORTED_MOVIE_AGENT_TEAM, ...)
The same APIs can also read from or write to object storage by passing both
object_storage_credential_name and location. When exporting to object
storage, Team.export_team() writes the specification to the location and
returns None. When importing from object storage, pass the same credential
and location instead of specification.
4.3. Lifecycle helpers¶
All agent object types support list, fetch, enable, disable, and delete operations.
for tool in select_ai.agent.Tool.list():
print(tool.tool_name)
task = select_ai.agent.Task.fetch("ANALYZE_MOVIE_TASK")
agent = select_ai.agent.Agent.fetch("MOVIE_ANALYST")
team = select_ai.agent.Team.fetch("MOVIE_AGENT_TEAM")
team.disable()
team.enable()
team.delete(force=True)
5. AI agent examples¶
5.1. Web Search Agent using OpenAI’s GPT model¶
import os
import select_ai
from select_ai.agent import (
Agent,
AgentAttributes,
Task,
TaskAttributes,
Team,
TeamAttributes,
Tool,
)
OPEN_AI_CREDENTIAL_NAME = "OPENAI_CRED"
OPEN_AI_PROFILE_NAME = "OPENAI_PROFILE"
SELECT_AI_AGENT_NAME = "WEB_SEARCH_AGENT"
SELECT_AI_TASK_NAME = "WEB_SEARCH_TASK"
SELECT_AI_TOOL_NAME = "WEB_SEARCH_TOOL"
SELECT_AI_TEAM_NAME = "WEB_SEARCH_TEAM"
USER_QUERIES = {
"d917b055-e8a1-463a-a489-d4328a7b2210": "What are the key features for the product highlighted at "
"this URL https://www.oracle.com/artificial-intelligence/database-machine-learning",
"c2e3ff20-f56d-40e7-987c-cc72740c75a5": "What is the main topic at this URL https://www.oracle.com/artificial-intelligence/database-machine-learning",
"25e23a25-07b9-4ed7-be11-f7e5e445d286": "What is the main topic at this URL https://openai.com",
}
# connect
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)
# Create Open AI credential
select_ai.create_credential(
credential={
"credential_name": OPEN_AI_CREDENTIAL_NAME,
"username": "OPENAI",
"password": os.getenv("OPEN_AI_API_KEY"),
},
replace=True,
)
print("Created credential: ", OPEN_AI_CREDENTIAL_NAME)
# # Create Open AI Profile
profile = select_ai.Profile(
profile_name=OPEN_AI_PROFILE_NAME,
attributes=select_ai.ProfileAttributes(
credential_name=OPEN_AI_CREDENTIAL_NAME,
provider=select_ai.OpenAIProvider(model="gpt-4.1"),
),
description="My Open AI Profile",
replace=True,
)
print("Created profile: ", OPEN_AI_PROFILE_NAME)
# Create an AI Agent team
team = Team(
team_name=SELECT_AI_TEAM_NAME,
attributes=TeamAttributes(
agents=[{"name": SELECT_AI_AGENT_NAME, "task": SELECT_AI_TASK_NAME}]
),
)
team.create(replace=True)
# Agent
agent = Agent(
agent_name=SELECT_AI_AGENT_NAME,
attributes=AgentAttributes(
profile_name=OPEN_AI_PROFILE_NAME,
enable_human_tool=False,
role="You are a specialized web search agent that can access web page "
"contents and respond to questions based on its content.",
),
)
agent.create(replace=True)
# Task
task = Task(
task_name=SELECT_AI_TASK_NAME,
attributes=TaskAttributes(
instruction="Answer the user question about the provided URL:{query}",
enable_human_tool=False,
tools=[SELECT_AI_TOOL_NAME],
),
)
task.create(replace=True)
# Tool
web_search_tool = Tool.create_websearch_tool(
tool_name=SELECT_AI_TOOL_NAME,
credential_name=OPEN_AI_CREDENTIAL_NAME,
description="Web Search Tool using OpenAI",
replace=True,
)
print("Created tool: ", SELECT_AI_TOOL_NAME)
# Run the Agent Team
for conversation_id, prompt in USER_QUERIES.items():
response = team.run(
prompt=prompt, params={"conversation_id": conversation_id}
)
print(response)
output:
Created credential: OPENAI_CRED
Created profile: OPENAI_PROFILE
Created tool: WEB_SEARCH_TOOL
The key features of Oracle Database Machine Learning, as highlighted on the
Oracle website, include:
- In-database machine learning: Build, train, and deploy machine learning
models directly inside the Oracle Database, eliminating the need to move
data.
- Support for multiple languages: Use SQL, Python, and R for machine
learning tasks, allowing flexibility for data scientists and developers.
- Automated machine learning (AutoML): Automates feature selection, model
selection, and hyperparameter tuning to speed up model development.
- Scalability and performance: Utilizes Oracle Database’s scalability,
security, and high performance for machine learning workloads.
- Integration with Oracle Cloud: Seamlessly integrates with Oracle
Cloud Infrastructure for scalable and secure deployment.
- Security and governance: Inherits Oracle Database’s robust security,
data privacy, and governance features.
- Prebuilt algorithms: Offers a wide range of in-database algorithms for
classification, regression, clustering, anomaly detection, and more.
- No data movement: Keeps data secure and compliant by performing
analytics and machine learning where the data resides.
These features enable organizations to operationalize machine learning at
scale, improve productivity, and maintain data security and compliance.
The main topic at the URL https://www.oracle.com/artificial-intelligence/database-machine-learning
is Oracle's database machine learning capabilities, specifically how Oracle
integrates artificial intelligence and machine learning features directly
into its database products. The page highlights how users can leverage these
built-in AI and ML tools to analyze data, build predictive models, and enhance
business applications without moving data outside the Oracle Database
environment.
The main topic of the website https://openai.com is artificial
intelligence research and development. OpenAI focuses on creating and
promoting advanced AI technologies, including products like ChatGPT, and
provides information about their research, products, and mission to ensure
that artificial general intelligence benefits all of humanity.