Skip to content

Commit 0179353

Browse files
committed
change code block to file link
1 parent f558432 commit 0179353

File tree

1 file changed

+2
-64
lines changed

1 file changed

+2
-64
lines changed

building-intelligent-applications/README.md

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ We would like to execute the code **When Button is Pressed** , select the button
128128

129129
[12]: images/1706371121253.png
130130

131-
Copy paste this PL/SQL code block, you can also download it from [my GitHub repo][13] , replace your compartment id, credential name and page numbers in input and output APEX page items. [API Guide][14]
131+
Download the [genai_plsql.sql](genai_plsql.sql), replace your compartment id, credential name and page numbers in input and output APEX page items. [API Guide.][14]
132132

133133

134134
[13]: https://github.com/madhusudhanrao-ppm/code-assets/blob/main/AI-for-Financial-Services/genai_plsql.sql
@@ -141,69 +141,7 @@ Copy paste this PL/SQL code block, you can also download it from [my GitHub repo
141141

142142
[15]: https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/
143143

144-
-- PL/SQL code block to Generate AI Text from Oracle Generative AI service
145-
-- Author: Madhusudhan Rao
146-
-- Replace Compartment OCID, Web credentials and page number for APEX page items P91_AI_INPUT, P91_AI_OUTPUT
147-
----------------------
148-
149-
DECLARE
150-
151-
l_genai_rest_url VARCHAR2(4000) := 'https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/generateText';
152-
153-
l_web_cred CONSTANT VARCHAR2(50) := '<Your_Web_Credentials>';
154-
l_input varchar2(4000) := :P91_AI_INPUT;
155-
l_response_json CLOB;
156-
l_text varchar2(4000);
157-
158-
-- Request payload JSON
159-
l_ocigabody varchar2(1000) := '{
160-
"inferenceRequest": {
161-
"runtimeType": "COHERE",
162-
"prompt": "'||l_input||'",
163-
"maxTokens": 500,
164-
"numGenerations": 1,
165-
"returnLikelihoods": "GENERATION",
166-
"isStream": false
167-
},
168-
"servingMode": {
169-
"servingType": "ON_DEMAND",
170-
"modelId": "cohere.command-light"
171-
},
172-
"compartmentId": "<Your-Compartment-OCID>"
173-
}';
174-
175-
-- Cursor for Response Payload
176-
CURSOR C1 IS
177-
SELECT jt.*
178-
FROM JSON_TABLE(l_response_json, '$'
179-
COLUMNS (text VARCHAR2(4000) PATH '$.inferenceResponse[0].generatedTexts[0].text' )) jt;
180-
181-
BEGIN
182-
183-
if l_input is not null then
184-
185-
apex_web_service.g_request_headers.DELETE;
186-
apex_web_service.g_request_headers(1).name := 'Content-Type';
187-
apex_web_service.g_request_headers(1).value := 'application/json';
188-
189-
l_response_json := apex_web_service.make_rest_request
190-
(p_url => l_genai_rest_url,
191-
p_http_method => 'POST',
192-
p_body => l_ocigabody,
193-
p_credential_static_id => l_web_cred);
194-
195-
For row_1 In C1 Loop
196-
l_text := row_1.text;
197-
-- Display AI Response
198-
:P91_AI_OUTPUT := l_text;
199-
End Loop;
200-
201-
end if;
202-
203-
END;
204-
205-
206-
Few request parameters: [(reference)][16]
144+
A few request parameters: [(reference)][16]
207145

208146
[16]: https://docs.oracle.com/en-us/iaas/Content/generative-ai/concepts.htm
209147

0 commit comments

Comments
 (0)