Skip to content

Repository files navigation

ADB Agent

This is a PoC using ADB (Autonomous Database) and Generative AI from Oracle Cloud.

Features

  • Generate SQL queries from natural language
  • Execute SQL queries on ADB
  • Display results in a web interface

Setup on Oracle Cloud

Setup ADB

  1. uv sync
  2. Create databases using DDL src/sql/oracle_ddl.sql
  3. Migrate data from exported parquet files to ADB by running uv run src/utils/import_parquet_to_oracle.py

Setup Generative AI

  1. Create API Key at https://cloud.oracle.com/identity/domains/my-profile/auth-tokens?region=ap-osaka-1
  2. Download the private key (.pem)
  3. Create folder ~/.oci if it doesn't exist, create config file in the folder and add the following: (We can click on view configuration file button of that key)
[DEFAULT]
user=ocid1.user.oc1..aaaaaaaaavxuh54wqwjenxphssv3vey4ob37eci627kkyhnknktvtxq2s2ya
fingerprint=3b:37:91:d6:e7:f9:fa:be:f3:17:af:64:03:32:fa:36
tenancy=ocid1.tenancy.oc1..aaaaaaaacixtzv2xnngnowsyd37bncbkjatyig7bk32uldjvy6qq34zyapga
region=ap-singapore-1
key_file=<path to your private keyfile> # TODO

Setup ADB AI Profiles

Each profile can be used to run different models, so that we can compare / test different models.

LiveLabs: https://livelabs.oracle.com/pls/apex/r/dbpm/livelabs/run-workshop?p210_wid=3831&p210_wec=&session=6520009178451

  1. Create Policy so that any users of ADB can use Generative AI Service with this Statement:
allow any-user to manage generative-ai-family in compartment okini-data-platform-poc
  1. Create Credential
BEGIN
  DBMS_CLOUD.CREATE_CREDENTIAL(
    credential_name => 'OCI_CRED',
    user_ocid       => 'ocid1.user.oc1..aaaaaaaaavxuh54wqwjenxphssv3vey4ob37eci627kkyhnknktvtxq2s2ya',
    tenancy_ocid    => 'ocid1.tenancy.oc1..aaaaaaaacixtzv2xnngnowsyd37bncbkjatyig7bk32uldjvy6qq34zyapga',
    private_key     => '-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
OCI_API_KEY',
    fingerprint     => '...'
  );
END;
/
  1. Create Profile for each model
begin    
-- Drop the profile in case it already exists
dbms_cloud_ai.drop_profile(
    profile_name => 'genai_llama33',
    force => true
    );    -- Create an AI profile that uses the default LLAMA model on OCI

dbms_cloud_ai.create_profile(
    profile_name => 'genai_llama33',
    attributes =>
    '{"provider": "oci",
    "credential_name": "OCI_CRED",
    "region": "ap-osaka-1",
    "comments":"true",
    "object_list": [
        {"owner": "POC", "name": "users"},
        {"owner": "POC", "name": "booking_payment"},
        {"owner": "POC", "name": "bookings_prod"},
        {"owner": "POC", "name": "rating"},
        {"owner": "POC", "name": "review"}
    ]
    }'
);
end;
/

About

LangGraph agents utilizing ADB (Oracle Autonomous Database)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages