Introduction
My previous PAF posts have covered the basics, now for a few more details. This post covers setting up PAF for SELECT AI and then using the SELECT AI components in a workflow.
Firstly, what does Select AI offer us in PAF? Here is a list of the components -
Pre-requisites for SELECT AI
There are a few pre-requisites we need to fulfill, in order to fully leverage these, namely, the creation of profiles, credentials and vector indexes. Let go through these, explaining what each is and how to create them.
Credentials
In PAF Select AI, a credential is the stored authentication object that lets your selected database call an external provider. This could be an AI provider, such as OpenAI. Net, net, I'm letting the DB invoke a 3rd party, using these credentials.
You can create this credential through the PAF UI, or via the following -
BEGIN
DBMS_VECTOR.CREATE_CREDENTIAL(
credential_name => 'OPENAI_CRED',
params => JSON('{
"access_token": "youeAccessToken"
}')
);
END;
/
The UI list is exhaustive and includes many LLMs as well as OCI, Email, Slack etc.
Once you have the credential, then create a profile.
Profiles
A profile in PAF Select AI is a reusable configuration that tells a database how to use an AI provider for a particular task. Think about it, the credential for OpenAI we just created allows us to invoke OpenAI, here we specify the details - e.g.
- AI provider and model — e.g. OpenAI + gpt-4.1
- Credential to use — e.g. OPENAI
- Capability — NL2SQL, RAG, or both
- Optional embedding model — for RAG, e.g. text-embedding-3-large
- Scope/settings — such as the database objects or vector indexes available to the AI workflow
I'm not using the Embedding model, but, for those interested, this enables your agent to answer questions from your own documents—policies, manuals, product descriptions, tickets—rather than relying on the LLM's general knowledge. Naturally, this greatly improves the relevance of the answers and ensures they cite current internal content. I cover the setup of the Embedding model and it's pre-requisites in a dedicated section below.
I also need an In-Database Tool -
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name => 'OPENAI_RAG_PROFILE',
attributes => '{
"provider": "openai",
"credential_name": "OPENAI",
"model": "gpt-4.1",
"embedding_model": "text-embedding-3-large",
"vector_index_name": "ORDER_PROCESSING_DOCS_RAG_INDEX",
"temperature": 0.2,
"max_tokens": 1024
}'
);
END;
EnableNL2SQL
Natural-language question → AI generates SQL → OrdersDB runs SQL → result
Here I can specify which schema, tables, views etc. to use.
Enable RAG - what is it?
Enable RAG turns on Retrieval-Augmented Generation. It lets the AI answer using content you have indexed—such as PDFs, manuals, policies, or product documentation; naturally ensuring far superior results, compared to relying on the selected model’s general knowledge.
And yes, to use RAG, you need to specify an embedding model, e.g. text-embedding-3-large.
You also need a vector index -
A vector index is the searchable store RAG uses to find the most relevant pieces of your documents.
When you create it, PAF will do the following -
- Read your source documents.
- Split them into smaller chunks.
- Use the embedding model to turn each chunk into a vector—a numeric representation of its meaning.
- Store and index those vectors in the database.
How does this work at runtime?
Question → embedding vector → vector index finds similar chunks
→ RAG sends those chunks to the LLM → grounded answer
An example of leveraging such could be -
- Chat input - "How do I get a refund?"
- The index retrieves a policy section titled "Returns and reimbursements"
- The model answers, based on that content
Set this all up as follows -
Enabling RAG / Vector Indexes
Upload docs to Object Storage
Make your corporate docs available in an OCI Object Storage Bucket -
Create a new OCI Credential in PAF
This is to allow access to this bucket -You can validate by executing the following SQL e.g. -
SELECT object_name, bytes
FROM DBMS_CLOUD.LIST_OBJECTS(
credential_name => 'OCI_OBJECT_STORAGE_CRED',
location_uri => 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/NNNNNNNNN/b/niallc-orderProcessingDocs/o/'
);
This should specify the following values -
Create Vector Index
Use the above values.You can also create the Vector index, using the following SQL -
BEGIN
DBMS_CLOUD_AI.CREATE_VECTOR_INDEX(
index_name => 'ORDER_PROCESSING_DOCS_RAG_INDEX',
wait_for_completion => FALSE,
attributes => '{
"vector_db_provider": "oracle",
"location": "https://objectstorage.us-phoenix-1.oraclecloud.com/n/nnn/b/niallc-orderProcessingDocs/o/",
"object_storage_credential_name": "OCI_OBJECT_STORAGE_CRED",
"profile_name": "OPENAI_EMBED_PROFILE",
"vector_dimension": 3072,
"vector_distance_metric": "cosine",
"chunk_size": 1024,
"chunk_overlap": 128,
"match_limit": 5,
"similarity_threshold": 0.6,
"refresh_rate": 60
}'
);
END;
/
Setup is complete, so let's use the Select AI components...
Using the Select AI Components
Select AI
An In-Database Agent is a reusable, database-hosted AI agent definition. It runs in Oracle Database and uses a Select AI profile for its model, credentials, and data access.
Create new -
In-Database Tasks define what the agent can do -
An In-Database Team is an in-database orchestrator for one or more In-Database Agents.
It is the node that receives a user prompt and decides which attached agent(s) should handle it.
I also need an In-Database Tool -
Run read-only SQL queries against the approved OrdersDB tables to answer order and customer questions.
I run in Playground -
Step 1 is the ensure we have the relevant profile -
The profile can be created via the UI or via the following SQL -
/
In the Workflow, drop the SELECT AI component -
The response -
No, customers from Ireland cannot order iBikes. The order guidelines specifically state that there are no iBike sales to customers from Ireland.
Sources:
- Order Guidelines for NiallC Corp.txt (https://objectstorage.us-phoenix-1.oraclecloud.com/n/nnn/b/niallc-orderProcessingDocs/o/Order Guidelines for NiallC Corp.txt)

No comments:
Post a Comment