Skip to content

Commit

Permalink
wms 11631 (#162)
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
  • Loading branch information
bhenndricks authored Aug 20, 2024
1 parent ca81719 commit a3dcfe1
Show file tree
Hide file tree
Showing 30 changed files with 661 additions and 137 deletions.
26 changes: 14 additions & 12 deletions ai-vector-search-apex-adb/apex-app/apex-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

Set up the APEX application to interact with Oracle Cloud Infrastructure (OCI) data sources. This lab will walk you through the process of setting up web credentials, configuring REST data sources, and updating application definitions.

Estimated Time: 10 minutes

## Objectives

By following this guide, you will:

- Insert OCI credentials.
- Set up REST data sources to connect with OCI.
- Update application definitions and substitutions for proper configuration.

* Insert OCI credentials.
* Set up REST data sources to connect with OCI.
* Update application definitions and substitutions for proper configuration.

### Task 1: Insert OCI Credentials in APEX

Expand All @@ -21,10 +22,10 @@ By following this guide, you will:
![alt text](images/editwebcredentials.png)
![alt text](images/editociaccess.png)
3. Replace the following with the credentials saved earlier:
- **OCI User ID**
- **OCI Private Key** (remove the -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- lines)
- **OCI Tenancy ID**
- **OCI Public Key Fingerprint**
* **OCI User ID**
* **OCI Private Key** (remove the -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- lines)
* **OCI Tenancy ID**
* **OCI Public Key Fingerprint**
4. Click apply changes.
![alt text](images/editociaccessconfig.png)

Expand All @@ -39,7 +40,7 @@ Here we will be doing some repetitive work but it will be pretty easy. So we wil
3. Edit each REST data source (`Bucket V3`, `list_buckets`, `list_objects_in_bucket`) as follows:
![alt text](images/editrestdatasources.png)

#### For `Bucket V3`:
#### For `Bucket V3`

1. Open the `Bucket V3` REST data source, and click the pencil icon to edit the remote server.
![alt text](images/editremoteserver.png)
Expand All @@ -52,14 +53,14 @@ Here we will be doing some repetitive work but it will be pretty easy. So we wil
7. Repeat the same steps for the other two sources `list_buckets` and `list_objects_in_bucket`.
8. Save changes.

#### For `list_buckets`:
#### For `list_buckets`

1. Edit the `list_buckets` REST data source.
2. Click on the parameters section and update the `compartmentid` with your PROD compartment ID.
![alt text](images/listbucketsparameters.png)
3. Save changes.

#### For `list_objects_in_bucket`:
#### For `list_objects_in_bucket`

1. Edit the `list_objects_in_bucket` REST data source.
2. Click on the parameters section and update the `bucket_name` value to reflect the name of the bucket you created earlier.
Expand All @@ -83,5 +84,6 @@ By completing these steps, you have successfully set up your APEX application, c
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** - July 2024
18 changes: 10 additions & 8 deletions ai-vector-search-apex-adb/apex/apex.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

In this lab we will setup an Oracle APEX (Application Express) service with Oracle Autonomous Database for web application development. APEX provides a powerful and user-friendly platform to build scalable, secure, and highly functional web applications. This guide will walk you through the process of setting up an APEX service, creating a workspace, and preparing for application deployment.

Estimated Time: 10 minutes

## Objectives

By following this guide, you will:

- Set up an Oracle APEX service on your ADB instance.
- Create a new APEX workspace and schema.
- Login to your APEX instance.
- Import and configure a pre-built application in APEX.
* Set up an Oracle APEX service on your ADB instance.
* Create a new APEX workspace and schema.
* Login to your APEX instance.
* Import and configure a pre-built application in APEX.

### Task 1: Set Up Oracle APEX Service

Expand All @@ -30,7 +32,6 @@ By following this guide, you will:
8. Enter your desired values for the workspace name, username, and password. Click **Create Workspace**.
![alt text](images/dbactionscredentials.png)


### Task 2: Log In to Your APEX Instance

1. Head back to the Autonomous Database you created.
Expand All @@ -39,9 +40,9 @@ By following this guide, you will:
3. Click **Launch APEX**.
![alt text](images/dbactionlaunchapex.png)
4. Enter the credentials you created with your workspace:
- **Workspace Name**: Enter your workspace name.
- **Username**: Your user you created for the workspace.
- **Password**: The password you created in the workspace for that user.
* **Workspace Name**: Enter your workspace name.
* **Username**: Your user you created for the workspace.
* **Password**: The password you created in the workspace for that user.
5. Click on **App Builder** located on the left of the dashboard.
![alt text](images/dbactionsappbuilder.png)
6. Select **Import** and upload the [SQL file](images/f100.sql) we obtained to access the pre-configured application.
Expand All @@ -55,5 +56,6 @@ In this lab you created the Oracle APEX service and created a workspace. We impo
You may now [proceed to the next lab](#next).

## Acknowledgements

* **Authors** - Blake Hendricks, Milton Wan
* **Last Updated By/Date** - July 2024
Binary file modified ai-vector-search-apex-adb/apex/images/databaseactions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ai-vector-search-apex-adb/apex/images/dbaccessapexinstance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 23 additions & 14 deletions ai-vector-search-apex-adb/ask/ask.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

In this lab, we will load a document and ask a question about it. This process involves launching the application, uploading a document to object storage, selecting the document, previewing it, asking a question, displaying the results, and viewing the PL/SQL call that generates the response. There is no need to run any of the PLSQL in this lab. It will be executed by APEX.

Estimated Time: 10 minutes

## Objectives

By following this guide, you will:

- Launch the application and sign in.
- Load a document to Oracle Object Storage.
- Select and preview the document.
- Ask a question about the document.
- Display the results of the question.
- View the PL/SQL call in the APEX Page Designer.

* Launch the application and sign in.
* Load a document to Oracle Object Storage.
* Select and preview the document.
* Ask a question about the document.
* Display the results of the question.
* View the PL/SQL call in the APEX Page Designer.

## Task 1: Launch Application

Expand All @@ -23,18 +24,20 @@ By following this guide, you will:
![Run Application](images/run.png)
2. Sign into the application with your credentials.


## Task 2: Load Document to Object Store

1. Click on the blue "Upload File" button.
![alt text](images/apex1.png)
2. Select the file you want to upload from your computer.

This will upload it to the object storage.
![alt text](images/apex2.png)

Let's take a look at what PLSQL procedure is storing the document into our object storage.

Open the Apex Page Designer and select Page 12.
Open the Apex Page Designer and select Page 12.

As soon as we load our document this PLSQL procedure is called to put the document in the object storage. In this image we are using our credentials and putting our file to the object storage.
As soon as we load our document this PLSQL procedure is called to put the document in the object storage. In this image we are using our credentials and putting our file to the object storage.
![alt text](images/object.png)

``` sql
Expand Down Expand Up @@ -65,10 +68,11 @@ END;

Let's take a look at the PLSQL code for storing the file into the database table.

Click on Apex Processes Icon and select the Processes tab followed by Store in Local DB. On the right hand side you can view the window for the code. This is where the procedure stores the file to a table that you uploaded to object storage.
Click on Apex Processes Icon and select the Processes tab followed by Store in Local DB. On the right hand side you can view the window for the code. This is where the procedure stores the file to a table that you uploaded to object storage.
We store the file in a table called "My_Books" within our database. As files are stored, a trigger converts the file to text, chunks the text, and creates vector embeddings for the chunks.

![alt text](images/admin.png)

```sql
INSERT INTO ADMIN.MY_BOOKS
(FILE_NAME, file_type,FILE_CONTENT,FILE_SIZE)
Expand All @@ -80,6 +84,7 @@ WHERE name = :P12_FILE;
## Task 3: Select Document from Drop-Down Menu

1. Select the item you just uploaded from the drop-down menu.
![alt text](images/apex3.png)

2. You can view the document you just uploaded by selecting the preview check box.

Expand All @@ -88,6 +93,7 @@ WHERE name = :P12_FILE;
1. After selecting the document, you can go ahead and type a question about the document and hit return.

After sending your question, you can view the results of the answer in the chat box.
![alt text](images/apex4.png)

We can see the PL/SQL call in the APEX Page Designer on page 3.
![Page Designer](images/pagedesign.png)
Expand All @@ -112,21 +118,24 @@ BEGIN
END;
```

### Explanation of PL/SQL code:
### Explanation of PL/SQL code

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:
1. :P3_QUESTION - The question entered by the user.

1. :P3_QUESTION - The question entered by the user.
2. :P3_ID - The ID of the document selected by the user.
3. :7 - A static parameter to return the top 7 chunks.

Finally assign the result of the function to the APEX page item :P3_ANSWER. If the question is null, the answer will also be null; otherwise, it assigns the result of the function call.

## Conclusion
## 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.

## Acknowledgements

* **Authors** - Blake Hendricks
* **Last Updated By/Date** - July 2024
Binary file added ai-vector-search-apex-adb/ask/images/apex1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-vector-search-apex-adb/ask/images/apex2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-vector-search-apex-adb/ask/images/apex3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-vector-search-apex-adb/ask/images/apex4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a3dcfe1

Please sign in to comment.