You can create and manage your AI profiles through
DBMS_CLOUD_AI package.
Use DBMS_CLOUD_AI to Configure AI Profiles Autonomous Database uses AI profiles to facilitate and configure access to an LLM and to setup for generating, running, and explaining SQL based on natural language prompts. It also facilitates retrieval augmented generation using embedding models and vector indexes and allows for chatting with the LLM.
Autonomous Database uses
AI profiles to facilitate and configure access to an LLM and to setup for
generating, running, and explaining SQL based on natural language prompts.
It also facilitates retrieval augmented generation using
embedding models and vector indexes and allows for chatting with the
LLM.
AI profiles include database objects that are the target for natural
language queries. Metadata used from these targets can include database
table names, column names, column data types, and comments. You create and
configure AI profiles using the DBMS_CLOUD_AI.CREATE_PROFILE
and DBMS_CLOUD_AI.SET_PROFILE
procedures.
In addition to specifying tables
and views in the AI profile, you can also specify tables mapped with
external tables, including those described in Query External Data with
Data Catalog. This enables you to query data not just inside
the database, but also data stored in a data lake's object store.
Grant quotas in tablespace to manage
the amount of space in a specific tablespace to
the user who wants to use Select AI with RAG.
Examples of Privileges
to Run Select AI
The following example grants the EXECUTE
privilege to
ADB_USER:
GRANT execute on DBMS_CLOUD_AI to ADB_USER;
The following example grants EXECUTE
privilege for the DBMS_CLOUD_PIPELINE package
required for
RAG:
GRANT EXECUTE on DBMS_CLOUD_PIPELINE to ADB_USER;
To check the privileges granted to a user for the
DBMS_CLOUD_AI and
DBMS_CLOUD_PIPELINE packages, an
administrator can run the following:
SELECT table_name AS package_name, privilege
FROM DBA_TAB_PRIVS
WHERE grantee = '<username>'
AND (table_name = 'DBMS_CLOUD_PIPELINE'
OR table_name = 'DBMS_CLOUD_AI');
The following example grants ADB_USER the
privilege to use the api.openai.com
endpoint.
Note
This
procedure is not applicable to OCI Generative AI.
host: The host, which can be
the name or the IP address of the host. You can use
a wildcard to specify a domain or an IP subnet. The
host or domain name is not case sensitive.
ace: The access control
entries (ACE). The XS$ACE_TYPE type is provided to
construct each ACE entry for the ACL. For more
details, see Creating ACLs and ACEs.
The following example creates a credential to enable access
to OpenAI.
If
you are using the Azure OpenAI Service principal to authenticate, you can
skip the DBMS_CLOUD.CREATE_CREDENTIAL
procedure. See Examples of Using Select AI for an example of
authenticating using Azure OpenAI Service principal.
The following example grants quotas on tablespace to the
ADB_USER to use Select AI with RAG:
ALTER USER ADB_USER QUOTA 1T ON <tablespace_name>;
To the check the tablespace quota granted to a user, run the
following:
SELECT TABLESPACE_NAME, BYTES, MAX_BYTES
FROM DBA_TS_QUOTAS
WHERE USERNAME = '<username>' AND
TABLESPACE_NAME LIKE 'DATA%';
The parameters are:
TABLESPACE_NAME: The tablespace for which the
quota is assigned. In Autonomous Database, tablespaces are managed
automatically and have DATA as a prefix.
BYTES: The amount of space currently used by
the user in the tablespace.
MAX_BYTES: The maximum quota assigned (in
bytes). If MAX_BYTES is -1, it means the
user has unlimited quota on the tablespace. The database
user creating the vector index must have
MAX_BYTES sufficiently larger than
bytes to accommodate the vector index, or
MAX_BYTES should be -1 for
unlimited quota.
Topics
Use OpenAI To enable OpenAI to generate SQL and text responses to your natural language prompts, obtain API keys from your OpenAI paid account.
Use Cohere To enable Cohere to generate SQL and text responses to your natural language prompts, obtain API keys from your Cohere paid account.
Use Azure OpenAI Service To enable Azure OpenAI Service to generate SQL and text responses to your natural language prompts, configure and provide access to the AI provider.
Use OCI Generative AI To enable OCI Generative AI to generate SQL and text responses to your natural language prompts, generate an API signing key.
Use Google To enable Google AI Studio to generate SQL and text responses to your natural language prompts, obtain API keys from your Google AI Studio paid account.
Use Anthropic To enable Anthropic Developer Console to generate SQL and text responses to your natural language prompts, obtain API keys from your Anthropic Developer Console paid account.
Use Hugging Face To enable Hugging Face as your AI provider to generate SQL and text responses to your natural language prompts, obtain API keys from your Hugging Face paid account.
To enable Azure OpenAI Service to
generate SQL and text responses to your natural language prompts, configure and provide
access to the AI provider.
To use Azure OpenAI Service,
perform the following steps:
Obtain your secret API keys. You can find your API keys in the Resource
Management section of your Azure portal. On your Azure OpenAI Service Resource page, click
Keys and Endpoint. You can copy either KEY1 or
KEY2.
Make note of the resource name and deployment name
as those parameters are used to provide network access
permission and to create your Azure OpenAI Service profile using the DBMS_CLOUD_AI.CREATE_PROFILE
procedure.
To enable Google AI Studio to generate SQL and text responses to your
natural language prompts, obtain API keys from your Google AI Studio paid
account.
To enable Anthropic Developer Console to generate SQL and text responses
to your natural language prompts, obtain API keys from your Anthropic Developer Console paid
account.
To enable Hugging Face as your AI provider to generate SQL and text
responses to your natural language prompts, obtain API keys from your Hugging Face paid
account.
You must run DBMS_CLOUD_AI.SET_PROFILE in each new stateful
database session (connection) before you use SELECT AI. If you
are using a stateless connection, you must use the
DBMS_CLOUD_AI.GENERATE function which enables you to
specify the profile name in each invocation.
The following example with the OpenAI provider creates an
AI profile called OPENAI and sets the
OPENAI profile for the current user session.