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

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.

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

Select AI Agent Tools

Tool Type

Class Method

Arguments

EMAIL

select_ai.agent.Tool.create_email_notification_tool

  • tool_name

  • credential_name

  • recipient

  • sender

  • smtp_host

HTTP

select_ai.agent.Tool.create_http_tool

  • tool_name

  • credential_name

  • endpoint

SQL

select_ai.agent.Tool.create_sql_tool

  • tool_name

  • profile_name

SLACK

select_ai.agent.Tool.create_slack_notification_tool

  • tool_name

  • credential_name

  • slack_channel

WEBSEARCH

select_ai.agent.Tool.create_websearch_tool

  • tool_name

  • credential_name

PL/SQL custom tool

select_ai.agent.Tool.create_pl_sql_tool

  • tool_name

  • function

RAG

select_ai.agent.Tool.create_rag_tool

  • tool_name

  • profile_name

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. For example: “tool_inputs”: [

    {

    “name”: “data_guard”, “description”: “Only supported values are “Enabled” and “Disabled””

    }

    ]

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, slack_channel: str | None = None, smtp_host: 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

  • slack_channel (str) – Slack channel to use

  • smtp_host (str) – SMTP host to use for EMAIL notification

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) 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

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, replace: bool = False) 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

  • replace (bool) – Whether to replace the existing tool. Default value is False

Returns:

select_ai.agent.Tool

classmethod create_pl_sql_tool(tool_name: str, function: str, description: str | None = None, replace: bool = False) 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

classmethod create_rag_tool(tool_name: str, profile_name: str, description: str | None = None, replace: bool = False) 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

classmethod create_slack_notification_tool(tool_name: str, credential_name: str, slack_channel: str, description: str | None = None, replace: bool = False) 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

  • slack_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

classmethod create_sql_tool(tool_name: str, profile_name: str, description: str | None = None, replace: bool = False) 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

classmethod create_websearch_tool(tool_name: str, credential_name: str, description: str | None, replace: bool = False) 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

delete(force: bool = False)

Delete AI Tool from the database

Parameters:

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.2. 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,
                                         slack_channel=None,
                                         smtp_host=None),
               tool_inputs=None,
               tool_type=<ToolType.SQL: 'SQL'>)

1.3. 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)

output:

Tool(tool_name=MOVIE_SQL_TOOL, attributes=ToolAttributes(instruction='This tool is used to work with SQL queries using natural language. Input should be a natural language query about data or database operations. The tool behavior depends on the configured action: RUNSQL - generates and executes the SQL query returning actual data; SHOWSQL - generates and displays the SQL statement without executing it; EXPLAINSQL - generates SQL and provides a natural language explanation of what the query does. Always provide clear, specific questions about the data you want to retrieve or analyze.', function='dbms_cloud_ai_agent.sql_tool', tool_params=SQLToolParams(_REQUIRED_FIELDS=None, credential_name=None, endpoint=None, notification_type=None, profile_name='oci_ai_profile', recipient=None, sender=None, slack_channel=None, smtp_host=None), tool_inputs=None, tool_type='SQL'), description=My Select AI MOVIE SQL agent tool)

Tool(tool_name=LLM_CHAT_TOOL, attributes=ToolAttributes(instruction='This tool is used to work with SQL queries using natural language. Input should be a natural language query about data or database operations. The tool behavior depends on the configured action: RUNSQL - generates and executes the SQL query returning actual data; SHOWSQL - generates and displays the SQL statement without executing it; EXPLAINSQL - generates SQL and provides a natural language explanation of what the query does. Always provide clear, specific questions about the data you want to retrieve or analyze.', function='dbms_cloud_ai_agent.sql_tool', tool_params=SQLToolParams(_REQUIRED_FIELDS=None, credential_name=None, endpoint=None, notification_type=None, profile_name='oci_ai_profile', recipient=None, sender=None, slack_channel=None, smtp_host=None), tool_inputs=None, tool_type='SQL'), description=My Select AI agent 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.

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

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="Movie task involving a human",
    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)

output:

Task(task_name=ANALYZE_MOVIE_TASK, 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"]', input=None, enable_human_tool=False), description=Movie task involving a human)

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.

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.

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.

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, 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.

disable()

Disable the AI agent team

enable()

Enable the AI agent team

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 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. Currently, the following parameters are supported:

    • conversation_id: Identifies the conversation session associated

    with the agent team

    • variables: key-value pairs that provide additional 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

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)

5. AI agent examples

5.1. Web Search Agent using OpenAI’s GPT model

# -----------------------------------------------------------------------------
# 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.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# movie_analyst.py
#
# Demonstrates web search AI agent
# -----------------------------------------------------------------------------

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.