|
2 | 2 |
|
3 | 3 | In this article, we will learn how to generate SQLs or chat using **#Cohere** AI or **#OpenAI** with Oracle # **SelectAI** to respond to users' input prompts. DBMS_CLOUD_AI package facilitates and configures the translation of natural language prompts to SQL statements. Oracle **#APEX** helps create a user interface for accepting user inputs and displaying AI results. Use Oracle Machine Learning #OML notebooks to run some of the Select AI SQLs. |
4 | 4 |
|
5 | | -This article is a continuation of my [previous article][1] . We discussed Retrieval Augmented generation ( **#RAG** ), which is a **#NaturalLanguage** Processing ( **#NLP** ) technique that combines information retrieval and natural language understanding with the content generation or, in simple words, an intelligent chatbot that can talk to database - generate SQL, run queries and display results on user's chat window. we will take an example of using Cohere AI with Oracle Autonomous Database with customer info and US Hospitals data tables; you can download these table data from [my GitHub repo][2] . |
6 | | - |
7 | | - |
8 | | -[1]: https://www.linkedin.com/pulse/retrieval-augmented-generation-chatbots-aimlnlp-based-madhusudhan-rao-pgodf |
9 | | -[2]: https://github.com/madhusudhanrao-ppm/code-assets/tree/main/AI-for-Financial-Services |
10 | | - |
11 | 5 | ### Assumptions: |
12 | 6 |
|
13 | 7 | You have access to the following: |
14 | 8 |
|
15 | | -1. Oracle Autonomous Database with ADMIN user access. |
16 | | -2. API Keys from Cohere or OpenAI - please check their terms and conditions for usage. [Cohere - Developer Guide][3] |
| 9 | +1. Oracle Autonomous Database with ADMIN user access |
| 10 | +2. API Keys from Cohere - please check their terms and conditions for usage. [Cohere - Developer Guide][3] |
17 | 11 | 3. Oracle APEX workspace (Optional) or any non-ADMIN Database USER |
18 | 12 | 4. APEX username (<APEX_USERNAME>) is the same as schema name (Optional) |
19 | 13 |
|
@@ -462,50 +456,7 @@ Click on various chart icons to change visualisation |
462 | 456 |
|
463 | 457 | [31]: images/1705725354738.png |
464 | 458 |
|
465 | | -If you plan to use [OpenAI][32] , then it would need a few setup changes listed below and the OpenAI API Keys. |
466 | | - |
467 | | - |
468 | | -[32]: https://openai.com/ |
469 | | - |
470 | | -To get API Keys Sign up and Sign in at [https://platform.openai.com/api-keys][33] |
471 | | - |
472 | | - |
473 | | -[33]: https://platform.openai.com/api-keys |
474 | | - |
475 | | -![][34] |
476 | | - |
477 | | - |
478 | | -[34]: images/1705727388220.png |
479 | | - |
480 | | -and run these commands from Oracle Autonomous Database SQL Developer under Database Actions |
481 | | - |
482 | | - BEGIN |
483 | | - DBMS_CLOUD.create_credential('OPENAI_CRED', 'OPENAI', 'YourOpenAIKey'); |
484 | | - END; |
485 | | - |
486 | | - BEGIN |
487 | | - DBMS_CLOUD_AI.CREATE_PROFILE( |
488 | | - profile_name => 'OPENAI', |
489 | | - attributes => '{ "provider": "openai", |
490 | | - "credential_name": "OPENAI_CRED", |
491 | | - "object_list": [{"owner": "<APEX_SCHEMA_USER>", "name": "<DB_TABLE>"}] |
492 | | - }' |
493 | | - ); |
494 | | - END; |
495 | | - |
496 | | - BEGIN |
497 | | - DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE( |
498 | | - HOST => 'api.openai.com', |
499 | | - ACE => XS$ACE_TYPE(PRIVILEGE_LIST => XS$NAME_LIST('http'), |
500 | | - PRINCIPAL_NAME => '<APEX_SCHEMA_USER>', |
501 | | - PRINCIPAL_TYPE => XS_ACL.PTYPE_DB) |
502 | | - ); |
503 | | - END; |
504 | | - |
505 | | - EXEC DBMS_CLOUD_AI.set_profile('OPENAI'); |
506 | | - |
507 | | - |
508 | | -**Troubleshooting -** |
| 459 | +### Troubleshooting |
509 | 460 |
|
510 | 461 | 1. _ORA-20000: ORA-24247: Network access denied by access control list (ACL)_ |
511 | 462 |
|
@@ -578,36 +529,3 @@ and run these commands from Oracle Autonomous Database SQL Developer under Datab |
578 | 529 |
|
579 | 530 | **Solution:** To run **Select AI** SQL commands, use Oracle Machine Learning Notebook or SQL Developer Desktop client. **Select AI** will not work in SQL Database Actions or in Oracle APEX SQL Commands. |
580 | 531 |
|
581 | | -### Demo video |
582 | | - |
583 | | -Thanks for reading, liking, and sharing - have a great day. |
584 | | - |
585 | | -Thanks & Regards, |
586 | | - |
587 | | -[Madhusudhan Rao][38] |
588 | | - |
589 | | - |
590 | | -[38]: https://www.linkedin.com/in/madhusudhanraobm/ |
591 | | - |
592 | | -Links to my other related articles and LiveLabs |
593 | | - |
594 | | -- [How to build intelligent applications using Oracle Generative AI and Oracle APEX][39] |
595 | | -- [How to Translate text using OCI AI Language and Oracle APEX][40] |
596 | | -- [How to use Oracle Select AI with Cohere or OpenAI to Generate SQLs from Natural Language][41] |
597 | | -- [Retrieval Augmented Generation (Database Chatbots)][42] |
598 | | -- [How to create dynamic websites on an always-free Oracle Cloud Instance][43] |
599 | | -- [Working with Oracle APEX and Oracle Analytics Cloud platform][44] |
600 | | -- [Working with JSON-Relational Duality Views and Oracle APEX][45] |
601 | | -- [How to Integrate Google Cloud YouTube APIs with Oracle APEX][46] |
602 | | -- [AI for Healthcare][47] |
603 | | - |
604 | | - |
605 | | -[39]: https://www.linkedin.com/pulse/how-build-intelligent-apps-oracle-generative-ai-apex-madhusudhan-rao-z423f/ |
606 | | -[40]: https://www.linkedin.com/pulse/how-translate-text-using-oci-ai-language-oracle-apex-madhusudhan-rao-seq0f |
607 | | -[41]: https://www.linkedin.com/pulse/how-use-oracle-select-ai-cohere-openai-generate-sqls-from-rao-zabjf |
608 | | -[42]: https://www.linkedin.com/pulse/retrieval-augmented-generation-chatbots-aimlnlp-based-madhusudhan-rao-pgodf |
609 | | -[43]: https://www.linkedin.com/pulse/how-create-enterprise-grade-dynamic-website-always-free-rao-9hgmf/ |
610 | | -[44]: https://www.linkedin.com/pulse/working-oracle-apex-analytics-platform-madhusudhan-rao-tfwvf |
611 | | -[45]: https://www.linkedin.com/pulse/working-json-relational-duality-views-oracle-apex-madhusudhan-rao-a2izf |
612 | | -[46]: https://www.linkedin.com/pulse/how-integrate-google-cloud-youtube-apis-oracle-apex-madhusudhan-rao |
613 | | -[47]: https://bit.ly/O_AI_healthcare |
0 commit comments