forked from oracle-devrel/oracle-autonomous-database-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectAI4Py -0- Prerequisites and Setup.dsnb
More file actions
1313 lines (1313 loc) · 64.4 KB
/
SelectAI4Py -0- Prerequisites and Setup.dsnb
File metadata and controls
1313 lines (1313 loc) · 64.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"name" : "SelectAI4Py -0- Prerequisites and Setup",
"description" : null,
"tags" : null,
"version" : "7",
"layout" : "jupyter",
"type" : "low",
"snapshot" : false,
"isEditable" : true,
"isRunnable" : true,
"template" : null,
"templateConfig" : null,
"paragraphs" : [
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : null,
"hasTitle" : false,
"message" : [ ],
"selectedVisualization" : null,
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : true,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695117377,
"endTime" : 1764695118304,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [ ],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"# Oracle Select AI for Python: Setting up the environment",
"",
"This notebook prepares your Autonomous Database instance to use Oracle Select AI for Python.",
"",
"This setup must be completed before using NL2SQL, RAG, Synthetic Data Generation, and other Select AI features.",
"",
"#### What is Select AI?",
"",
"Select AI enables SQL, PL/SQL, and Python access to Large Language Models (LLMs) and transformers from a range of AI providers from your database. ",
"It supports SQL query generation from natural language prompts against your database data (NL2SQL), retrieval augmented generation (RAG), and synthetic data generation (SDG), among other features. ",
"",
"See this <a href=\"https://www.youtube.com/watch?v=rnsnIYYZzr4\" target=\"_blank\">video</a> for an introduction to Select AI.",
"",
"#### Setup Overview",
"",
"To configure Select AI, both the ADMIN and a non-ADMIN users are required. You will need to specify access credentials to the AI provider(s) you want to use and, for RAG, cloud storage. ",
"Note that you can also use private endpoints to host your LLMs. ",
"",
"**ADMIN Tasks:**",
"- Grant permissions to OML users",
"- Configure network access (if needed)",
"",
"**Select AI User Tasks:**",
"- Create cloud authentication credentials",
"- Create AI profiles",
"- Create vector indexes as needed in support of RAG",
"",
"",
"> **Note:** This notebook includes examples based on OCI Generative AI Service. However multiple other AI providers are supported. ",
"Users must have an account with a compatible AI provider API and provide access to Autonomous Database via database credentials.",
"Consult the <a href=\"https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/sql-generation-ai-autonomous.html\" target=\"_blank\">Select AI documentation</a> for details.",
"",
"Copyright (c) 2025 Oracle Corporation ",
"###### <a href=\"https://oss.oracle.com/licenses/upl/\" target=\"_blank\">The Universal Permissive License (UPL), Version 1.0</a>",
"---"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695124458,
"endTime" : 1764695124862,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h1 id=\"oracle-select-ai-for-python-setting-up-the-environment\">Oracle Select AI for Python: Setting up the environment</h1>\n<p>This notebook prepares your Autonomous Database instance to use Oracle Select AI for Python.</p>\n<p>This setup must be completed before using NL2SQL, RAG, Synthetic Data Generation, and other Select AI features.</p>\n<h4 id=\"what-is-select-ai\">What is Select AI?</h4>\n<p>Select AI enables SQL, PL/SQL, and Python access to Large Language Models (LLMs) and transformers from a range of AI providers from your database.\nIt supports SQL query generation from natural language prompts against your database data (NL2SQL), retrieval augmented generation (RAG), and synthetic data generation (SDG), among other features.</p>\n<p>See this <a href=\"https://www.youtube.com/watch?v=rnsnIYYZzr4\" target=\"_blank\">video</a> for an introduction to Select AI.</p>\n<h4 id=\"setup-overview\">Setup Overview</h4>\n<p>To configure Select AI, both the ADMIN and a non-ADMIN users are required. You will need to specify access credentials to the AI provider(s) you want to use and, for RAG, cloud storage.\nNote that you can also use private endpoints to host your LLMs.</p>\n<p><strong>ADMIN Tasks:</strong></p>\n<ul>\n<li>Grant permissions to OML users</li>\n<li>Configure network access (if needed)</li>\n</ul>\n<p><strong>Select AI User Tasks:</strong></p>\n<ul>\n<li>Create cloud authentication credentials</li>\n<li>Create AI profiles</li>\n<li>Create vector indexes as needed in support of RAG</li>\n</ul>\n<blockquote>\n<p><strong>Note:</strong> This notebook includes examples based on OCI Generative AI Service. However multiple other AI providers are supported.\nUsers must have an account with a compatible AI provider API and provide access to Autonomous Database via database credentials.\nConsult the <a href=\"https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/sql-generation-ai-autonomous.html\" target=\"_blank\">Select AI documentation</a> for details.</p>\n</blockquote>\n<p>Copyright (c) 2025 Oracle Corporation</p>\n<h6 id=\"the-universal-permissive-license-upl-version-10\"><a href=\"https://oss.oracle.com/licenses/upl/\" target=\"_blank\">The Universal Permissive License (UPL), Version 1.0</a></h6>\n<hr />\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"### For more information...",
"",
"<a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/index.html\" target=\"_blank\">Select AI for Python documentation</a>"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695131720,
"endTime" : 1764695132078,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"for-more-information\">For more information...</h3>\n<p><a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/pysai/index.html\" target=\"_blank\">Select AI for Python documentation</a></p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"### ADMIN: Grant 'EXECUTE' on DBMS_CLOUD packages",
"",
"The `ADMIN` user must grant execute privileges on `DBMS_CLOUD`, `DBMS_CLOUD_AI`, and `DBMS_CLOUD_PIPELINE` packages to the Select AI user. In SelectAI4Py, use ",
"`select_ai.enable_provider` to grant these privileges to a single user or list of users. Replace `SELECT_AI_USER` with your username.",
"",
"`select_ai.enable_provider` also enables users to invoke the AI (LLM) endpoint by adding them to the Access Control List (ACL).",
"",
"**Note:** This privilege is not required for OCI GenAI."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695136201,
"endTime" : 1764695136563,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"admin-grant-execute-on-dbms_cloud-packages\">ADMIN: Grant 'EXECUTE' on DBMS_CLOUD packages</h3>\n<p>The <code>ADMIN</code> user must grant execute privileges on <code>DBMS_CLOUD</code>, <code>DBMS_CLOUD_AI</code>, and <code>DBMS_CLOUD_PIPELINE</code> packages to the Select AI user. In SelectAI4Py, use\n<code>select_ai.enable_provider</code> to grant these privileges to a single user or list of users. Replace <code>SELECT_AI_USER</code> with your username.</p>\n<p><code>select_ai.enable_provider</code> also enables users to invoke the AI (LLM) endpoint by adding them to the Access Control List (ACL).</p>\n<p><strong>Note:</strong> This privilege is not required for OCI GenAI.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%python",
"",
"import select_ai",
"",
"# This grants EXECUTE on DBMS_CLOUD, DBMS_CLOUD_AI, and DBMS_CLOUD_PIPELINE",
"select_ai.enable_provider(users = [\"SELECT_AI_USER\"])"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : false,
"forms" : "[]",
"result" : {
"startTime" : 1759775045287,
"endTime" : 1759775048082,
"interpreter" : "python.low",
"taskStatus" : null,
"status" : null,
"results" : null,
"forms" : null
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"### Select AI User: Create cloud authentication credential",
"",
"The Select AI user must establish authentication credentials to their AI provider. Here, we are using Oracle Cloud Infrastructure (OCI) services. To enable",
"Select AI to use other AI providers, see <a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai-manage-profiles.html#GUID-0B631791-3627-4C2D-B527-396A55C72021\" target=\"_blank\" rel=\"noopener noreferrer\">the Select AI documentation</a>.",
"",
"The `select_ai.create_credential()` function securely stores your OCI identity information (user OCID, tenancy OCID, private key, and API key fingerprint). ",
"",
"The parameters include:",
"- `credential_name`: A unique identifier for this set of credentials (\"OCI_CRED2\" in this example)",
"- `user_ocid`: Your OCI user's unique identifier",
"- `tenancy_ocid`: Your OCI tenancy's unique identifier ",
"- `private_key`: Your RSA private key (in PEM format) that authenticates API requests",
"- `fingerprint`: The fingerprint of the public key uploaded to your OCI user account",
"",
"This credential can be referenced in subsequent operations that require OCI authentication, such as when accessing Cloud Object Storage buckets for data loading, ",
"external tables, or data movement operations. For Select AI, this enables secure access to your data stored in OCI Cloud Storage via a built-in automated pipeline.",
"",
"This is a standard pattern for setting up secure API access to Oracle Cloud services from within an Oracle Database. The credentials are stored securely within the ",
"database and can be managed using various `select_ai` functions.",
"",
">Note: Replace all placeholder values with your specific values."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695142093,
"endTime" : 1764695142455,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"select-ai-user-create-cloud-authentication-credential\">Select AI User: Create cloud authentication credential</h3>\n<p>The Select AI user must establish authentication credentials to their AI provider. Here, we are using Oracle Cloud Infrastructure (OCI) services. To enable\nSelect AI to use other AI providers, see <a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai-manage-profiles.html#GUID-0B631791-3627-4C2D-B527-396A55C72021\" target=\"_blank\" rel=\"noopener noreferrer\">the Select AI documentation</a>.</p>\n<p>The <code>select_ai.create_credential()</code> function securely stores your OCI identity information (user OCID, tenancy OCID, private key, and API key fingerprint).</p>\n<p>The parameters include:</p>\n<ul>\n<li><code>credential_name</code>: A unique identifier for this set of credentials ("OCI_CRED2" in this example)</li>\n<li><code>user_ocid</code>: Your OCI user's unique identifier</li>\n<li><code>tenancy_ocid</code>: Your OCI tenancy's unique identifier</li>\n<li><code>private_key</code>: Your RSA private key (in PEM format) that authenticates API requests</li>\n<li><code>fingerprint</code>: The fingerprint of the public key uploaded to your OCI user account</li>\n</ul>\n<p>This credential can be referenced in subsequent operations that require OCI authentication, such as when accessing Cloud Object Storage buckets for data loading,\nexternal tables, or data movement operations. For Select AI, this enables secure access to your data stored in OCI Cloud Storage via a built-in automated pipeline.</p>\n<p>This is a standard pattern for setting up secure API access to Oracle Cloud services from within an Oracle Database. The credentials are stored securely within the\ndatabase and can be managed using various <code>select_ai</code> functions.</p>\n<blockquote>\n<p>Note: Replace all placeholder values with your specific values.</p>\n</blockquote>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Create a cloud authentication credential for OCI GenAI Services - template example",
"hasTitle" : true,
"message" : [
"%python",
"",
"import select_ai",
"",
"credential = {",
" \"credential_name\": \"OCI_CRED2\",",
" \"user_ocid\": \"ocid1.user.oc1...\", # Replace with your user OCID",
" \"tenancy_ocid\": \"ocid1.tenancy.oc1...\", # Replace with your tenancy OCID",
" \"private_key\": \"MIIEogIBAAK...\", # Replace with your private key",
" \"fingerprint\": \"12:34:56:78:9a:bc:...\" # Replace with your fingerprint",
"}",
"",
"# Create the credential, replacing it if it exists",
"select_ai.create_credential(credential = credential, replace = True)"
],
"selectedVisualization" : null,
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : false,
"forms" : null,
"result" : null,
"relations" : [ ],
"dynamicFormParams" : null
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Verify the cloud credential is defined",
"hasTitle" : true,
"message" : [
"%sql",
"",
"SELECT OWNER, CREDENTIAL_NAME, ENABLED ",
"FROM ALL_CREDENTIALS ",
"WHERE CREDENTIAL_NAME = 'OCI_CRED2';"
],
"selectedVisualization" : "table",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695142868,
"endTime" : 1764695144742,
"interpreter" : "sql.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "OWNER\tCREDENTIAL_NAME\tENABLED\nSELECT_AI_USER\tOCI_CRED2\tTRUE\n",
"type" : "TABLE"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"### AI Profile Overview",
"",
"Users can create different profiles for various Select AI scenarios, such as using different credentials, AI providers, transformers, or configuration parameters.",
"",
"Here, we create three profile objects:",
"",
"1. **OCI_GENAI_PY_DEMO:** A primary profile for chat, NL2SQL, and SDG",
"2. **OCI_GENAI_RAG_PY_DEMO:** A profile for RAG ",
"3. **IN_DB_TRANSFORMER_RAG_DEMO:** A profile for RAG using an in-database transformer for embeddings",
"",
"These profile objects allow you to invoke Select AI operations using their specific configurations. You'll need to create a proxy object to leverage these profiles in the chat, NL2SQL, SDG, and RAG notebooks, as those will be separate database sessions.",
"",
"> Note: The annotations feature referenced in each profile requires Autonomous Database 23ai. Select AI RAG also requires 23ai."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695145160,
"endTime" : 1764695145690,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"ai-profile-overview\">AI Profile Overview</h3>\n<p>Users can create different profiles for various Select AI scenarios, such as using different credentials, AI providers, transformers, or configuration parameters.</p>\n<p>Here, we create three profile objects:</p>\n<ol>\n<li><strong>OCI_GENAI_PY_DEMO:</strong> A primary profile for chat, NL2SQL, and SDG</li>\n<li><strong>OCI_GENAI_RAG_PY_DEMO:</strong> A profile for RAG</li>\n<li><strong>IN_DB_TRANSFORMER_RAG_DEMO:</strong> A profile for RAG using an in-database transformer for embeddings</li>\n</ol>\n<p>These profile objects allow you to invoke Select AI operations using their specific configurations. You'll need to create a proxy object to leverage these profiles in the chat, NL2SQL, SDG, and RAG notebooks, as those will be separate database sessions.</p>\n<blockquote>\n<p>Note: The annotations feature referenced in each profile requires Autonomous Database 23ai. Select AI RAG also requires 23ai.</p>\n</blockquote>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"### Create an AI profile for chat, NL2SQL, and SDG",
"",
"We'll create an AI profile named `OCI_GENAI_PY_DEMO` to support chat interactions, querying the database using natural language, and generating synthetic data.",
"",
"This profile uses OCI Generative AI Service as the AI provider and the `meta.llama-3.1-70b-instruct` LLM.",
"",
"In this profile, we enable Select AI features including conversation support, comments, constraints, and annotations.",
"",
"The object_list in the profile can be specified to determine which database tables the AI features can access. It highlights the owner field (e.g., SH) to specify",
"the schema. You can optionally list individual tables, as shown here with `CUSTOMERS`, `SALES`, `PRODUCTS`, and `COUNTRIES`.",
"",
"With this profile, you'll be able to:",
"",
"* Run natural language queries like 'Show me the top 3 baby boomer big spending customers' and have it generate the corresponding SQL query (NL2SQL)",
"* Engage in interactive chat conversations with the LLM (Chat)",
"* Generate realistic synthetic data based on your existing table structures and data patterns (SDG)",
"",
"> Note, Select AI also enables automated selection of schema metadata for augmented NL2SQL prompts, supporting schemas with a large number of tables and views, ",
"simplifying AI profile specification, and can reduce the metadata volume sent to the LLM. Specify `\"object_list_mode\": \"automated\"` in the `DBMS_CLOUD_AI.CREATE_PROFILE` attributes list to enable this feature. See <a href=\"https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/select-ai-examples.html#GUID-F9C4BEFB-1570-430F-AB36-347F1A4B8A71\" target=\"_blank\" rel=\"noopener noreferrer\">\"Automatically Detect Relevant Table Metadata\" in Example: Improve SQL Query Generation for details</a>."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695146076,
"endTime" : 1764695146424,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"create-an-ai-profile-for-chat-nl2sql-and-sdg\">Create an AI profile for chat, NL2SQL, and SDG</h3>\n<p>We'll create an AI profile named <code>OCI_GENAI_PY_DEMO</code> to support chat interactions, querying the database using natural language, and generating synthetic data.</p>\n<p>This profile uses OCI Generative AI Service as the AI provider and the <code>meta.llama-3.1-70b-instruct</code> LLM.</p>\n<p>In this profile, we enable Select AI features including conversation support, comments, constraints, and annotations.</p>\n<p>The object_list in the profile can be specified to determine which database tables the AI features can access. It highlights the owner field (e.g., SH) to specify\nthe schema. You can optionally list individual tables, as shown here with <code>CUSTOMERS</code>, <code>SALES</code>, <code>PRODUCTS</code>, and <code>COUNTRIES</code>.</p>\n<p>With this profile, you'll be able to:</p>\n<ul>\n<li>Run natural language queries like 'Show me the top 3 baby boomer big spending customers' and have it generate the corresponding SQL query (NL2SQL)</li>\n<li>Engage in interactive chat conversations with the LLM (Chat)</li>\n<li>Generate realistic synthetic data based on your existing table structures and data patterns (SDG)</li>\n</ul>\n<blockquote>\n<p>Note, Select AI also enables automated selection of schema metadata for augmented NL2SQL prompts, supporting schemas with a large number of tables and views,\nsimplifying AI profile specification, and can reduce the metadata volume sent to the LLM. Specify <code>"object_list_mode": "automated"</code> in the <code>DBMS_CLOUD_AI.CREATE_PROFILE</code> attributes list to enable this feature. See <a href=\"https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/select-ai-examples.html#GUID-F9C4BEFB-1570-430F-AB36-347F1A4B8A71\" target=\"_blank\" rel=\"noopener noreferrer\">"Automatically Detect Relevant Table Metadata" in Example: Improve SQL Query Generation for details</a>.</p>\n</blockquote>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Select AI user: OCI_GENAI_PY_DEMO profile definition",
"hasTitle" : true,
"message" : [
"%python",
"",
"# OCI GenAI uses the default model if \"model\" is not set in attributes ",
"",
"import select_ai",
"",
"provider = select_ai.OCIGenAIProvider()",
"",
"profile_attributes = select_ai.ProfileAttributes(",
" provider = provider,",
" credential_name = \"OCI_CRED2\",",
" conversation = True,",
" comments = True,",
" constraints = True,",
" annotations = True,",
" object_list =[",
" {\"owner\": \"SH\", \"name\": \"CUSTOMERS\"},",
" {\"owner\": \"SH\", \"name\": \"SALES\"},",
" {\"owner\": \"SH\", \"name\": \"PRODUCTS\"},",
" {\"owner\": \"SH\", \"name\": \"COUNTRIES\"}",
" ])",
"",
"profile = select_ai.Profile(",
" profile_name = \"OCI_GENAI_PY_DEMO \",",
" attributes = profile_attributes,",
" description = \"Profile for chat, NL2SQL, and SDG\",",
" replace = True)",
"",
"print(profile.profile_name + \" profile has been successfully created\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695146805,
"endTime" : 1764695152220,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "OCI_GENAI_PY_DEMO profile has been successfully created\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"### Create an AI profile for RAG",
"",
"We'll create an AI profile named `OCI_GENAI_RAG_PY_DEMO` that also uses OCI Generative AI Service as the provider and the same LLM. ",
"But we also can specify the embedding model (or transformer) we want to use for generating vectors. ",
"",
"Additionally, we'll specify a vector index named `MY_VECTOR_INDEX2` to enable RAG. This profile will be used in the corresponding RAG notebook. ",
"",
">Note, we haven't created `MY_VECTOR_INDEX2` yet. That will be done in the notebook that covers RAG. ",
"",
"In this profile, we enable conversations and set it as the current profile after creation. ",
"",
"The RAG profile will allow you to ask questions about customer documentation in your vector store, such as 'What are our service level agreements for high-value customers ",
"in the Asia Pacific region?' and receive answers enhanced with information derived from your object storage documents."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695152601,
"endTime" : 1764695152943,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"create-an-ai-profile-for-rag\">Create an AI profile for RAG</h3>\n<p>We'll create an AI profile named <code>OCI_GENAI_RAG_PY_DEMO</code> that also uses OCI Generative AI Service as the provider and the same LLM.\nBut we also can specify the embedding model (or transformer) we want to use for generating vectors.</p>\n<p>Additionally, we'll specify a vector index named <code>MY_VECTOR_INDEX2</code> to enable RAG. This profile will be used in the corresponding RAG notebook.</p>\n<blockquote>\n<p>Note, we haven't created <code>MY_VECTOR_INDEX2</code> yet. That will be done in the notebook that covers RAG.</p>\n</blockquote>\n<p>In this profile, we enable conversations and set it as the current profile after creation.</p>\n<p>The RAG profile will allow you to ask questions about customer documentation in your vector store, such as 'What are our service level agreements for high-value customers\nin the Asia Pacific region?' and receive answers enhanced with information derived from your object storage documents.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Select AI user: OCI_GENAI_RAG_PY_DEMO profile definition",
"hasTitle" : true,
"message" : [
"%python",
"",
"provider = select_ai.OCIGenAIProvider(",
" model = \"meta.llama-4-maverick-17b-128e-instruct-fp8\",",
" embedding_model = \"cohere.embed-english-v3.0\")",
"",
"profile_attributes = select_ai.ProfileAttributes(",
" provider = provider,",
" credential_name = \"OCI_CRED2\",",
" vector_index_name = \"MY_VECTOR_INDEX2\",",
" enable_source_offsets = True,",
" conversation = True)",
"",
"profile = select_ai.Profile(",
" profile_name = \"OCI_GENAI_RAG_PY_DEMO\",",
" attributes = profile_attributes,",
" description = \"Supports RAG with semantic search to augment prompts using a vector store\",",
" replace = True)",
"",
"print(profile.profile_name + \" profile has been successfully created\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695153324,
"endTime" : 1764695154989,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "OCI_GENAI_RAG_PY_DEMO profile has been successfully created\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"#### Transformer model selection ",
"The `embedding_model` parameter allows you to choose between different text embedding models and deployment approaches. You can use third-party hosted transformer ",
"models from providers like OpenAI or Cohere, or use in-database transformers as described below.",
"",
"Oracle provides pre-built ONNX transformer models that have been augmented through a specialized pipeline to generate embeddings directly within the database. The following models are available for download.",
"<span style=\"color: #00008B;\">[Right-click link ? Save As to download]</span>:",
"",
"- <a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/qXfE9JKYR_w7UP-473agAv_c9b0rQC6vo8_K6bCsaBpSXO0CFzFp7HHx_H7P8HGf/n/adwc4pm/b/OML-ai-models/o/all_MiniLM_L12_v2.onnx\" target=\"_blank\">ALL_MINILM_L12_V2</a> (384 dimensions) - Optimized for English content. ",
"- <a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/k0BGCbupcnBQfLPWX5egR0M7fqKEE3jWqyRDio6Um_AU_N6BheP7yiQgn_0SfmfR/n/adwc4pm/b/OML-ai-models/o/multilingual_e5_small.onnx\" target=\"_blank\">MULTILINGUAL_E5_SMALL</a> (384 dimensions) - Supports 100+ languages. ",
"- <a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/VvKu-Ab2FxWRXrONLXwMclTw0iYAtsUJOVn_m4p1R8rNF4ea8o9ytSPMVf4r3Oid/n/adwc4pm/b/OML-ai-models/o/clip_vit_base_patch32_img.onnx\" target=\"_blank\">CLIP_VIT_BASE_PATCH32_IMG</a> (512 dimensions) - CLIP model for image embeddings. ",
"- <a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/YjeKIRvRbFsq6g5gWFlxazvUxbELCG161GFMEegfYRz7a3gHABeE5m6iQ3fChXYD/n/adwc4pm/b/OML-ai-models/o/clip_vit_base_patch32_txt.onnx\" target=\"_blank\">CLIP_VIT_BASE_PATCH32_TXT</a> (512 dimensions) - CLIP model for text embeddings. ",
"",
"Each model offers different capabilities and embedding dimensions. Third-party hosted models may provide specialized capabilities or larger embedding dimensions, while ",
"in-database models provide efficient embedding generation without external API calls. You can switch the active embedding model at any time by updating the profile with `profile.set_attribute()`, as demonstrated below in this section.",
"",
"In the following steps, we'll load these embedding models into the database. For additional information on these models, refer to these blogs:",
"",
"<a href=\"https://blogs.oracle.com/machinelearning/post/use-our-prebuilt-onnx-model-now-available-for-embedding-generation-in-oracle-database-23ai\" target=\"_blank\">Prebuilt ONNX Models for Embedding Generation</a>",
"<br>",
"<a href=\"https://blogs.oracle.com/machinelearning/post/enhance-your-semantic-similarity-search-with-multilingual-support\" target=\"_blank\">Multilingual Support for Semantic Similarity Search</a>"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695155380,
"endTime" : 1764695155724,
"interpreter" : "md.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h4 id=\"transformer-model-selection\">Transformer model selection</h4>\n<p>The <code>embedding_model</code> parameter allows you to choose between different text embedding models and deployment approaches. You can use third-party hosted transformer\nmodels from providers like OpenAI or Cohere, or use in-database transformers as described below.</p>\n<p>Oracle provides pre-built ONNX transformer models that have been augmented through a specialized pipeline to generate embeddings directly within the database. The following models are available for download.\n<span style=\"color: #00008B;\">[Right-click link ? Save As to download]</span>:</p>\n<ul>\n<li><a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/qXfE9JKYR_w7UP-473agAv_c9b0rQC6vo8_K6bCsaBpSXO0CFzFp7HHx_H7P8HGf/n/adwc4pm/b/OML-ai-models/o/all_MiniLM_L12_v2.onnx\" target=\"_blank\">ALL_MINILM_L12_V2</a> (384 dimensions) - Optimized for English content.</li>\n<li><a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/k0BGCbupcnBQfLPWX5egR0M7fqKEE3jWqyRDio6Um_AU_N6BheP7yiQgn_0SfmfR/n/adwc4pm/b/OML-ai-models/o/multilingual_e5_small.onnx\" target=\"_blank\">MULTILINGUAL_E5_SMALL</a> (384 dimensions) - Supports 100+ languages.</li>\n<li><a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/VvKu-Ab2FxWRXrONLXwMclTw0iYAtsUJOVn_m4p1R8rNF4ea8o9ytSPMVf4r3Oid/n/adwc4pm/b/OML-ai-models/o/clip_vit_base_patch32_img.onnx\" target=\"_blank\">CLIP_VIT_BASE_PATCH32_IMG</a> (512 dimensions) - CLIP model for image embeddings.</li>\n<li><a href=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/YjeKIRvRbFsq6g5gWFlxazvUxbELCG161GFMEegfYRz7a3gHABeE5m6iQ3fChXYD/n/adwc4pm/b/OML-ai-models/o/clip_vit_base_patch32_txt.onnx\" target=\"_blank\">CLIP_VIT_BASE_PATCH32_TXT</a> (512 dimensions) - CLIP model for text embeddings.</li>\n</ul>\n<p>Each model offers different capabilities and embedding dimensions. Third-party hosted models may provide specialized capabilities or larger embedding dimensions, while\nin-database models provide efficient embedding generation without external API calls. You can switch the active embedding model at any time by updating the profile with <code>profile.set_attribute()</code>, as demonstrated below in this section.</p>\n<p>In the following steps, we'll load these embedding models into the database. For additional information on these models, refer to these blogs:</p>\n<p><a href=\"https://blogs.oracle.com/machinelearning/post/use-our-prebuilt-onnx-model-now-available-for-embedding-generation-in-oracle-database-23ai\" target=\"_blank\">Prebuilt ONNX Models for Embedding Generation</a>\n<br>\n<a href=\"https://blogs.oracle.com/machinelearning/post/enhance-your-semantic-similarity-search-with-multilingual-support\" target=\"_blank\">Multilingual Support for Semantic Similarity Search</a></p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : "Load Hugging Face all-MiniLM-L12-v2 model",
"hasTitle" : true,
"message" : [
"%python",
"",
"import oml",
"cursor = oml.cursor()",
"",
"model_name = 'ALL_MINILM_L12_V2'",
"onnx_file = 'all_MiniLM_L12_v2.onnx'",
"location_uri = 'https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/qXfE9JKYR_w7UP-473agAv_c9b0rQC6vo8_K6bCsaBpSXO0CFzFp7HHx_H7P8HGf/n/adwc4pm/b/OML-ai-models/o/'",
"",
"cursor.execute(f\"\"\"",
"BEGIN",
" BEGIN ",
" DBMS_DATA_MINING.DROP_MODEL('{model_name}');",
" EXCEPTION WHEN OTHERS THEN NULL; ",
" END;",
" ",
" DBMS_CLOUD.GET_OBJECT(",
" credential_name => 'OCI_CRED2',",
" directory_name => 'DATA_PUMP_DIR',",
" object_uri => '{location_uri}{onnx_file}');",
" ",
" DBMS_VECTOR.LOAD_ONNX_MODEL(",
" directory => 'DATA_PUMP_DIR',",
" file_name => '{onnx_file}',",
" model_name => '{model_name}');",
"END;",
"\"\"\")",
"",
"print(model_name + \" model successfully loaded\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695156102,
"endTime" : 1764695170203,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "ALL_MINILM_L12_V2 model successfully loaded\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : "Load Hugging Face multilingual-e5-small model",
"hasTitle" : true,
"message" : [
"%python",
"",
"model_name = 'MULTILINGUAL_E5_SMALL'",
"onnx_file = 'multilingual_e5_small.onnx'",
"location_uri = 'https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/k0BGCbupcnBQfLPWX5egR0M7fqKEE3jWqyRDio6Um_AU_N6BheP7yiQgn_0SfmfR/n/adwc4pm/b/OML-ai-models/o/'",
"",
"cursor.execute(f\"\"\"",
"BEGIN",
" BEGIN ",
" DBMS_DATA_MINING.DROP_MODEL('{model_name}');",
" EXCEPTION WHEN OTHERS THEN NULL; ",
" END;",
" ",
" DBMS_CLOUD.GET_OBJECT(",
" credential_name => 'OCI_CRED2',",
" directory_name => 'DATA_PUMP_DIR',",
" object_uri => '{location_uri}{onnx_file}');",
" ",
" DBMS_VECTOR.LOAD_ONNX_MODEL(",
" directory => 'DATA_PUMP_DIR',",
" file_name => '{onnx_file}',",
" model_name => '{model_name}');",
"END;",
"\"\"\")",
"",
"print(model_name + \" model successfully loaded\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695170591,
"endTime" : 1764695183694,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "MULTILINGUAL_E5_SMALL model successfully loaded\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : "Load the Hugging Face CLIP ViT-B/32 text model",
"hasTitle" : true,
"message" : [
"%python",
"",
"model_name = 'CLIP_VIT_BASE_PATCH32_TXT'",
"onnx_file = 'clip_vit_base_patch32_txt.onnx'",
"location_uri = 'https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/YjeKIRvRbFsq6g5gWFlxazvUxbELCG161GFMEegfYRz7a3gHABeE5m6iQ3fChXYD/n/adwc4pm/b/OML-ai-models/o/'",
"",
"cursor.execute(f\"\"\"",
"BEGIN",
" BEGIN ",
" DBMS_DATA_MINING.DROP_MODEL('{model_name}');",
" EXCEPTION WHEN OTHERS THEN NULL; ",
" END;",
" ",
" DBMS_CLOUD.GET_OBJECT(",
" credential_name => NULL,",
" directory_name => 'DATA_PUMP_DIR',",
" object_uri => '{location_uri}{onnx_file}');",
" ",
" DBMS_VECTOR.LOAD_ONNX_MODEL(",
" directory => 'DATA_PUMP_DIR',",
" file_name => '{onnx_file}',",
" model_name => '{model_name}',",
" metadata => JSON('{{\"function\" : \"embedding\", \"embeddingOutput\" : \"embedding\", \"input\": {{\"input\": [\"DATA\"]}}}}'));",
"END;",
"\"\"\")",
"",
"print(model_name + \" model successfully loaded\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695184075,
"endTime" : 1764695206983,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "CLIP_VIT_BASE_PATCH32_TXT model successfully loaded\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : "Load the Hugging Face CLIP ViT-B/32 image model",
"hasTitle" : true,
"message" : [
"%python",
"",
"model_name = 'CLIP_VIT_BASE_PATCH32_IMG'",
"onnx_file = 'clip_vit_base_patch32_img.onnx'",
"location_uri = 'https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/VvKu-Ab2FxWRXrONLXwMclTw0iYAtsUJOVn_m4p1R8rNF4ea8o9ytSPMVf4r3Oid/n/adwc4pm/b/OML-ai-models/o/'",
"",
"cursor.execute(f\"\"\"",
"BEGIN",
" BEGIN ",
" DBMS_DATA_MINING.DROP_MODEL('{model_name}');",
" EXCEPTION WHEN OTHERS THEN NULL; ",
" END;",
" ",
" DBMS_CLOUD.GET_OBJECT(",
" credential_name => NULL,",
" directory_name => 'DATA_PUMP_DIR',",
" object_uri => '{location_uri}{onnx_file}');",
" ",
" DBMS_VECTOR.LOAD_ONNX_MODEL(",
" directory => 'DATA_PUMP_DIR',",
" file_name => '{onnx_file}',",
" model_name => '{model_name}',",
" metadata => JSON('{{\"function\" : \"embedding\", \"embeddingOutput\" : \"embedding\", \"input\": {{\"input\": [\"DATA\"]}}}}'));",
"END;",
"\"\"\")",
"",
"print(model_name + \" model successfully loaded\")"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695207776,
"endTime" : 1764695238952,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "CLIP_VIT_BASE_PATCH32_IMG model successfully loaded\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : "List imported transformer models available for use with in-database ONNX Runtime",
"hasTitle" : true,
"message" : [
"%python",
"",
"df = oml.sync(query = \"\"\"",
" SELECT MODEL_NAME",
" FROM user_mining_models",
" WHERE mining_function = 'EMBEDDING'\"\"\")",
"",
"print(df)"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1764695239341,
"endTime" : 1764695239749,
"interpreter" : "python.low",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : " MODEL_NAME\n0 CLIP_VIT_BASE_PATCH32_IMG\n1 CLIP_VIT_BASE_PATCH32_TXT\n2 ALL_MINILM_L12_V2\n3 MULTILINGUAL_E5_SMALL\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Select AI user: IN_DB_TRANSFORMER_RAG_DEMO profile definition",
"hasTitle" : true,
"message" : [
"%python",
"",
"provider = select_ai.OCIGenAIProvider(",
" embedding_model = \"database:MULTILINGUAL_E5_SMALL\")",