|
| 1 | +# Introduction |
| 2 | + |
| 3 | +## About this Workshop |
| 4 | + |
| 5 | +This workshop demonstrates how to integrate Oracle APEX with OCI **Generative AI Agents**, showcasing how enterprises can enhance their applications with intelligent, context-aware capabilities. You will explore the power of **Large Language Models (LLMs)** combined with **Retrieval-Augmented Generation (RAG)** to transform raw enterprise documents into actionable insights. |
| 6 | + |
| 7 | +As part of this workshop, you will begin by uploading various documents to OCI Object Storage, which serves as a secure, scalable repository for your enterprise data. These documents are then processed through an **ingestion job**, which parses, indexes, and prepares the data for interaction using the **OCI Generative AI service**. |
| 8 | + |
| 9 | +You will integrate a **chat interface** within your Oracle APEX application, allowing end users to interact with the Generative AI Agent in real time. The AI agent uses the previously ingested content to provide intelligent, personalized, and context-rich responses, enhancing user experience and driving operational efficiency. |
| 10 | + |
| 11 | +Estimated Time: 90 minutes |
| 12 | + |
| 13 | +### Objectives |
| 14 | + |
| 15 | +In this workshop, you will: |
| 16 | + |
| 17 | +- Creating an Agent in OCI Generative AI Agents. |
| 18 | + |
| 19 | +- Add API Keys in the OCI Console. |
| 20 | + |
| 21 | +- Create Web Credentials in Oracle APEX. |
| 22 | + |
| 23 | +- Create Session and Ingestion Job using OCI Ingestion Job REST APIs. |
| 24 | + |
| 25 | +- Set up an automation to monitor the status of incomplete Ingestion Jobs. |
| 26 | + |
| 27 | +- Create and invoke a REST Data Source in your APEX app using the OCI Generative AI Agents' Create Sessions REST API. |
| 28 | + |
| 29 | +- Design and customize a Classic Report for the chat widget. |
| 30 | + |
| 31 | +- Interact with OCI Generative AI Agents through the Chat REST API. |
| 32 | + |
| 33 | +>*Note: This workshop assumes you are using Oracle APEX 24.2. Some of the features might not be available in prior releases and the instructions, flow, and screenshots might differ if you use an older version of Oracle APEX. |
| 34 | +
|
| 35 | +## Prerequisites |
| 36 | + |
| 37 | +- A paid Oracle Cloud Infrastructure (OCI) account or a FREE Oracle Cloud account with $300 credits for 30 days to use on other services. Read more about it at: [oracle.com/cloud/free/](https://www.oracle.com/cloud/free/). |
| 38 | + |
| 39 | +- An OCI compartment. An Oracle Cloud account comes with two pre-configured compartments - The tenancy (root compartment) and ManagedCompartmentForPaaS (created by Oracle for Oracle Platform services). |
| 40 | + |
| 41 | +- The logged-in user should have the necessary privileges to create and manage Autonomous Database instances in this compartment. You can configure these privileges via an OCI IAM Policy. If you are using a Free Tier account, it is likely that you already have all the necessary privileges. |
| 42 | + |
| 43 | +### **Let's Get Started!** |
| 44 | + |
| 45 | +If the menu is not displayed, you can open by clicking the menu button () at the upper-left corner of the page. |
| 46 | + |
| 47 | +## Downloads: Download and Install the Complete Application |
| 48 | + |
| 49 | +If you are stuck or the app is not working as expected, you can download and install the completed App as follows: |
| 50 | + |
| 51 | +1. Setup OCI: |
| 52 | + |
| 53 | + - Follow Lab 1 > Task 1 to generate API keys using the OCI Console, and update the existing web credentials with your credentials. |
| 54 | + |
| 55 | + - Follow Lab 1 > Task 2 to create a bucket in OCI Object Storage. |
| 56 | + |
| 57 | + - Follow Lab 2 > Task 1 and Task 2 to create a Knowledge Base and Generative AI Agents in OCI. |
| 58 | + |
| 59 | +2. [Click here](https://c4u04.objectstorage.us-ashburn-1.oci.customer-oci.com/p/EcTjWk2IuZPZeNnD_fYMcgUhdNDIDA6rt9gaFj_WZMiL7VvxPBNMY60837hu5hga/n/c4u04/b/livelabsfiles/o/genai_agents_export.sql) to download the completed application. |
| 60 | + |
| 61 | +3. Import the **genai\_agents\_export.sql** file into your workspace. Follow the steps in the Install Application wizard to install the app along with the Supporting Objects. |
| 62 | + |
| 63 | +4. Update **Web Credentials** |
| 64 | + |
| 65 | + - Expand **App Builder**, then select **All Workspace Utilities** and click **Workspace Utilities**. |
| 66 | + |
| 67 | +  |
| 68 | + |
| 69 | + - Click **Web Credentials**. |
| 70 | + |
| 71 | +  |
| 72 | + |
| 73 | + - Click **APEX\_OCI\_AI\_CRED**. |
| 74 | + |
| 75 | +  |
| 76 | + |
| 77 | + - Enter the following details using the configuration file you copied and click **Apply Changes**. |
| 78 | + |
| 79 | + - **OCI User ID**: Enter the OCID of the Oracle Cloud user Account. You can find the OCID in the Configuration File Preview generated during the API Key creation. |
| 80 | + Your OCI User ID looks similar to **ocid1.user.oc1..aaaaaaaa\*\*\*\*\*\*wj3v23yla** |
| 81 | + |
| 82 | + - **OCI Private Key**: Open the private key (.pem file) downloaded in the previous task. Copy and paste the API Key. |
| 83 | + |
| 84 | + - **OCI Tenancy ID**: Enter the OCID for Tenancy. Your Tenancy ID looks similar to **ocid1.tenancy.oc1..aaaaaaaaf7ush\*\*\*\*cxx3qka** |
| 85 | + |
| 86 | + - **OCI Public Key Fingerprint**: Enter the Fingerprint ID. Your Fingerprint ID looks similar to **a8:8e:c2:8b:fe:\*\*\*\*:ff:4d:40** |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +5. Navigate to Shared Components > Data Sources > Rest Data Sources > Click **Create Sessions API**. |
| 91 | + |
| 92 | +6. Under Parameters, click **Add Parameter**. |
| 93 | + |
| 94 | +  |
| 95 | + |
| 96 | +7. Enter/select the following: |
| 97 | + |
| 98 | + - Type: **URL Pattern** |
| 99 | + |
| 100 | + - Name: **agentEndpointId** |
| 101 | + |
| 102 | + - Default Value: Enter your agent endpoint OCID, Refer - [Lab 2, Task3, Step 6](?lab=2-configure-kb-genai#Task3:FetchOCIDofGenerativeAIAgentandDataSource) |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +8. Navigate to Page 1 of application, map the following page item: |
| 107 | + |
| 108 | + - Under Body, select **P1\_AGENT\_ENDPOINT\_ID**. |
| 109 | + |
| 110 | + - In the property editor, Default > Type : **Static**. |
| 111 | + |
| 112 | + - Under Static Value: Enter your agent endpoint OCID, Refer - [Lab 2, Task3, Step 6](?lab=2-configure-kb-genai#Task3:FetchOCIDofGenerativeAIAgentandDataSource) |
| 113 | + |
| 114 | +  |
| 115 | + |
| 116 | +9. Navigate to Page 5 of application, map the following page item: |
| 117 | + |
| 118 | + | | Page Item |Default > Type | Default > Static Value | |
| 119 | + |---|-----------------|------|----------| |
| 120 | + | 1 | P5\_COMPARTMENT\_ID| Static |Enter your OCI account Compartment OCID| |
| 121 | + | 2 | P5\_CRED\_STATIC\_ID| Static | APEX\_OCI\_AI\_CRED | |
| 122 | + | 3 | P5\_NAMESPACE\_NAME| Static | Enter Namespace which you copied while creating a Bucket| |
| 123 | + | 4 | P5\_BUCKET\_NAME| Static | Enter the Bucket Name which you copied while creating a Bucket (For this Lab we have **GenAIRAGBucket**) | |
| 124 | + | 5 | P5\_REGION| Static | Enter your Region. e.g. us-chicago-1 | |
| 125 | + | 6 | P5\_DATASOURCE\_ID| Static | Enter your data source OCID.| |
| 126 | + {: title="Map Page Items"} |
| 127 | + |
| 128 | +  |
| 129 | + |
| 130 | +  |
| 131 | + |
| 132 | +  |
| 133 | + |
| 134 | +  |
| 135 | + |
| 136 | +  |
| 137 | + |
| 138 | +  |
| 139 | + |
| 140 | +10. All set. Now, run the application with the users you created and see it in action! |
| 141 | + |
| 142 | +## Learn More - *Useful Links* |
| 143 | + |
| 144 | +- [OCI Generative AI](https://www.oracle.com/artificial-intelligence/generative-ai/large-language-models/) |
| 145 | +- [APEX on Autonomous](https://apex.oracle.com/autonomous) |
| 146 | +- [APEX Collateral](https://www.oracle.com/database/technologies/appdev/apex/collateral.html) |
| 147 | +- [Tutorials](https://apex.oracle.com/en/learn/tutorials) |
| 148 | +- [Community](https://apex.oracle.com/community) |
| 149 | +- [External Site + Slack](http://apex.world) |
| 150 | + |
| 151 | +## Acknowledgements |
| 152 | + |
| 153 | +- **Author(s)**: Roopesh Thokala, Senior Product Manager; Shailu Srivastava, Product Manager |
| 154 | +- **Last Updated By/Date**: Shailu Srivastava, Product Manager, June 2025 |
0 commit comments