|
| 1 | +# Connect APEX with GenAI Agent |
| 2 | +## Introduction |
| 3 | + |
| 4 | +In this lab, we will learn how to expose Gen AI Agents via Oracle APEX. This involves retrieving the Agent Endpoint ID and configuring APEX to interact with the Gen AI Agent. |
| 5 | + |
| 6 | +Estimated Time: 20 minutes |
| 7 | + |
| 8 | +### Objectives |
| 9 | + |
| 10 | +In this lab, you will: |
| 11 | +- Retrieve the Agent Endpoint ID. |
| 12 | +- Configure a Digital Assistant to interact with the Gen AI Agent. |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +This lab assumes you have: |
| 17 | +- Access to the Gen AI Agent dashboard. |
| 18 | +- GenerativeAI Agent Endpoint ID. See Lab: Connect ODA with GenAI Agent - Task 1 |
| 19 | +- [Download the APEX app, here](https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/genAiAgents/o/apex_ai_agent_2024_11_19.sql) |
| 20 | + |
| 21 | +Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD. Here, we use Autonomous database since both are preinstalled. |
| 22 | + |
| 23 | +## Task 1: Policies |
| 24 | + |
| 25 | +1. Click the hamburger menu on the left-hand corner and go to **Oracle Database > Autonomous Transaction Processing**. |
| 26 | + |
| 27 | +  |
| 28 | + |
| 29 | +2. Click on the Autonomous Database name (or create a new one with all default) and find the OCID (something like ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abcdefghj..) |
| 30 | + |
| 31 | +  |
| 32 | + |
| 33 | +3. Click the hamburger menu on the left-hand corner and go to **Identity and Security > Policies**. |
| 34 | + |
| 35 | +  |
| 36 | + |
| 37 | +4. Change to the root compartment. Create a policy with rules like this one (use your OCID found above) |
| 38 | + |
| 39 | +  |
| 40 | + |
| 41 | + ``` |
| 42 | + allow any-user to manage genai-agent-family in tenancy where request.principal.id='ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abcdefghj...' |
| 43 | + allow any-user to read object-family in tenancy where request.principal.id='ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abcdefghj...' |
| 44 | + allow any-user to manage object-family in tenancy where ALL { request.principal.id='ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abcdefghj...', request.permission = 'PAR_MANAGE' } |
| 45 | + ``` |
| 46 | +
|
| 47 | +## Task 2: Configure Autonomous Database |
| 48 | +
|
| 49 | +1. Click the hamburger menu on the left-hand corner and go to **Oracle Database > Autonomous Transaction Processing**. |
| 50 | +
|
| 51 | +  |
| 52 | +
|
| 53 | +2. Click on your database name |
| 54 | +3. Click on the button **Database Actions / View All Database Actions** |
| 55 | +
|
| 56 | +  |
| 57 | +
|
| 58 | +4. Choose **APEX**. Click **Open** |
| 59 | +5. If you have already an existing APEX workspace, log in it. If not, create one with Administration Services. |
| 60 | +6. Click **Application Builder / Import**. Choose the APEX app that your downloaded above (apex_ai_agent_xx.sql). Then **Next**. |
| 61 | +
|
| 62 | +  |
| 63 | +
|
| 64 | +7. Click **Install Application** |
| 65 | +
|
| 66 | +  |
| 67 | +
|
| 68 | +8. Click **Install Supporting Objects** |
| 69 | +9. When the installation is done, click **Edit Application**. |
| 70 | +
|
| 71 | +  |
| 72 | +
|
| 73 | +10. Click on page 1 |
| 74 | +11. Open Pre-rendering / CREATE_SESSION |
| 75 | +12. Edit the agent endpoint id. Save and Run |
| 76 | +  |
| 77 | + |
| 78 | + ## Task 3: Test the application |
| 79 | +
|
| 80 | +1. Type your question in message. Then Send |
| 81 | +
|
| 82 | +  |
| 83 | +
|
| 84 | +2. Check the response. Hover the mouse to see the citations of the original documents. |
| 85 | +3. Click on the link of the original document to see it. |
| 86 | +
|
| 87 | +## Learn More |
| 88 | +
|
| 89 | +- [Gen AI Agent Documentation](https://docs.oracle.com/en-us/iaas/Content/genAI/getting-started.htm) |
| 90 | +- [Autonomous Database Documentation](https://docs.oracle.com/en-us/iaas/digital-assistant/getting-started.htm) |
| 91 | +
|
| 92 | +## Acknowledgements |
| 93 | +
|
| 94 | +* **Author** - Anshuman Panda, Marc Gueury, Alexandru Negrea |
| 95 | +
|
| 96 | +* **Last Updated By/Date** - Marc Gueury - Nov 2024 |
0 commit comments