-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathSelectAI4SQL - AI Agents - Sales Return Agent.dsnb
More file actions
4158 lines (4158 loc) · 174 KB
/
Copy pathSelectAI4SQL - AI Agents - Sales Return Agent.dsnb
File metadata and controls
4158 lines (4158 loc) · 174 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" : "SelectAI4SQL - AI Agents - Sales Return Agent",
"description" : null,
"tags" : null,
"version" : "7",
"layout" : "zeppelin",
"type" : "medium",
"snapshot" : false,
"isEditable" : true,
"isRunnable" : true,
"template" : "dsrgmn3y",
"templateConfig" : "{\"visualization\":{\"filters\":[{\"_id\":1583324064459,\"type\":\"styling\",\"enabled\":true,\"conditions\":{\"operator\":\"and\",\"conditions\":[{\"property\":\"hiddenConnection\",\"operator\":\"*\",\"value\":\"\"}]},\"component\":\"edge\",\"target\":\"edge\",\"properties\":{\"colors\":[\"rgba(0, 0, 0, 0.1)\"],\"style\":[\"dashed\"],\"legendTitle\":[\"Hidden Connection\"]}},{\"_id\":1590499315755,\"type\":\"aggregation\",\"enabled\":true,\"conditions\":{\"operator\":\"and\",\"conditions\":[]},\"component\":\"vertex\",\"target\":\"vertex\",\"properties\":{},\"aggregation\":[{\"source\":\"\",\"type\":\"average\"}]}],\"version\":4}}",
"paragraphs" : [
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [ ],
"selectedVisualization" : null,
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : true,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340024708,
"endTime" : 1777340025002,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [ ],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md\r",
"\r",
"# Build agentic solutions using Select AI - Sales Return Agent\r",
"\r",
"Select AI Agent provides a simple, automated framework to build, deploy, and manage AI agents. Users access the functionality via the package DBMS_CLOUD_AI_AGENT. \r",
"Select AI Agent provides the *ReAct* agentic pattern as a built-in feature but accommodates multiple agentic patterns - including prompt chaining, \r",
"routing, orchestrator-workers, and evaluator-optimizer.\r",
"\r",
"In this notebook, you will create a simple sales return agent that interacts with the customer to process a product return request. \r",
"The agent asks the reason for the return and handle the return accordingly. \r",
"\r",
"#### What is an AI agent?\r",
"\r",
"An AI agent is a software program or system designed to interact with its environment, collect and use data, formulate next actions, \r",
"and autonomously perform tasks to achieve specific goals.\r",
"\r",
"While generative AI supports creating content (as the case with LLMs), \r",
"agentic AI enables performing actions and making decisions to achieve specific goals, \r",
"potentially with no or minimal human intervention. \r",
"\r",
"#### Select AI Agent concepts\r",
"\r",
" * Agent Team - the set of agents and tasks that form an agentic flow\r",
" * Agent - an actor in an agent team with a defined role that can perform one or more tasks using a specified AI profile\r",
" * Task - an activity performed by a actor with a set of instructions and one or more tools to carry out the activity\r",
" * Tool - used to affect changes or access content in support of tasks and consist of instructions (what the tool does), a tool type, and tool parameters\r",
"\r",
"#### ReAct agentic pattern\r",
"\r",
"ReAct = Reasoning + Acting - allowing your LLM to “think” before it “acts”\r",
"\r",
"Supports a wide range of agentic use cases \r",
"* Reasoning - chain-of-thought on needed tasks\r",
"* Tool use - elect and invoke tools to affect environment\r",
"* Evaluation/reflection - loop until outcome is satisfactory\r",
"\r",
"Enable Select AI Agent by granting the following privileges to your user. Administrator privileges required to perform these operations:\r",
"* `grant execute on DBMS_CLOUD_AI to <username>;`\r",
"* `grant execute on DBMS_CLOUD_AI_AGENT to <username>;`\r",
"\r",
"---\r",
"Copyright (c) 2026 Oracle Corporation \r",
"###### [The Universal Permissive License (UPL), Version 1.0](https://oss.oracle.com/licenses/upl/)"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340025317,
"endTime" : 1777340025615,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h1 id=\"build-agentic-solutions-using-select-ai---sales-return-agent\">Build agentic solutions using Select AI - Sales Return Agent</h1>\n<p>Select AI Agent provides a simple, automated framework to build, deploy, and manage AI agents. Users access the functionality via the package DBMS_CLOUD_AI_AGENT.\nSelect AI Agent provides the <em>ReAct</em> agentic pattern as a built-in feature but accommodates multiple agentic patterns - including prompt chaining,\nrouting, orchestrator-workers, and evaluator-optimizer.</p>\n<p>In this notebook, you will create a simple sales return agent that interacts with the customer to process a product return request.\nThe agent asks the reason for the return and handle the return accordingly.</p>\n<h4 id=\"what-is-an-ai-agent\">What is an AI agent?</h4>\n<p>An AI agent is a software program or system designed to interact with its environment, collect and use data, formulate next actions,\nand autonomously perform tasks to achieve specific goals.</p>\n<p>While generative AI supports creating content (as the case with LLMs),\nagentic AI enables performing actions and making decisions to achieve specific goals,\npotentially with no or minimal human intervention.</p>\n<h4 id=\"select-ai-agent-concepts\">Select AI Agent concepts</h4>\n<ul>\n<li>Agent Team - the set of agents and tasks that form an agentic flow</li>\n<li>Agent - an actor in an agent team with a defined role that can perform one or more tasks using a specified AI profile</li>\n<li>Task - an activity performed by a actor with a set of instructions and one or more tools to carry out the activity</li>\n<li>Tool - used to affect changes or access content in support of tasks and consist of instructions (what the tool does), a tool type, and tool parameters</li>\n</ul>\n<h4 id=\"react-agentic-pattern\">ReAct agentic pattern</h4>\n<p>ReAct = Reasoning + Acting - allowing your LLM to “think” before it “acts”</p>\n<p>Supports a wide range of agentic use cases</p>\n<ul>\n<li>Reasoning - chain-of-thought on needed tasks</li>\n<li>Tool use - elect and invoke tools to affect environment</li>\n<li>Evaluation/reflection - loop until outcome is satisfactory</li>\n</ul>\n<p>Enable Select AI Agent by granting the following privileges to your user. Administrator privileges required to perform these operations:</p>\n<ul>\n<li><code>grant execute on DBMS_CLOUD_AI to <username>;</code></li>\n<li><code>grant execute on DBMS_CLOUD_AI_AGENT to <username>;</code></li>\n</ul>\n<hr />\n<p>Copyright (c) 2026 Oracle Corporation</p>\n<h6 id=\"the-universal-permissive-license-upl-version-10\"><a href=\"https://oss.oracle.com/licenses/upl/\">The Universal Permissive License (UPL), Version 1.0</a></h6>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "For more information...",
"hasTitle" : true,
"message" : [
"%md",
"",
"* <a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai.html\" target=\"_blank\" rel=\"noopener noreferrer\">Oracle Select AI documentation</a>",
"* <a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/dbms-cloud-ai-package.html\" target=\"_blank\" rel=\"noopener noreferrer\">DBMS_CLOUD_AI Package documentation</a>"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340025919,
"endTime" : 1777340026214,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<ul>\n<li><a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai.html\" target=\"_blank\" rel=\"noopener noreferrer\">Oracle Select AI documentation</a></li>\n<li><a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/dbms-cloud-ai-package.html\" target=\"_blank\" rel=\"noopener noreferrer\">DBMS_CLOUD_AI Package documentation</a></li>\n</ul>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 5,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"## Develop a sales return agent",
"",
"If you've ordered a product online, you likely at some point also had to return an item whether the product arrived broken or you no longer needed the item. ",
"This \"sales return agent\" scenario uses your database and LLM to interact with the user to handle product returns. This agent will inquire as to why the",
"item is being returned and perform some backend processing (update a database record) to indicate the status change. As an additional capability, the ",
"agent can also generate an email that could be sent to the customer. ",
"",
"You will be constructing the agentic solution as depicted here, starting with function and tool definition,",
"then task, agent, and agent team. Note that the agent specifies your AI profile, which identifies the LLM to use. ",
"",
"There are two phases to this solution. First, a basic definition that interacts with the customer and updates the database table.",
"Second, make the agent more personable and generate an email that could be sent to the customer confirming the action. "
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340026518,
"endTime" : 1777340026796,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h2 id=\"develop-a-sales-return-agent\">Develop a sales return agent</h2>\n<p>If you've ordered a product online, you likely at some point also had to return an item whether the product arrived broken or you no longer needed the item.\nThis "sales return agent" scenario uses your database and LLM to interact with the user to handle product returns. This agent will inquire as to why the\nitem is being returned and perform some backend processing (update a database record) to indicate the status change. As an additional capability, the\nagent can also generate an email that could be sent to the customer.</p>\n<p>You will be constructing the agentic solution as depicted here, starting with function and tool definition,\nthen task, agent, and agent team. Note that the agent specifies your AI profile, which identifies the LLM to use.</p>\n<p>There are two phases to this solution. First, a basic definition that interacts with the customer and updates the database table.\nSecond, make the agent more personable and generate an email that could be sent to the customer confirming the action.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 7,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
""
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340027104,
"endTime" : 1777340027383,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<p><img src=\"https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/vXNl6D1Ixp4e5cz-YD_Q-h9yjtzrMAzgXfmR39QYSYb5EPrjju803L5sXqj40oZn/n/adwc4pm/b/select-ai-notebook-content/o/Select-AI-Agent-Sales-Return-Agent.png\" alt=\"tiny arrow\" title=\"tiny arrow\" /></p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"# Phase 1: Create a sales return agent"
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340027687,
"endTime" : 1777340027966,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h1 id=\"phase-1-create-a-sales-return-agent\">Phase 1: Create a sales return agent</h1>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"### Create scenario data tables",
"",
"First, for our scenario, we'll create minimal `customers` and `customer_order_status` tables. "
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340028270,
"endTime" : 1777340028565,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"create-scenario-data-tables\">Create scenario data tables</h3>\n<p>First, for our scenario, we'll create minimal <code>customers</code> and <code>customer_order_status</code> tables.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Define a Customer table",
"hasTitle" : true,
"message" : [
"%script",
"",
"BEGIN EXECUTE IMMEDIATE 'DROP TABLE customers';",
"EXCEPTION WHEN OTHERS THEN NULL; END;",
"/",
"CREATE TABLE customers (",
" customer_id NUMBER(10) PRIMARY KEY,",
" name VARCHAR2(100),",
" email VARCHAR2(100),",
" phone VARCHAR2(20),",
" state VARCHAR2(2),",
" zip VARCHAR2(10)",
");",
"",
"INSERT INTO customers (customer_id, name, email, phone, state, zip) VALUES",
"(1, 'Alice Thompson', 'alice.thompson@example.com', '555-1234', 'NY', '10001'),",
"(2, 'Bob Martinez', 'bob.martinez@example.com', '555-2345', 'CA', '94105'),",
"(3, 'Carol Chen', 'carol.chen@example.com', '555-3456', 'TX', '73301'),",
"(4, 'David Johnson', 'david.johnson@example.com', '555-4567', 'IL', '60601'),",
"(5, 'Eva Green', 'eva.green@example.com', '555-5678', 'FL', '33101');"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340028867,
"endTime" : 1777340029596,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "\nPL/SQL procedure successfully completed.\n\n\n---------------------------\n\nTable CUSTOMERS created.\n\n\n---------------------------\n\n5 rows inserted.\n\n\n---------------------------\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "View customers table content",
"hasTitle" : true,
"message" : [
"%sql",
"",
"select * from customers;"
],
"selectedVisualization" : "table",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340029898,
"endTime" : 1777340030241,
"interpreter" : "sql.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "CUSTOMER_ID\tNAME\tEMAIL\tPHONE\tSTATE\tZIP\n1\tAlice Thompson\talice.thompson@example.com\t555-1234\tNY\t10001\n2\tBob Martinez\tbob.martinez@example.com\t555-2345\tCA\t94105\n3\tCarol Chen\tcarol.chen@example.com\t555-3456\tTX\t73301\n4\tDavid Johnson\tdavid.johnson@example.com\t555-4567\tIL\t60601\n5\tEva Green\teva.green@example.com\t555-5678\tFL\t33101\n",
"type" : "TABLE"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Define table Customer Order Return Status",
"hasTitle" : true,
"message" : [
"%script",
"",
"BEGIN EXECUTE IMMEDIATE 'DROP TABLE customer_order_status';",
"EXCEPTION WHEN OTHERS THEN NULL; END;",
"/",
"CREATE TABLE customer_order_status (",
" customer_id NUMBER(10),",
" order_number VARCHAR2(20),",
" status VARCHAR2(30),",
" product_name VARCHAR2(100)",
"",
");",
"",
"INSERT INTO customer_order_status (customer_id, order_number, status, product_name) VALUES",
"(2, '7734', 'delivered', 'smartphone charging cord'),",
"(1, '4381', 'pending_delivery', 'smartphone protective case'),",
"(2, '7820', 'delivered', 'smartphone charging cord'),",
"(3, '1293', 'pending_return', 'smartphone stand (metal)'),",
"(4, '9842', 'returned', 'smartphone backup storage'),",
"(5, '5019', 'delivered', 'smartphone protective case'),",
"(2, '6674', 'pending_delivery', 'smartphone charging cord'),",
"(1, '3087', 'returned', 'smartphone stand (metal)'),",
"(3, '7635', 'pending_return', 'smartphone backup storage'),",
"(4, '3928', 'delivered', 'smartphone protective case'),",
"(5, '8421', 'pending_delivery', 'smartphone charging cord'),",
"(1, '2204', 'returned', 'smartphone stand (metal)'),",
"(2, '7031', 'pending_delivery', 'smartphone backup storage'),",
"(3, '1649', 'delivered', 'smartphone protective case'),",
"(4, '9732', 'pending_return', 'smartphone charging cord'),",
"(5, '4550', 'delivered', 'smartphone stand (metal)'),",
"(1, '6468', 'pending_delivery', 'smartphone backup storage'),",
"(2, '3910', 'returned', 'smartphone protective case'),",
"(3, '2187', 'delivered', 'smartphone charging cord'),",
"(4, '8023', 'pending_return', 'smartphone stand (metal)'),",
"(5, '5176', 'delivered', 'smartphone backup storage');"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340030546,
"endTime" : 1777340031036,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "\nPL/SQL procedure successfully completed.\n\n\n---------------------------\n\nTable CUSTOMER_ORDER_STATUS created.\n\n\n---------------------------\n\n21 rows inserted.\n\n\n---------------------------\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "View customer_order_status table content",
"hasTitle" : true,
"message" : [
"%sql",
"",
"select * from customer_order_status;"
],
"selectedVisualization" : "table",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340031345,
"endTime" : 1777340031669,
"interpreter" : "sql.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "CUSTOMER_ID\tORDER_NUMBER\tSTATUS\tPRODUCT_NAME\n2\t7734\tdelivered\tsmartphone charging cord\n1\t4381\tpending_delivery\tsmartphone protective case\n2\t7820\tdelivered\tsmartphone charging cord\n3\t1293\tpending_return\tsmartphone stand (metal)\n4\t9842\treturned\tsmartphone backup storage\n5\t5019\tdelivered\tsmartphone protective case\n2\t6674\tpending_delivery\tsmartphone charging cord\n1\t3087\treturned\tsmartphone stand (metal)\n3\t7635\tpending_return\tsmartphone backup storage\n4\t3928\tdelivered\tsmartphone protective case\n5\t8421\tpending_delivery\tsmartphone charging cord\n1\t2204\treturned\tsmartphone stand (metal)\n2\t7031\tpending_delivery\tsmartphone backup storage\n3\t1649\tdelivered\tsmartphone protective case\n4\t9732\tpending_return\tsmartphone charging cord\n5\t4550\tdelivered\tsmartphone stand (metal)\n1\t6468\tpending_delivery\tsmartphone backup storage\n2\t3910\treturned\tsmartphone protective case\n3\t2187\tdelivered\tsmartphone charging cord\n4\t8023\tpending_return\tsmartphone stand (metal)\n5\t5176\tdelivered\tsmartphone backup storage\n",
"type" : "TABLE"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Define a PL/SQL function called update_customer_order_status",
"hasTitle" : true,
"message" : [
"%script",
"",
"CREATE OR REPLACE FUNCTION update_customer_order_status (",
" p_customer_name IN VARCHAR2,",
" p_order_number IN VARCHAR2,",
" p_status IN VARCHAR2",
") RETURN CLOB IS",
" v_customer_id customers.customer_id%TYPE;",
" v_row_count NUMBER;",
"BEGIN",
" -- Find customer_id from customer_name",
" SELECT customer_id",
" INTO v_customer_id",
" FROM customers",
" WHERE name = p_customer_name;",
" ",
" UPDATE customer_order_status",
" SET status = p_status",
" WHERE customer_id = v_customer_id",
" AND order_number = p_order_number;",
"",
" v_row_count := SQL%ROWCOUNT;",
"",
" IF v_row_count = 0 THEN",
" RETURN 'No matching record found to update.';",
" ELSE",
" RETURN 'Update successful.';",
" END IF;",
"EXCEPTION",
" WHEN OTHERS THEN",
" RETURN 'Error: ' || SQLERRM;",
"END;"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340032054,
"endTime" : 1777340032429,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "\nFunction UPDATE_CUSTOMER_ORDER_STATUS compiled\n\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Test the function update_customer_order_status",
"hasTitle" : true,
"message" : [
"%script",
"",
"DECLARE",
" v_result CLOB;",
"BEGIN",
" v_result := update_customer_order_status('David Johnson', '3928', 'pending_return');",
"",
" DBMS_OUTPUT.PUT_LINE(v_result);",
"END;"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340032734,
"endTime" : 1777340033142,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "Update successful.\n\n\nPL/SQL procedure successfully completed.\n\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "View customer_order_status table",
"hasTitle" : true,
"message" : [
"%sql",
"",
"select * from customer_order_status",
"where order_number = 3928"
],
"selectedVisualization" : "table",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340033446,
"endTime" : 1777340033764,
"interpreter" : "sql.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "CUSTOMER_ID\tORDER_NUMBER\tSTATUS\tPRODUCT_NAME\n4\t3928\tpending_return\tsmartphone protective case\n",
"type" : "TABLE"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 0,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"### Create a tool for database update",
"",
"Tools are what allow agents to perform tasks in the \"real\" world. One of these tools is for updating the table with customer order status. "
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777341766063,
"endTime" : 1777341766352,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"create-a-tool-for-database-update\">Create a tool for database update</h3>\n<p>Tools are what allow agents to perform tasks in the "real" world. One of these tools is for updating the table with customer order status.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Define Update_Order_Status_Tool",
"hasTitle" : true,
"message" : [
"%script",
"",
"BEGIN DBMS_CLOUD_AI_AGENT.drop_tool('Update_Order_Status_Tool');",
"EXCEPTION WHEN OTHERS THEN NULL; END;",
"/",
" BEGIN",
" DBMS_CLOUD_AI_AGENT.CREATE_TOOL(",
" tool_name => 'Update_Order_Status_Tool',",
" attributes => '{\"instruction\": \"This tool updates the database to reflect return status change. Always confirm user name and order number with user before update status\",",
" \"function\" : \"update_customer_order_status\"}',",
" description => 'Tool for updating customer order status in database table.'",
" );",
"END;"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340034654,
"endTime" : 1777340035374,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "\nPL/SQL procedure successfully completed.\n\n\n---------------------------\n\nPL/SQL procedure successfully completed.\n\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "View tools listing",
"hasTitle" : true,
"message" : [
"%sql",
"",
"select * from USER_AI_AGENT_TOOLS ",
"order by created desc"
],
"selectedVisualization" : "table",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340035675,
"endTime" : 1777340036020,
"interpreter" : "sql.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "TOOL_ID\tTOOL_NAME\tSTATUS\tDESCRIPTION\tCREATED\tLAST_MODIFIED\tORACLE_MAINTAINED\n1\tUPDATE_ORDER_STATUS_TOOL\tENABLED\tTool for updating customer order status in database table.\t2026-04-28 01:33:55.037078 UTC\t2026-04-28 01:33:55.037078 UTC\tN\n",
"type" : "TABLE"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"### Define the task to handle the product return",
"",
"We use a task to specify the instructions for performing actions using tools. Here, we create the `Handle_Product_Return_Task` and describe the interaction with the customer and how to respond in various cases. ",
"",
"This will use the Update_Order_Status_Tool and the implicit HUMAN_TOOL."
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340036327,
"endTime" : 1777340036606,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"define-the-task-to-handle-the-product-return\">Define the task to handle the product return</h3>\n<p>We use a task to specify the instructions for performing actions using tools. Here, we create the <code>Handle_Product_Return_Task</code> and describe the interaction with the customer and how to respond in various cases.</p>\n<p>This will use the Update_Order_Status_Tool and the implicit HUMAN_TOOL.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Define the Handle_Product_Return_Task",
"hasTitle" : true,
"message" : [
"%script",
"",
"BEGIN DBMS_CLOUD_AI_AGENT.drop_task('Handle_Product_Return_Task');",
"EXCEPTION WHEN OTHERS THEN NULL; END;",
"/",
"BEGIN",
" DBMS_CLOUD_AI_AGENT.create_task(",
" task_name => 'Handle_Product_Return_Task',",
" attributes => '{\"instruction\": \"Process a product return request from a customer:{query}' || ",
" '1. Ask customer the order reason for return (no longer needed, arrived too late, box broken, or defective)' || ",
" '2. If no longer needed:' ||",
" ' a. Inform customer to ship the product at their expense back to us.' ||",
" ' b. Update the order status to return_shipment_pending using Update_Order_Status_Tool.' ||",
" '3. If it arrived too late:' ||",
" ' a. Ask customer if they want a refund.' ||",
" ' b. If the customer wants a refund, then confirm refund processed and update the order status to refund_completed' || ",
" '4. If the product was defective or the box broken:' ||",
" ' a. Ask customer if they want a replacement or a refund' ||",
" ' b. If a replacement, inform customer replacement is on its way and they will receive a return shipping label for the defective product, then update the order status to replaced' ||",
" ' c. If a refund, inform customer to print out the return shipping label for the defective product, return the product, and update the order status to refund' ||",
" '5. After the completion of a return or refund, ask if you can help with anything else.' ||",
" ' End the task if user does not need help on anything else\",",
" \"tools\": [\"Update_Order_Status_Tool\"]}'",
" );",
"END;"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340036909,
"endTime" : 1777340037630,
"interpreter" : "script.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "\nPL/SQL procedure successfully completed.\n\n\n---------------------------\n\nPL/SQL procedure successfully completed.\n\n",
"type" : "TEXT"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : null,
"hasTitle" : false,
"message" : [
"%md",
"",
"### Define Customer Agent",
"",
"Next, we define the agent that will perform the task, describing the role of the agent. ",
"This characterizes the the experience of the agent and how they should interact with the customer. ",
"",
"First, you need to have a credential for your AI provider of choice. We've shown the template for OCI GenAI Service. ",
"",
"Then, define the AI profile using this credential for the desired LLM and transformer. ",
"The agent will use only the LLM at this point, but the transformer will be used for the RAG tool later in the notebook. "
],
"selectedVisualization" : "html",
"visualizationConfig" : null,
"hideCode" : true,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : true,
"hideInIFrame" : false,
"enabled" : true,
"forms" : "[]",
"result" : {
"startTime" : 1777340056269,
"endTime" : 1777340056548,
"interpreter" : "md.medium",
"taskStatus" : "SUCCESS",
"status" : "SUCCESS",
"results" : [
{
"message" : "<h3 id=\"define-customer-agent\">Define Customer Agent</h3>\n<p>Next, we define the agent that will perform the task, describing the role of the agent.\nThis characterizes the the experience of the agent and how they should interact with the customer.</p>\n<p>First, you need to have a credential for your AI provider of choice. We've shown the template for OCI GenAI Service.</p>\n<p>Then, define the AI profile using this credential for the desired LLM and transformer.\nThe agent will use only the LLM at this point, but the transformer will be used for the RAG tool later in the notebook.</p>\n",
"type" : "HTML"
}
],
"forms" : "[]"
},
"relations" : [ ],
"dynamicFormParams" : "{}"
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,
"title" : "Create the credential to access OCI GenAI Service for your AI models",
"hasTitle" : true,
"message" : [
"%script",
"",
"-- This paragraph is DISABLED on purpose.",
"-- If you are using this with an Oracle LiveLabs-provided OCI environment,",
"-- please do not make changes. The credential is created for you.",
"",
"-- If you are using the current Notebook with your own OCI tenancy:",
"-- 1) Click on the Settings of this paragraph, and click \"Enable Run\"",
"-- 2) Enter your own information below",
"-- 3) Make sure to take into account the name of your newly defined Credentials",
"",
"begin",
" DBMS_CLOUD.drop_credential(credential_name => 'AI_CREDENTIAL');",
" EXCEPTION WHEN OTHERS THEN NULL; END;",
"/",
"BEGIN",
" DBMS_CLOUD.create_credential(",
" credential_name => 'AI_CREDENTIAL',",
" user_ocid => 'ocid1.user......',",
" tenancy_ocid => 'ocid1.tenancy......',",
" fingerprint => '04:f2:.....'",
" );",
"END;"
],
"selectedVisualization" : "raw",
"visualizationConfig" : null,
"hideCode" : false,
"hideResult" : false,
"hideGutter" : true,
"hideVizConfig" : false,
"hideInIFrame" : false,
"enabled" : false,
"forms" : "[]",
"result" : null,
"relations" : [ ],
"dynamicFormParams" : null
},
{
"row" : 0,
"col" : 0,
"sizeX" : 0,
"width" : 12,