Skip to content

upgrading all the 3 rag solutionns with the llm_region feature #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 17 additions & 3 deletions cloud-foundation/solutions/RAG-in-a-Box-Easy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We even allow visibility on the chunking results from the proximitiy search pass
Please refer to the "Show Documentation" button in the app or the field help info (press the '?' next to each field).


## Important - please deploy the solution in one of the listed regions below as the GenAI it's only available in this regions. If you deploy it in other regions, the solution will not work. If you don't have any of the regions available in your tenancy, please subscribe to one of them.
## Important - please deploy the solution in any region but you need to use for the variable llm_region - one of the listed regions below as the GenAI it's only available in this regions. If you deploy it in other regions, the solution will not work. If you don't have any of the regions available in your tenancy, please subscribe to one of them.


Some regions don't offer all the models. See the region for each pretrained model to find out which models are available in a region near you.
Expand All @@ -47,6 +47,16 @@ Some regions don't offer all the models. See the region for each pretrained mode
| UK South (London) | London | uk-london-1 | LHR |
| US Midwest (Chicago) | Chicago | us-chicago-1 | ORD |

```
There is this variable called llm_region :
variable "llm_region" {
type = string
default = "us-chicago-1"
}

It is set to default to us-chicago-1 ; you need to use any region available in your tenancy subscribed to one of the available LLMs regions listed above.
```



## <a name="deliverables"></a>Deliverables
Expand Down Expand Up @@ -358,7 +368,8 @@ The ADW subsystem / module is able to create ADW/ATP databases.

The RAG IN A BOX SETTINGS are:

* Parameters:
* Parameters:
* __llm_region__ - The region that you need to connect to your LLM. Some regions don't offer all the models. See the region for each pretrained model to find out which models are available in a region near you. It is set to default to us-chicago-1 ; you need to use any region available in your tenancy subscribed to one of the available LLMs regions listed : sa-saopaulo-1 , eu-frankfurt-1 , ap-osaka-1 , uk-london-1 , us-chicago-1
* __riab_user__ - The username inside the database where you will install the apex application
* __riab_password__ - The password for the user inside the database - The password must be between 12 and 30 characters long, and must contain at least 1 uppercase, 1 lowercase, and 1 numeric character. It cannot contain the double quote symbol (") or the username "admin", regardless of casing. The password is mandatory if source value is "BACKUP_FROM_ID", "BACKUP_FROM_TIMESTAMP", "DATABASE" or "NONE"
* __apex_workspace__ - The name of the apex workspace
Expand Down Expand Up @@ -444,7 +455,10 @@ variable "db_database_management_status" {

# The RAG IN A BOX SETTINGS are:


variable "llm_region" {
type = string
default = "us-chicago-1"
}

# The username inside the database where you will install the apex application
variable "riab_user" {
Expand Down
10 changes: 5 additions & 5 deletions cloud-foundation/solutions/RAG-in-a-Box-Easy/provisioners.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ resource "null_resource" "sqlcl-create-usr" {
echo 'Creating the APEX WORKSPACE and APEX USER running easyRAG-IN-A-BOX_APEX_ADMIN_v2.0.sql'
sql -cloudconfig wallet_${var.db_name}.zip admin/${var.db_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_APEX_ADMIN_v2.0.sql ${var.apex_workspace} ${var.riab_user} ${var.apex_user} ${var.apex_password} ${var.apex_password}

echo 'Start running easyRAG-IN-A-BOX_USER_v2.2.sql script'
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_USER_v2.2.sql
echo 'Start running easyRAG-IN-A-BOX_USER_v2.3.sql script'
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_USER_v2.3.sql

echo 'Start running easyRAG-IN-A-BOX_USER_CREDS_v1.1.sql script'
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_USER_CREDS_v1.1.sql ${var.apex_user} ${var.user_ocid} ${var.tenancy_ocid} "${local.final_bucket_url}" "${var.private_key}" ${var.fingerprint} ${var.compartment_id}
echo 'Start running easyRAG-IN-A-BOX_USER_CREDS_v1.2.sql script'
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_USER_CREDS_v1.2.sql ${var.apex_user} ${var.user_ocid} ${var.tenancy_ocid} "${local.final_bucket_url}" "${var.private_key}" ${var.fingerprint} ${var.compartment_id} ${var.llm_region}

echo 'Install the APEX APP in a box application running easyRAG-IN-A-BOX_APEX_USER_v2.0.sql'
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_APEX_USER_v2.0.sql ${var.apex_workspace} ${var.riab_user} ./scripts/easyRAG-IN-A-BOX_f103_v2.1.sql
sql -cloudconfig wallet_${var.db_name}.zip ${var.riab_user}/${var.riab_password}@'${local.conn_db}' @./scripts/easyRAG-IN-A-BOX_APEX_USER_v2.0.sql ${var.apex_workspace} ${var.riab_user} ./scripts/easyRAG-IN-A-BOX_f103_v2.2.sql

EOT
}
Expand Down
28 changes: 15 additions & 13 deletions cloud-foundation/solutions/RAG-in-a-Box-Easy/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ groupings:
- db_version
- db_size_in_tbs
- db_enable_auto_scaling
- db_compute_model
- db_compute_count
- db_workload
- db_data_safe_status
- db_operations_insights_status
- db_database_management_status
- title: "RAG IN A BOX SETTINGS"
variables:
- llm_region
- riab_user
- riab_password
- apex_workspace
Expand All @@ -52,6 +52,7 @@ groupings:
# - user_ocid
# - fingerprint
- private_key_path
- db_compute_model
# General Configuration Variables
variables:
display_name_prefix:
Expand Down Expand Up @@ -175,18 +176,6 @@ variables:
eq:
- db_is_free_tier
- false
db_compute_model:
title: "The compute model of the Autonomous Database ECPUs"
description: "The compute model of the Autonomous Database ECPUs"
type: enum
enum:
- "ECPU"
default: "ECPU"
required: true
visible:
eq:
- db_is_free_tier
- false
db_compute_count:
title: The number of ECPUs cores to be made available to the database
description: "The number of ECPU cores to enable. For ECPUs count needs to be minimum 2 and maximum 512 ECPUs"
Expand Down Expand Up @@ -237,6 +226,19 @@ variables:
required: true
visible: true
# RAG IN A BOX SETTINGS:
llm_region:
title: "Pick one of the listed regions that your tenancy it's subscribed to access the LLM"
description: "It is set to default to us-chicago-1 ; you need to use any region available in your tenancy subscribed to one of the available LLMs regions listed"
type: enum
enum:
- "us-chicago-1"
- "sa-saopaulo-1"
- "eu-frankfurt-1"
- "ap-osaka-1"
- "uk-london-1"
default: "us-chicago-1"
required: true
visible: true
riab_user:
title: "The username inside the database where you will install the apex application"
description: "Provide the username inside the database where you will install the apex application. Constraints: 12 alphanumeric characters only. No Spaces."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
-- "&5" - ${var.private_key}
-- "&6" - ${var.fingerprint}
-- "&7" - ${var.compartment_id}
-- "&8" - ${var.llm_region}
--
-- v1.0 iop initial release
-- v1.1 mac update docs
-- v1.2 mac added variable 8 (llm region)
--
----------------------------------------------------------------

----------------------------------------------------------------
-- AS DATABASE USER
----------------------------------------------------------------

-- Insert data into the q_logs table

INSERT INTO eriab_user_settings VALUES (
'&1',
'VECTOR',
Expand All @@ -39,7 +41,6 @@ INSERT INTO eriab_user_settings VALUES (
"refresh" : 1040
}'));

-- Insert credentials data into the setting table
INSERT INTO eriab_user_settings VALUES (
'&1',
'BUCKETCRED',
Expand All @@ -50,15 +51,15 @@ INSERT INTO eriab_user_settings VALUES (
"fingerprint" : "&6"
}'));

-- Insert credentials data into the setting table
INSERT INTO eriab_user_settings VALUES (
'&1',
'RAGCRED',
json('{ "user_ocid" : "&2",
"tenancy_ocid" : "&3",
"compartment_ocid" : "&7",
"private_key" : "&5",
"fingerprint" : "&6"
"fingerprint" : "&6",
"llm_region" : "&8"
}'));

-- exercise the setting table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-- v2.0 mac first production release
-- v2.1 mac swapped llama with cohere model for answer generation
-- v2.2 mac added eriab_util_timestamp_diff
-- v2.3 mac added support for llm region in profile creation statement
--
-- Parameters
--
Expand Down Expand Up @@ -82,7 +83,8 @@ INSERT INTO eriab_user_settings VALUES (
"tenancy_ocid" : "<<replace with your tenancy ocid>>",
"compartment_ocid" : "<<replace with your compartment ocid>>",
"private_key" : "<<replace with your private key>>",
"fingerprint" : "<<replace with your fingerprint>>"
"fingerprint" : "<<replace with your fingerprint>>",
"llm_region" : "<<replace with your llm region name>>"
}'));

-- exercise the setting table
Expand Down Expand Up @@ -158,6 +160,7 @@ is
cocid varchar2(256);
pkey varchar2(2000);
fprint varchar2(256);
llmreg varchar2(256);
jo json_object_t;
bo clob := ' ';
begin
Expand All @@ -174,8 +177,9 @@ begin
xtocid,
xcocid,
xpkey,
xfprint
into uocid,tocid,cocid,pkey,fprint
xfprint,
xllmreg
into uocid,tocid,cocid,pkey,fprint,llmreg
from json_table(
(select settings from eriab_user_settings
where riab_user = r_user
Expand All @@ -185,7 +189,8 @@ begin
xtocid varchar2(256) format json PATH '$.tenancy_ocid',
xcocid varchar2(256) format json PATH '$.compartment_ocid',
xpkey varchar2(2000) format json PATH '$.private_key',
xfprint varchar2(256) format json PATH '$.fingerprint'));
xfprint varchar2(256) format json PATH '$.fingerprint',
xllmreg varchar2(256) format json PATH '$.llm_region'));

-- credentials for GenAI OCI:
dbms_lob.append(bo, '{ "user_ocid" : ');
Expand Down Expand Up @@ -243,7 +248,8 @@ CREATE OR REPLACE PROCEDURE eriab_create_index (
rr number;
st number;
ml number;
bt varchar2(512);
bt varchar2(512);
llmreg varchar2(512);
BEGIN

-- Clean-up
Expand Down Expand Up @@ -281,6 +287,16 @@ BEGIN
), '$[*]' COLUMNS (
xbt varchar2(512) format json PATH '$.bucket_url'));


-- get llm region
select xllmreg into llmreg
from json_table(
(select settings from eriab_user_settings
where riab_user = r_user
and pref_type = 'RAGCRED'
), '$[*]' COLUMNS (
xllmreg varchar2(256) format json PATH '$.llm_region'));

-- Create an AI profile used for natural language queries
DBMS_CLOUD_AI.create_profile(
'ERIAB_PROFILE',
Expand All @@ -289,6 +305,7 @@ BEGIN
"vector_index_name": "ERIAB_VECTOR_INDEX",
"embedding_model": "cohere.embed-multilingual-v3.0",
"model": "cohere.command-r-plus-08-2024",
"region": '||llmreg||',
"oci_apiformat": "COHERE"
}');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ prompt APPLICATION 103 - eRAG-IN-A-BOX
-- Application Export:
-- Application: 103
-- Name: eRAG-IN-A-BOX
-- Date and Time: 15:36 Monday March 3, 2025
-- Date and Time: 12:07 Friday March 14, 2025
-- Exported By: ERIAB
-- Flashback: 0
-- Export Type: Application Export
-- Pages: 6
-- Items: 29
-- Items: 30
-- Processes: 8
-- Regions: 11
-- Buttons: 14
Expand Down Expand Up @@ -19235,7 +19235,7 @@ wwv_flow_imp_page.create_page(
);
wwv_flow_imp_page.create_page_button(
p_id=>wwv_flow_imp.id(16525671731483739)
,p_button_sequence=>110
,p_button_sequence=>120
,p_button_name=>'SaveCredentials'
,p_button_action=>'DEFINED_BY_DA'
,p_button_template_options=>'#DEFAULT#:t-Button--iconLeft'
Expand All @@ -19249,7 +19249,7 @@ wwv_flow_imp_page.create_page_button(
);
wwv_flow_imp_page.create_page_button(
p_id=>wwv_flow_imp.id(16525752246483740)
,p_button_sequence=>120
,p_button_sequence=>130
,p_button_name=>'ResetToDefault'
,p_button_action=>'DEFINED_BY_DA'
,p_button_template_options=>'#DEFAULT#:t-Button--iconLeft'
Expand All @@ -19264,6 +19264,21 @@ wwv_flow_imp_page.create_page_button(
,p_grid_new_row=>'N'
,p_grid_new_column=>'Y'
);
wwv_flow_imp_page.create_page_item(
p_id=>wwv_flow_imp.id(8174485639618834)
,p_name=>'P3_LLM_REGION'
,p_item_sequence=>110
,p_item_default=>'us-chicago-1'
,p_prompt=>'LLM Region Name'
,p_display_as=>'NATIVE_TEXT_FIELD'
,p_cSize=>30
,p_field_template=>wwv_flow_imp.id(31840446627957509)
,p_item_template_options=>'#DEFAULT#'
,p_attribute_01=>'N'
,p_attribute_02=>'N'
,p_attribute_04=>'TEXT'
,p_attribute_05=>'BOTH'
);
wwv_flow_imp_page.create_page_item(
p_id=>wwv_flow_imp.id(16525323425483736)
,p_name=>'P3_BUCKET_URL'
Expand Down Expand Up @@ -19470,8 +19485,9 @@ wwv_flow_imp_page.create_page_da_action(
' SUBSTR(xtocid, 2, LENGTH(xtocid) - 2),',
' SUBSTR(xcocid, 2, LENGTH(xcocid) - 2),',
' SUBSTR(xpkey, 2, LENGTH(xpkey) - 2),',
' SUBSTR(xfprint, 2, LENGTH(xfprint) - 2)',
' into :P3_LLM_USER_OCID,:P3_LLM_TENANCY_OCID,:P3_LLM_COMP_OCID,:P3_LLM_CERT,:P3_LLM_FINGERPRINT',
' SUBSTR(xfprint, 2, LENGTH(xfprint) - 2),',
' SUBSTR(xllmreg, 2, LENGTH(xllmreg) - 2)',
' into :P3_LLM_USER_OCID,:P3_LLM_TENANCY_OCID,:P3_LLM_COMP_OCID,:P3_LLM_CERT,:P3_LLM_FINGERPRINT,:P3_LLM_REGION',
' from json_table(',
' (select settings from eriab_user_settings',
' where riab_user = locusr',
Expand All @@ -19481,10 +19497,11 @@ wwv_flow_imp_page.create_page_da_action(
' xtocid varchar2(256) format json PATH ''$.tenancy_ocid'',',
' xcocid varchar2(256) format json PATH ''$.compartment_ocid'',',
' xpkey varchar2(2000) format json PATH ''$.private_key'',',
' xfprint varchar2(256) format json PATH ''$.fingerprint''));',
' xfprint varchar2(256) format json PATH ''$.fingerprint'',',
' xllmreg varchar2(256) format json PATH ''$.llm_region''));',
'',
'end;'))
,p_attribute_03=>'P3_BUCKET_USER_OCID,P3_BUCKET_TENANCY_OCID,P3_BUCKET_URL,P3_BUCKET_CERT,P3_BUCKET_FINGERPRINT,P3_LLM_USER_OCID,P3_LLM_TENANCY_OCID,P3_LLM_COMP_OCID,P3_LLM_CERT,P3_LLM_FINGERPRINT'
,p_attribute_03=>'P3_BUCKET_USER_OCID,P3_BUCKET_TENANCY_OCID,P3_BUCKET_URL,P3_BUCKET_CERT,P3_BUCKET_FINGERPRINT,P3_LLM_USER_OCID,P3_LLM_TENANCY_OCID,P3_LLM_COMP_OCID,P3_LLM_CERT,P3_LLM_FINGERPRINT,P3_LLM_REGION'
,p_attribute_04=>'N'
,p_attribute_05=>'PLSQL'
,p_wait_for_result=>'Y'
Expand Down Expand Up @@ -19534,7 +19551,8 @@ wwv_flow_imp_page.create_page_da_action(
' "tenancy_ocid" : "''||:P3_LLM_TENANCY_OCID||''",',
' "compartment_ocid" : "''||:P3_LLM_COMP_OCID||''",',
' "private_key" : "''||:P3_LLM_CERT||''",',
' "fingerprint" : "''||:P3_LLM_FINGERPRINT||''"',
' "fingerprint" : "''||:P3_LLM_FINGERPRINT||''",',
' "llm_region" : "''||:P3_LLM_REGION||''"',
' }''));',
' ',
' else',
Expand All @@ -19555,7 +19573,8 @@ wwv_flow_imp_page.create_page_da_action(
' "tenancy_ocid" : "''||:P3_LLM_TENANCY_OCID||''",',
' "compartment_ocid" : "''||:P3_LLM_COMP_OCID||''",',
' "private_key" : "''||:P3_LLM_CERT||''",',
' "fingerprint" : "''||:P3_LLM_FINGERPRINT||''"',
' "fingerprint" : "''||:P3_LLM_FINGERPRINT||''",',
' "llm_region" : "''||:P3_LLM_REGION||''"',
' }'')',
' where riab_user = :user',
' and pref_type = ''RAGCRED'';',
Expand All @@ -19566,7 +19585,7 @@ wwv_flow_imp_page.create_page_da_action(
' eriab_create_bucket_cred( :user );',
' eriab_create_llm_cred( :user );',
'end;'))
,p_attribute_02=>'P3_BUCKET_USER_OCID,P3_BUCKET_TENANCY_OCID,P3_BUCKET_URL,P3_BUCKET_CERT,P3_BUCKET_FINGERPRINT,P3_LLM_USER_OCID,P3_LLM_TENANCY_OCID,P3_LLM_COMP_OCID,P3_LLM_CERT,P3_LLM_FINGERPRINT'
,p_attribute_02=>'P3_BUCKET_USER_OCID,P3_BUCKET_TENANCY_OCID,P3_BUCKET_URL,P3_BUCKET_CERT,P3_BUCKET_FINGERPRINT,P3_LLM_USER_OCID,P3_LLM_TENANCY_OCID,P3_LLM_COMP_OCID,P3_LLM_CERT,P3_LLM_FINGERPRINT,P3_LLM_REGION'
,p_attribute_05=>'PLSQL'
,p_wait_for_result=>'Y'
);
Expand Down Expand Up @@ -19635,8 +19654,9 @@ wwv_flow_imp_page.create_page_process(
' SUBSTR(xtocid, 2, LENGTH(xtocid) - 2),',
' SUBSTR(xcocid, 2, LENGTH(xcocid) - 2),',
' SUBSTR(xpkey, 2, LENGTH(xpkey) - 2),',
' SUBSTR(xfprint, 2, LENGTH(xfprint) - 2)',
' into :P3_LLM_USER_OCID,:P3_LLM_TENANCY_OCID,:P3_LLM_COMP_OCID,:P3_LLM_CERT,:P3_LLM_FINGERPRINT',
' SUBSTR(xfprint, 2, LENGTH(xfprint) - 2),',
' SUBSTR(xllmreg, 2, LENGTH(xllmreg) - 2)',
' into :P3_LLM_USER_OCID,:P3_LLM_TENANCY_OCID,:P3_LLM_COMP_OCID,:P3_LLM_CERT,:P3_LLM_FINGERPRINT,:P3_LLM_REGION',
' from json_table(',
' (select settings from eriab_user_settings',
' where riab_user = locusr',
Expand All @@ -19646,7 +19666,8 @@ wwv_flow_imp_page.create_page_process(
' xtocid varchar2(256) format json PATH ''$.tenancy_ocid'',',
' xcocid varchar2(256) format json PATH ''$.compartment_ocid'',',
' xpkey varchar2(2000) format json PATH ''$.private_key'',',
' xfprint varchar2(256) format json PATH ''$.fingerprint''));',
' xfprint varchar2(256) format json PATH ''$.fingerprint'',',
' xllmreg varchar2(256) format json PATH ''$.llm_region''));',
'',
'end;'))
,p_process_clob_language=>'PLSQL'
Expand Down
Loading