Skip to content

Commit f41de97

Browse files
committed
NL2SQL Data Retrieval Agent
1 parent 936feae commit f41de97

File tree

10 files changed

+293
-136
lines changed

10 files changed

+293
-136
lines changed

autonomous-ai-agents/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
# Select AI Agents on Oracle Autonomous Database
2+
# Select AI Agents on Oracle Autonomous AI Database
33

44
## Overview
55

6-
This repository provides a **generic, extensible framework for building Select AI Agents on Oracle Autonomous Database** using the **Select AI Agent framework**.
6+
This repository provides a **generic, extensible framework for building Select AI Agents on Oracle Autonomous AI Database** using the **Select AI Agent framework**.
77

88
Select AI Agents enable natural language interactions with enterprise data by combining large language models (LLMs), database-resident tools, and orchestration logic directly inside Oracle Database. Agents can reason over user input, invoke tools, and return structured, explainable results — all while keeping data governance, security, and execution within the database.
99

@@ -13,20 +13,20 @@ The agents in this repository are **generic Select AI agents**. While some examp
1313

1414
## What is a Select AI Agent?
1515

16-
Select AI Agents are part of the Oracle Autonomous Database Select AI framework. A Select AI Agent:
16+
Select AI Agents are part of the Oracle Autonomous AI Database Select AI framework. A Select AI Agent:
1717

1818
- Accepts natural language input from users
1919
- Uses an LLM to reason about the request
2020
- Invokes database-resident tools (PL/SQL functions)
2121
- Executes logic securely inside the database
22-
- Returns structured and auditable responses
22+
- Returns structured responses
2323

2424
Key characteristics of the Select AI Agent framework include:
2525

26-
- Native integration with Oracle Database
26+
- Native integration with Oracle Autonomous AI Database
2727
- Tool execution through PL/SQL
2828
- Support for tasks, agents, and teams
29-
- Centralized governance and auditing
29+
- Centralized governance and monitoring
3030
- Flexibility to build domain-specific or generic agents
3131

3232
For full details, refer to the official documentation:
@@ -103,7 +103,7 @@ This repository is intended for:
103103
- Data engineers
104104
- Architects
105105
- Platform teams
106-
- AI practitioners working with Oracle Database
106+
- AI practitioners working with Oracle Autonomous AI Database
107107

108108
Anyone looking to build secure, database-native AI agents using Select AI can use this repository as a starting point.
109109

@@ -112,5 +112,4 @@ Anyone looking to build secure, database-native AI agents using Select AI can us
112112
## License
113113

114114
This project is licensed under the **Universal Permissive License (UPL), Version 1.0**.
115-
116115
See: https://oss.oracle.com/licenses/upl/

autonomous-ai-agents/nl2sql_data_retrieval/README.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Select AI - NL2SQL Data Retrieval Agent for Oracle Autonomous Database
1+
# Select AI - NL2SQL Data Retrieval Agent for Oracle Autonomous AI Database
22

3-
## Why This Select AI - NL2SQL Agent Is Better Than Plain Select AI NL2SQL
3+
## How the NL2SQL agent improves upon Select AI NL2SQL
44

55
Oracle Select AI already provides Natural Language to SQL (NL2SQL), but **real-world data retrieval often fails** due to:
66

@@ -34,7 +34,7 @@ into a **single autonomous agent workflow**.
3434
| Chart generation |||
3535
| Config-driven & extensible |||
3636

37-
> **Result:** Higher accuracy, fewer hallucinations, safer SQL, and richer analytical answers.
37+
> **Result:** Higher accuracy, fewer hallucinations, accurate SQL, and richer analytical answers.
3838
3939
---
4040

@@ -56,7 +56,7 @@ Agent Reasoning
5656
Final Verified Answer + Sources
5757
```
5858

59-
The agent dynamically selects tools, retries intelligently, and produces **auditable and explainable outputs**.
59+
The agent dynamically selects tools, retries intelligently, and produces **explainable outputs**.
6060

6161
---
6262

@@ -66,7 +66,7 @@ The agent dynamically selects tools, retries intelligently, and produces **audit
6666
.
6767
├── nl2sql_data_retrieval_tools.sql
6868
│ ├── PL/SQL utility functions
69-
│ ├── OCI Vault integration
69+
│ ├── OCI Vault integration for Websearch credentials
7070
│ ├── Web search enablement
7171
│ └── AI tool registration
7272
@@ -83,10 +83,10 @@ The agent dynamically selects tools, retries intelligently, and produces **audit
8383

8484
## Prerequisites
8585

86-
- Oracle Autonomous Database
86+
- Oracle Autonomous AI Database
8787
- Select AI enabled
88-
- OCI Vault configured (Option for websearch)
89-
- Google Custom Search API enabled (Option for websearch)
88+
- OCI Vault configured (Optional for websearch)
89+
- Google Custom Search API enabled (Optional for websearch)
9090
- Run as ADMIN
9191

9292
---
@@ -126,6 +126,12 @@ Run as ADMIN (or privileged user):
126126
```sql
127127
sqlplus admin@db @nl2sql_data_retrieval_tools.sql
128128
```
129+
### Input Parameters required to run.
130+
- Target schema name (Schema where to the agent team needs to be installed)
131+
- Cloud Config Parameters required for Websearch (This is mandatory to enable Websearch)
132+
- Google Search API Keys needs to be stored in OCI Vault
133+
- Vault Secret OCID's.
134+
- OCI Region name where Vault is created.
129135

130136
### Example Configuration JSON
131137

@@ -134,8 +140,7 @@ sqlplus admin@db @nl2sql_data_retrieval_tools.sql
134140
"credential_name": "OCI_CRED",
135141
"vault_region": "eu-frankfurt-1",
136142
"api_key_vault_secret_ocid": "ocid1.vaultsecret.oc1..aaaa",
137-
"cxid_vault_secret_ocid": "ocid1.vaultsecret.oc1..bbbb",
138-
"ai_profile": "MY_AI_PROFILE"
143+
"cxid_vault_secret_ocid": "ocid1.vaultsecret.oc1..bbbb"
139144
}
140145
```
141146

@@ -144,14 +149,14 @@ sqlplus admin@db @nl2sql_data_retrieval_tools.sql
144149
- Grants required DBMS_CLOUD and Select AI privileges
145150
- Creates `SELECTAI_AGENT_CONFIG`
146151
- Installs `NL2SQL_DATA_RETRIEVAL_FUNCTIONS`
147-
- Registers all AI agent tools
152+
- Registers all AI agent tools.
148153

149154
---
150155

151156
## Installed Tools Explained
152157

153158
### 1️⃣ SQL_TOOL
154-
**Purpose:** Generate SQL from natural language and execute it safely.
159+
**Purpose:** Generate SQL from natural language and run it safely.
155160

156161
**Fail-safe behavior:**
157162
- SQL generation failure → feedback returned to the LLM
@@ -214,17 +219,18 @@ Run:
214219
sqlplus admin@db @nl2sql_data_retrieval_agent.sql
215220
```
216221

217-
### Prompts
218-
- Target schema name
219-
- AI Profile name
222+
### Input Parameters required to run.
223+
- Target schema name (Schema where to the agent team needs to be installed)
224+
- AI Profile name (Select AI Profile name that needs to be used with the Agent)
225+
220226

221227
### Objects Created
222228

223229
| Object | Name |
224-
|------|------|
225-
| Task | NL2SQL_DATA_RETRIEVAL_TASK |
230+
|-------|------|
231+
| Task | NL2SQL_DATA_RETRIEVAL_TASK |
226232
| Agent | NL2SQL_DATA_RETRIEVAL_AGENT |
227-
| Team | NL2SQL_DATA_RETRIEVAL_TEAM |
233+
| Team | NL2SQL_DATA_RETRIEVAL_TEAM |
228234

229235
---
230236

@@ -252,7 +258,6 @@ Specialize agents using tasks.**
252258
|----|-----------|--------|
253259
| Data Retrieval Team | All tools | General analytics |
254260
| Finance Analytics Team | SQL + RANGE | Financial reporting |
255-
| Metadata Explorer Team | DISTINCT | Schema exploration |
256261
| Research Agent Team | WEBSEARCH | External intelligence |
257262
| Visualization Team | SQL + CHART | Dashboards & insights |
258263

@@ -262,24 +267,22 @@ Specialize agents using tasks.**
262267
- Agents bind AI profiles
263268
- Teams orchestrate workflows
264269

265-
---
266-
267-
## Safe Re-Execution
270+
### Example prompts
271+
After creating the NL2SQL Data Retrieval Agent team, you can interact with it using prompts such as:
268272

269-
All scripts are **idempotent**:
270-
- Tools are dropped and recreated
271-
- Tasks, agents, and teams are refreshed
272-
- Secrets remain in OCI Vault
273+
- “How can you help?”
274+
- Ask questions related to the database tables associated with the selected profile.
275+
- To generate visualizations, explicitly mention the chart type, for example:
276+
“Generate a bar chart for the result.” (any supported chart type can be used)
277+
- To perform a web search, ask relevant questions after configuring the required credentials.
273278

274279
---
275280

276281
## Best Practices
277282

278283
- Use `DISTINCT_VALUES_CHECK` before filtering text columns
279-
- Use `RANGE_VALUES_CHECK` for DATE and NUMBER columns
280-
- Always verify web content with `GET_URL_CONTENT`
281-
- Maintain separate AI profiles per environment
282-
- Rotate Vault secrets without code changes
284+
- Use `RANGE_VALUES_CHECK` for DATE and NUMBER columns
285+
- Maintain separate AI profiles per environment
283286

284287
---
285288

@@ -290,7 +293,7 @@ https://oss.oracle.com/licenses/upl/
290293

291294
---
292295

293-
## ✨ Final Thought
296+
## ✨ Final Thoughts
294297

295298
This NL2SQL Data Retrieval Agent elevates Select AI from a **SQL generator** to a **true autonomous data analyst** — capable of reasoning, validating, retrying, enriching, and visualizing data with confidence.
296299

autonomous-ai-agents/oci_autonomous_database/README.md

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The **Select AI - OCI Autonomous Database AI Agent** enables natural-language–
66

77
Unlike traditional scripts or consoles, this agent allows users to:
88
- Provision and manage Autonomous Databases conversationally
9-
- Safely execute lifecycle operations with confirmations
9+
- Run lifecycle operations with confirmations
1010
- Discover OCI resources dynamically (regions, compartments, databases)
1111
- Automate complex OCI workflows through reusable AI tools
1212

@@ -23,7 +23,6 @@ Compared to manual OCI operations or simple chat-based automation, this agent:
2323
- Requires **explicit confirmation for destructive actions**
2424
- Uses **OCI-native APIs** through PL/SQL wrappers
2525
- Produces **human-readable outputs**, not raw JSON dumps
26-
- Is **idempotent and safe to re-run**
2726

2827
---
2928

@@ -85,6 +84,12 @@ Run as ADMIN (or privileged user):
8584
sqlplus admin@db @oci_autonomous_database_tools.sql
8685
```
8786

87+
### Input Parameters required to run.
88+
- Target schema name (Schema where to the agent team needs to be installed)
89+
- Cloud Config Parameters.
90+
- OCI Credentials - Required to access to Object Storage buckets.
91+
- Compartment Name
92+
8893
### Optional Configuration JSON
8994

9095
```json
@@ -147,16 +152,16 @@ Run:
147152
sqlplus admin@db @oci_autonomous_database_agent.sql
148153
```
149154

150-
### Prompts
151-
- Target schema name
152-
- AI Profile name
155+
### Input Parameters required to run.
156+
- Target schema name (Schema where to the agent team needs to be installed)
157+
- AI Profile name (Select AI Profile name that needs to be used with the Agent)
153158

154159
### Objects Created
155160

156161
| Object | Name |
157162
|------|------|
158163
| Task | OCI_AUTONOMOUS_DATABASE_TASKS |
159-
| Agent | OCI_AUTONOMOUS_DATABASE_ADVISOR |
164+
| Agent| OCI_AUTONOMOUS_DATABASE_ADVISOR |
160165
| Team | OCI_AUTONOMOUS_DATABASE_TEAM |
161166

162167
---
@@ -169,7 +174,6 @@ The task enforces:
169174
- Clarifying questions for incomplete input
170175
- Mandatory confirmation for destructive actions
171176
- Human-readable formatting of OCI outputs
172-
- Safe automation of OCI operations
173177

174178
---
175179

@@ -189,15 +193,6 @@ Bind profiles at agent level.**
189193

190194
---
191195

192-
## Safe Re-Execution
193-
194-
All scripts are **safe to re-run**:
195-
- Tasks, agents, and teams are dropped and recreated
196-
- OCI configuration is preserved
197-
- No duplicate OCI resources are created accidentally
198-
199-
---
200-
201196
## Best Practices
202197

203198
- Always use confirmation for destructive actions
@@ -208,16 +203,55 @@ All scripts are **safe to re-run**:
208203

209204
---
210205

206+
## Example Prompts
207+
208+
After creating the Oracle Autonomous Database AI Agent, users can interact with it using prompts such as:
209+
210+
### Discovery & Setup
211+
- “List all OCI regions I am subscribed to.”
212+
- “Show all compartments in my tenancy.”
213+
214+
### Provisioning Autonomous Databases
215+
- “Help me to Provision a new Autonomous Transaction Processing database"
216+
217+
### Listing & Inspecting Databases
218+
- “List all Autonomous Databases in the `Finance` compartment in the Mumbai region.”
219+
- “Get detailed information for the Autonomous Database with OCID `<db_ocid>`.”
220+
221+
### Power & Lifecycle Management
222+
- “Start the Autonomous Database with OCID `<db_ocid>` in the Mumbai region.”
223+
- “Stop the Autonomous Database with OCID `<db_ocid>`.”
224+
- “Restart the Autonomous Database with OCID `<db_ocid>`.”
225+
226+
### Scaling & Resource Management
227+
- “Increase the CPU count of the Autonomous Database `<db_ocid>` to 8 cores.”
228+
- “Update the storage size of the Autonomous Database `<db_ocid>` to 2 TB.”
229+
- “Shrink the Autonomous Database `<db_ocid>` to optimize storage usage.”
230+
231+
### Configuration Updates
232+
- “Enable auto-scaling and update the display name for the Autonomous Database `<db_ocid>`.”
233+
- “Update backup retention to 30 days for the Autonomous Database `<db_ocid>`.”
234+
235+
### Maintenance & Backups
236+
- “Show maintenance run history for maintenance run ID `<maintenance_id>`.”
237+
- “List all backups for the Autonomous Database `<db_ocid>` in the `Finance` compartment.”
238+
239+
### Supporting Resources
240+
- “List all key stores in the `Finance` compartment.”
241+
- “List all DB homes in the `Finance` compartment.”
242+
243+
244+
211245
## License
212246

213247
Universal Permissive License (UPL) 1.0
214248
https://oss.oracle.com/licenses/upl/
215249

216250
---
217251

218-
## ✨ Final Thought
252+
## ✨ Final Thoughts
219253

220-
This OCI Autonomous Database AI Agent turns OCI operations into a **guided, conversational, and safe experience**, blending human judgment with automation.
254+
This OCI Autonomous Database AI Agent turns OCI operations into a **guided, conversational**, blending human judgment with automation.
221255

222256
It is designed for:
223257
- Platform teams

autonomous-ai-agents/oci_autonomous_database/oci_autonomous_database_agent.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rem
1010
rem DESCRIPTION
1111
rem Installer and configuration script for OCI Autonomous Database
1212
rem AI Agent using DBMS_CLOUD_AI_AGENT
13-
rem (Select AI / Oracle AI Database).
13+
rem (Select AI / Oracle Autonomous AI Database).
1414
rem
1515
rem This script performs an interactive installation of an
1616
rem OCI Autonomous Database AI Agent by:
@@ -231,9 +231,9 @@ BEGIN
231231
);
232232
DBMS_OUTPUT.PUT_LINE('Created team OCI_AUTONOMOUS_DATABASE_TEAM');
233233

234-
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
234+
DBMS_OUTPUT.PUT_LINE('-------------------------------------------------');
235235
DBMS_OUTPUT.PUT_LINE('OCI Autonomous Database AI installation COMPLETE');
236-
DBMS_OUTPUT.PUT_LINE('--------------------------------------------');
236+
DBMS_OUTPUT.PUT_LINE('-------------------------------------------------');
237237
END install_oci_autonomous_database_agent;
238238
/
239239

autonomous-ai-agents/oci_autonomous_database/oci_autonomous_database_tools.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ rem oci_autonomous_database_tools.sql
99
rem
1010
rem DESCRIPTION
1111
rem Installer script for OCI Autonomous Database AI tools
12-
rem (Select AI Agent / Oracle AI Database).
12+
rem (Select AI Agent / Oracle Autonomous AI Database).
1313
rem
1414
rem This script installs a consolidated PL/SQL package and registers
1515
rem AI Agent tools used to automate OCI Autonomous Database operations
16-
rem via Select AI Agent (Oracle AI Database).
16+
rem via Select AI Agent (Oracle Autonomous AI Database).
1717
rem
1818
rem RELEASE VERSION
1919
rem 1.1

0 commit comments

Comments
 (0)