Skip to content

Commit

Permalink
WMS 11686 - several fixes in the Lab about APEX and GenAI Agent (#362)
Browse files Browse the repository at this point in the history
* ocw feedback

* genai1

* Update manifest.json

* GenAI + Opensearch 2.11

* GENAI

* Known issues

* Update integration.md

* Several fixes mostly for multi region.

* a

* Create genai_agent.md

* Create images folder

* Add files via upload

* Update genai_agent.md

* added Lab 4 (Optional): GenAI Agent

* Update genai_agent.md

* Add files via upload

* Delete a.txt

* completed genai_agent.md

* added genai agent screenshots

* formating changes genai_agent.md

* postgres v1

* v2

* initial  discover.md

* Delete oci-postgresql-genai-lab/3-discover/images directory

* Create images folder

* added screenshots for lab3

* Update discover.md

* PostgresLab

* Update test.md

* -

* Hybrid

* qa

* Create .gitignore

* remove genai agent

* hybrid

* screenshot

* pgvector

* -

* Update integration.md

rsa key

* Missing grants

* Update connect-apex-with-agents.md

* Fixes

* not used

* date

---------

Co-authored-by: mkratky <[email protected]>
Co-authored-by: Hope Fisher <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2025
1 parent 9cac3e4 commit 779527e
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,33 @@ Estimated Time: 20 minutes
### Objectives

In this lab, you will:
- Retrieve the Agent Endpoint ID.
- Configure a Digital Assistant to interact with the Gen AI Agent.
- Install a APEX application that connect to OCI GenAI Agent.

### Prerequisites

This lab assumes you have:
- Access to the Gen AI Agent dashboard.
- GenerativeAI Agent Endpoint ID. See Lab: Connect ODA with GenAI Agent - Task 1
- [Download the APEX app, here](https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/genAiAgents/o/apex_ai_agent_2024_11_19.sql)
- You have already an Autonomous Database with his Admin password ##DB_PASSWORD##
- GenAI Agent Endpoint OCID. See Lab: Connect ODA with GenAI Agent - Task 1
- [Download the APEX app, here](https://raw.githubusercontent.com/mgueury/oci-genai-agent-apex/refs/heads/main/apex_app.sql). In your browser, File / Save (File) As. Then store the file on your laptop

Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD. Here, we use Autonomous database since both are preinstalled.

### Your Notes

Keep a file to keep the details:

````
Autonomous OCID: (sample) ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abcdefghj....
DB Password: (sample) ##YOUR_PASSWORD##
Agent Endpoint OCID: (sample) ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.abcdefghj....
WorkSpace Name: (sample) agent
WorkSpace User: (sample) agent
WorkSpace Password: (sample) ##YOUR_PASSWORD##
````

## Task 1: Policies

1. Click the hamburger menu on the left-hand corner and go to **Oracle Database > Autonomous Transaction Processing**.
Expand All @@ -44,7 +59,7 @@ Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD.
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' }
```
## Task 2: Configure Autonomous Database
## Task 2: Configure APEX
1. Click the hamburger menu on the left-hand corner and go to **Oracle Database > Autonomous Transaction Processing**.
Expand All @@ -53,11 +68,27 @@ Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD.
2. Click on your database name
3. Click on the button **Database Actions / View All Database Actions**
![Database Actions](./images/ai_agent_db_action.png)
![Database Actions](./images/ai_agent_db_action_apex.png)
4. Choose **APEX**. Click **Open**
5. If you have already an existing APEX workspace, log in it. If not, create one with Administration Services.
6. Click **Application Builder / Import**. Choose the APEX app that your downloaded above (apex_ai_agent_xx.sql). Then **Next**.
5. If you have already an existing APEX workspace, go to next step. If not, create one with APEX Administration Services.
- Log into the Administration Service, enter you Admin ##DB_PASSWORD##.
- In Welcome to Oracle APEX!, click **Create Workspace**
- Choose **New Schema**
- In Create Workspace dialog enter for ex: (Keep note of it!)
- Workspace Name: AGENT
- Workspace Username: AGENT
- Workspave Password: ##YOUR_PASSWORD##
- Click **Create Workspace**
- Your workspace is created. Click the top/left, icon **Admin**. The Sign Out. Then return to signin page.
6. Log in your APEX workspace. Ex:
- Workspace: AGENT
- USER: AGENT
- Password: ##YOUR_PASSWORD##
- Click **Sign In**
6. Click **Application Builder / Import**. Choose the APEX app that your downloaded above (apex_app.sql). Then **Next**.
![APEX](./images/ai_agent_apex.png)
Expand All @@ -66,23 +97,72 @@ Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD.
![Import](./images/ai_agent_apex_import.png)
8. Click **Install Supporting Objects**
This will fail with **Supporting Objects Install Error**.
We fix that in the next steps.
9. When the installation is done, click **Edit Application**.
![Edit](./images/ai_agent_apex_edit.png)
10. Click on page 1
11. Open Pre-rendering / CREATE_SESSION
12. Edit the agent endpoint id. Save and Run
![Endpoint](./images/ai_agent_apex_endpoint.png)
## Task 3: Test the application
10. Keep this tab opened. We will fix the import issue first.
## Task 3: Configure Database Rights
1. Type your question in message. Then Send
1. In a second browser tab, go back to the OCI Console, again to Autonomous Database
2. Click the hamburger menu on the left-hand corner and go to **Oracle Database > Autonomous Transaction Processing**.
![Autonomous Database](./images/ai_agent_atp.png)
3. Click on your database name
3. Click on the button **Database Actions / View All Database Actions**
4. Choose **SQL**. Click **Open**
![Database Actions](./images/ai_agent_db_action_sql.png)
5. (Optional) Login as ADMIN
6. In Database Actions / SQL
- Look for the name of your Workspace user. If you created it manually, the name starts with WKSP.
- In the below command, replace with your value of:
- WKSP\_XXXX ( ex: WKSP\_AGENT )
- ##YOUR\_AGENT\_ENDPOINT## ( ex: ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.abcdefghj.... )
- Run the following commands
```
<copy>
EXEC DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL('WKSP_XXXX')
/
grant execute on DBMS_CLOUD to WKSP_XXXX
/
begin
update WKSP_XXXX.AI_AGENT_RAG_CONFIG set value='##YOUR_AGENT_ENDPOINT##' where key='agent_endpoint';
commit;
end;
/
</copy>
```
![Grants](./images/ai_agent_atp_grant.png)
## Task 4: Test the application
1. Back on your APEX tab of Task 2. Now, click Run **Application**
2. Login
- User: AGENT (=your workspace user)
- Password: ##YOUR_PASSWORD##
3. Type your question in message. Then Send
![Test](./images/ai_agent_apex_test.png)
2. Check the response. Hover the mouse to see the citations of the original documents.
3. Click on the link of the original document to see it.
4. Check the response. Hover the mouse to see the citations of the original documents.
5. Click on the link of the original document to see it.
## Known issues
### Error: ORA-20404: Object not found - https://agent-runtime.generativeai.eu-frankfurt-1.oci.oraclecloud.com/20240531/agentEndpoints/ocid1.genaiagentendpoint.oc1.eu-frankfurt-
- You have an issue in the OCID of your AGENT_ENDPOINT_ID. Check the format.
- Or the Policy (Task 1) is incorrect
## Learn More
Expand All @@ -93,4 +173,4 @@ Note: The lab should work also with any Database 19c+ with APEX and DBMS_CLOUD.
* **Author** - Anshuman Panda, Marc Gueury, Alexandru Negrea
* **Last Updated By/Date** - Marc Gueury - Nov 2024
* **Last Updated By/Date** - Marc Gueury - Jan 2025
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 779527e

Please sign in to comment.