diff --git a/ai-vector-search-apex-adb/apex-app/apex-app.md b/ai-vector-search-apex-adb/apex-app/apex-app.md index 57f3e2c..f287a3b 100644 --- a/ai-vector-search-apex-adb/apex-app/apex-app.md +++ b/ai-vector-search-apex-adb/apex-app/apex-app.md @@ -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. @@ -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 diff --git a/ai-vector-search-apex-adb/apex-app/images/urlpathprefix.png b/ai-vector-search-apex-adb/apex-app/images/urlpathprefix.png index 4e33f7f..6592e8b 100644 Binary files a/ai-vector-search-apex-adb/apex-app/images/urlpathprefix.png and b/ai-vector-search-apex-adb/apex-app/images/urlpathprefix.png differ diff --git a/ai-vector-search-apex-adb/apex/apex.md b/ai-vector-search-apex-adb/apex/apex.md index 0f8975e..6b64a58 100644 --- a/ai-vector-search-apex-adb/apex/apex.md +++ b/ai-vector-search-apex-adb/apex/apex.md @@ -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 \ No newline at end of file diff --git a/ai-vector-search-apex-adb/ask/ask.md b/ai-vector-search-apex-adb/ask/ask.md index 9457ff6..2f9f9fe 100644 --- a/ai-vector-search-apex-adb/ask/ask.md +++ b/ai-vector-search-apex-adb/ask/ask.md @@ -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. @@ -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 diff --git a/ai-vector-search-apex-adb/download/download.md b/ai-vector-search-apex-adb/download/download.md index 1ebcd96..71254cf 100644 --- a/ai-vector-search-apex-adb/download/download.md +++ b/ai-vector-search-apex-adb/download/download.md @@ -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. @@ -107,6 +107,7 @@ From ADMIN user, run the following to ensure your database user has the necessar CREATE USER VECTOR identified by ; 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; @@ -117,6 +118,50 @@ GRANT EXECUTE ON DBMS_CLOUD_AI TO VECTOR; ``` +Enable the Rest Access for the Vector User: + +```sql + +-- 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; +/ + +``` + + +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 + +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; + +/ + +``` + ## Task 5: Option 1 - Create the credential for ADB to access OCI GenAI Service ### OCI GenAI Service @@ -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 @@ -188,9 +235,11 @@ end; ``` -## Task 7: Download ONNX embedding models Using `DBMS\_CLOUD.GET\_OBJECTS` -Now log in as VECTOR or ``, 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 ``, 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. @@ -238,7 +287,9 @@ END; ``` -## 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. @@ -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 diff --git a/ai-vector-search-apex-adb/setup/setup.md b/ai-vector-search-apex-adb/setup/setup.md index 58452e5..ca74a50 100644 --- a/ai-vector-search-apex-adb/setup/setup.md +++ b/ai-vector-search-apex-adb/setup/setup.md @@ -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. @@ -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. @@ -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. @@ -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) @@ -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). @@ -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) @@ -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 diff --git a/ai-vector-search-apex-adb/tables/tables.md b/ai-vector-search-apex-adb/tables/tables.md index e275518..1c2c597 100644 --- a/ai-vector-search-apex-adb/tables/tables.md +++ b/ai-vector-search-apex-adb/tables/tables.md @@ -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 }'; @@ -245,7 +245,7 @@ END; ``` -## 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. @@ -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 @@ -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