Skip to content

Commit

Permalink
Updates (#178)
Browse files Browse the repository at this point in the history
* Apex-RAG

This lab is in production for testing purposes.

* update

* updts

* Update manifest.json

* Update apex.md

* Update apex.md

* Update apex.md

* updates

* Update ask.md

* Update tables.md

* updts

* updts

* .

* TEST

* Update download.md

* Update download.md

* f

* .

* Update apex-app.md

* updates

* Update download.md

* updates

* updates

* Delete setup.md

* Update download.md

* updates

* updates

* Update setup.md

* Update setup.md

* Update download.md

* UPDATES

* updates

* Update introduction.md

* updates

* Update setup.md

* Update to:

* Updates

* Updates Formatting

* Updates from Kevin and Ramon @klazarz @ramonamagadan18

* updates

* Delete ai-vector-search-apex-adb directory

* update

* Update download.md

* Image Update

* Updates

* Update ask.md

* Updated ACL configuration

* Update download.md

* Update download.md

* General Updates

* Update tables.md

* Date Changes

* Update tables.md

---------

Co-authored-by: Ana-Maria COMAN <[email protected]>
  • Loading branch information
bhenndricks and anacoman11 authored Oct 11, 2024
1 parent 82c2503 commit 4ac0c49
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 27 deletions.
4 changes: 3 additions & 1 deletion ai-vector-search-apex-adb/apex-app/apex-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Here we will be doing some repetitive work but it will be pretty easy. So we wil
![alt text](images/editremoteserver.png)
2. Edit the remote server and plug in the pre-authenticated request URL.
3. Grab the pre-authenticated request URL from your bucket and plug it into the box where it says endpoint URL. Ensure it is in the format `https://objectstorage.us-ashburn-1.oraclecloud.com/p/-j_vl5Rra_FHPSt1Qx6lVjOdguVRDOjRdqZI/n/xyz`. Make sure the URL cuts off at the point where it mentions your tenancy (e.g., `xyz`). Click **Save Changes**.
![alt text](/images/urlpathprefix.png)
![alt text](images/urlpathprefix.png)
4. Open the same editing page again, copy the static identifier, and paste it into the name of this REST data source. The name should reflect what the static identifier has. Click **Save Changes**.
5. The rest of the URL: `/b/apex_file_storage/o/` will be used to plug into the URL path prefix underneath the base URL.
6. Ensure the URL format cuts off at the tenancy point.
Expand Down Expand Up @@ -85,6 +85,8 @@ You may now [proceed to the next lab](#next).

## Acknowledgements


* **Authors** - Blake Hendricks, Vijay Balebail, Milton Wan
* **Contributors** - Manoj Sundar, Rajeev Rumale

* **Last Updated By/Date** - July 2024
Binary file modified ai-vector-search-apex-adb/apex-app/images/urlpathprefix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions ai-vector-search-apex-adb/apex/apex.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ You may now [proceed to the next lab](#next).

## Acknowledgements

* **Authors** - Blake Hendricks, Monoj Sundar, Vijay Balebail, Milton Wan
* **Contributors** - Rajeev Rumale
* **Authors** - Blake Hendricks, Milton Wan
* **Last Updated By/Date** - July 2024
7 changes: 5 additions & 2 deletions ai-vector-search-apex-adb/ask/ask.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ END;
DECLARE: This section is used to declare the variable result_clob, which will hold the response from the LLM.

BEGIN: Marks the beginning of the executable part of the PL/SQL block.
result_clob := admin.generate_text_response2(:P3_QUESTION,:P3_ID,7) calls the generate_text_response2 function. It passes three parameters:

result\_clob := admin.generate\_text\_response2(:P3\_QUESTION,:P3\_ID,7) calls the generate\_text\_response2 function. It passes three parameters:

1. :P3_QUESTION - The question entered by the user.
2. :P3_ID - The ID of the document selected by the user.
Expand All @@ -133,7 +134,9 @@ Finally assign the result of the function to the APEX page item :P3_ANSWER. If t

## Summary

In this workshop we showcased an AI RAG application using Oracle APEX, Oracle Autonomous Database 23ai with AI Vector Search, and the Oracle Cloud Object Storage. These products and services are important building blocks for many AI solutions.

In this workshop we showcased an AI RAG application using Oracle APEX, Oracle Autonomous Database 23ai with AI Vector Search, and the Oracle Cloud Object Storage. These products and services are important building blocks for many AI solutions.


## Acknowledgements

Expand Down
65 changes: 58 additions & 7 deletions ai-vector-search-apex-adb/download/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ Before we dive into the procedure, make sure you have the following:
15. Select BYOL license type.

16. Click Create Autonomous Database.
![](./images/provision-atp-7.png)

Your console will show that ATP is provisioning. This will take about 2 or 3 minutes to complete.

Your console will show that ADW is provisioning. This will take about 2 or 3 minutes to complete.

You can check the status of the provisioning in the Work Request.

Expand Down Expand Up @@ -107,6 +107,7 @@ From ADMIN user, run the following to ensure your database user has the necessar
<copy>
CREATE USER VECTOR identified by <password>;
GRANT CONNECT to VECTOR;
GRANT CREATE SESSION to VECTOR;
GRANT RESOURCE to VECTOR;
GRANT DB_DEVELOPER_ROLE to VECTOR;
GRANT EXECUTE ON DBMS_CLOUD TO VECTOR;
Expand All @@ -117,6 +118,50 @@ GRANT EXECUTE ON DBMS_CLOUD_AI TO VECTOR;
</copy>
```

Enable the Rest Access for the Vector User:

```sql
<copy>
-- REST ENABLE
BEGIN
ORDS_ADMIN.ENABLE_SCHEMA(
p_enabled => TRUE,
p_schema => 'VECTOR',
p_url_mapping_type => 'BASE_PATH',
p_url_mapping_pattern => 'vector',
p_auto_rest_auth=> FALSE
);
-- ENABLE DATA SHARING
C##ADP$SERVICE.DBMS_SHARE.ENABLE_SCHEMA(
SCHEMA_NAME => 'VECTOR',
ENABLED => TRUE
);
commit;
END;
/
</copy>
```


Last, but not least, we need to create an ACL for making sure that package DBMS_VECTOR_CHAIN (which does a direct callout to internet from PL/SQL without going through APEX webservices packages) works as intended. You can run this as admin:

```sql
<copy>
BEGIN

DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'specific_host_or_ip', -- Restrict to a specific host or IP range so it is not wide open. You can use '*' if you want it open to any connection.
ace => xs$ace_type(privilege_list => xs$name_list('connect'),
principal_name => 'specific_user_or_role', -- Restrict to a specific user or role. For example, "Public"
principal_type => xs_acl.ptype_db)
);

END;

/
</copy>
```

## Task 5: Option 1 - Create the credential for ADB to access OCI GenAI Service

### OCI GenAI Service
Expand Down Expand Up @@ -166,7 +211,9 @@ end;
/
```

## Task 6: Option 2 - Create the credential for ADB to access OpenAI

## Task 5: Option 2 - Create the credential for ADB to access OpenAI


### OpenAI

Expand All @@ -188,9 +235,11 @@ end;
</copy>
```

## Task 7: Download ONNX embedding models Using `DBMS\_CLOUD.GET\_OBJECTS`

Now log in as VECTOR or `<your_database_user>`, use the `DBMS\_CLOUD.GET\_OBJECTS` procedure to download the ONNX embedding model files from the Oracle Object Storage bucket into Oracle ADB. You will download two different models.
## Task 6: Download ONNX embedding models Using `DBMS_CLOUD.GET_OBJECTS`

Now log in as VECTOR or `<your_database_user>`, use the `DBMS_CLOUD.GET_OBJECTS` procedure to download the ONNX embedding model files from the Oracle Object Storage bucket into Oracle ADB. You will download two different models.


Run to create the staging directory.

Expand Down Expand Up @@ -238,7 +287,9 @@ END;
</copy>
```

## Task 8: Verify the File in Oracle ADB

## Task 7: Verify the File in Oracle ADB


After downloading the file, you can verify its existence in Oracle ADB by listing the contents of the directory.

Expand Down Expand Up @@ -297,4 +348,4 @@ You may now [proceed to the next lab](#next).
## Acknowledgements

* **Authors** - Blake Hendricks, Vijay Balebail, Milton Wan
* **Last Updated By/Date** - July 2024
* **Last Updated By/Date** - Blake Hendricks, October 2024
28 changes: 17 additions & 11 deletions ai-vector-search-apex-adb/setup/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ By completing this lab, you will achieve the following objectives:
* **Generate a Pre-Authenticated Request (PAR) for secure bucket access.**
* You will create a PAR to enable secure and temporary access to your storage bucket without requiring further authentication.

### Task 1: Create an OCI Compartment
## Task 1: Create an OCI Compartment

1. Click the hamburger icon (≡) at the top left corner of the page.

Expand All @@ -50,7 +50,8 @@ By completing this lab, you will achieve the following objectives:

5. Click Create to complete the process.
6. Save the compartment OCID for later use.
![compartment save](/images/compartmentsave.png)
![alt text](images/compartmentsave.png)


The members of the ProdObjectManagers group will require the ability to list the buckets in the compartment and manage any objects in these buckets.

Expand All @@ -60,7 +61,8 @@ By completing this lab, you will achieve the following objectives:
8. Click Create to complete the process.
![Policies](/images/policyconfiguration.png)

### Task 2: Create policy to enable access to OCI GenAI

## Task 2: Create policy to enable access to OCI GenAI

Oracle's GenAI service is an LLM service from Oracle Cloud Infrastructure (OCI). The GenAI service provides access to several LLMs that you can pick from.

Expand Down Expand Up @@ -91,14 +93,16 @@ Compartment: select your own compartment

Note: This policy allows any database in the specified compartment to access OCI Generative AI service. In a production environment, ensure your policy's scope is minimally inclusive.

### Task 3: Save User OCID and Create API Keys

## Task 3: Save User OCID and Create API Keys


1. Click the profile icon in the top right of your OCI page, and click My Profile.
![Users](/images/userprofile.png)
![alt text](images/userprofile.png)
2. Save the user OCID for later use.
![alt text](/images/ocidsave.png)
![alt text](images/ocidsave.png)

### Task 4: Create OCI API Key
## Task 4: Create OCI API Key

1. Select API KEYS under the resources section and add api key.
![alt text](images/addapikey.png)
Expand All @@ -109,14 +113,16 @@ Note: This policy allows any database in the specified compartment to access OCI
![alt text](images/saveconfig.png)
5. Go ahead and close the tab after you have saved the contents.

### Task 5: Grab Your Parent Tenancy OCID
## Task 5: Grab Your Parent Tenancy OCID

1. Type tenancies in the OCI search bar, click the result, and then the tenancy name.
![alt text](images/tenancysearch.png)
2. Copy the tenancy OCID and save it in a separate document for later use.
![alt text](images/copytenancyid.png)

### Task 6: Create a Bucket

## Task 6: Create a Bucket


In Oracle Object Storage, a bucket is a container for storing objects. To access a bucket through the Oracle Cloud Infrastructure REST APIs, complete the following identity management tasks using the Oracle Cloud Infrastructure console and an account that has administrative rights within the tenancy (the root compartment).

Expand All @@ -133,7 +139,7 @@ In Oracle Object Storage, a bucket is a container for storing objects. To access
5. Click Create Bucket to complete the process.
6. To prepare for the successful creation and discovery of the WSM data profile later, upload a dummy file to the `apex_file_storage` bucket now using the Oracle Cloud Infrastructure console.

### Task 7: Create a Pre-Authenticated Request (PAR)
## Task 7: Create a Pre-Authenticated Request (PAR)

1. Click Create Pre-Auth Request on the resources section from the newly created bucket.
![alt text](images/createpreauth.png)
Expand All @@ -151,4 +157,4 @@ You may now [proceed to the next lab](#next).
## Acknowledgements

* **Authors** - Blake Hendricks, Milton Wan
* **Last Updated By/Date** - July 2024
* **Last Updated By/Date** - Blake Hendricks, October 2024
8 changes: 4 additions & 4 deletions ai-vector-search-apex-adb/tables/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ BEGIN
"provider": "openai",
"credential_name": "OPENAI_CRED",
"url": "https://api.openai.com/v1/chat/completions",
"model": "gpt-3.5-turbo-16k",
"model": "gpt-4o-mini",
"max_tokens": 2000,
"temperature": 1.0
}';
Expand All @@ -245,7 +245,7 @@ END;
</copy>
```

## Task 3: Option 2 OCI GenAI Service - Create function to generate response using OCI GenAI LLM
## Task 3: Option 2 IS NOT AVAILABLE AT THE MOMENT. PLEASE USE OPTION 1.

The LLM involves processing both the user question and relevant text excerpts to generate responses tailored specifically to the provided context. It's essential to note that the nature of the response is contingent upon the question and the LLM utilized.

Expand Down Expand Up @@ -318,7 +318,7 @@ BEGIN
"provider":"ocigenai",
"credential_name": "GENAI_CRED",
"url": "https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/generateText",
"model": "cohere.command",
"model": "cohere.command-r-16k",
"inferenceRequest": {
"maxTokens": 2000,
"temperature": 1
Expand Down Expand Up @@ -405,4 +405,4 @@ You may now [proceed to the next lab](#next).
## Acknowledgements

* **Authors** - Vijay Balebail, Milton Wan, Blake Hendricks
* **Last Updated By/Date** - Milton Wan, July 2024
* **Last Updated By/Date** - Blake Hendricks, October 2024

0 comments on commit 4ac0c49

Please sign in to comment.