how to chat with Oracle 23ai using SQL agent

 

Introduction:

In this blog post I am going to build a simple chatbot where we can interact with Oracle 23ai database.

To build this chatbot I am using SQL agent, we can also build a chatbot using chain but SQL agent have advantages over chain.

Q&A with PDF - Building RAG application with Oracle 23ai Vector Search and OpenAI LLM

 


What is RAG? 

Retrieval Augmented Generation (RAG) is an important component in Generative AI. It allows important context to be included with the prompt to the LLM.

ExaCC: PDB creation fails with DBAAS-60074

 


In this blog post, I am going to describe a strange error when I was creating the new PDB in existing CDB on ExaCC using dbaascli.

Attach block volume to an existing LVM on OCI compute instance

 


In this blog, I will cover the steps to attach Block Volume to an existing LVM on OCI compute instance.

Cross-tenancy compute VM migration on OCI

 

In this blog post I will show you how we can migrate OCI compute instance from one tenancy to another tenancy. Both tenancies should be in same region US East (Ashburn).



How to chat with MySQL database in Natural language (English)

 


In this Gen AI world, companies are working hard to release best LLM model, few of them are OpenAI, Google, Meta, anthropic.

Today I will show you how we can chat with our MySQL database using OpenAI LLM model. You can use any other model as well, even use any open source model.

Pre-requisite:

1. You should have account on Open AI to use the Open AI key.
2. MySQL database 
3. LangChain (LangChain is an open source framework for building applications based on large language models (LLMs).
4. Visual Studio Code (You can use any other platform to develop code, I feel vs code is easy)
5. Python 3.10 or later

So let's start.. 

I have 2 files, .env and app.py

app.py where I write my code. and .env where I specify the OpenAI key

1. First step is to install libraries.

pip install langchain langchain-community langchain-openai langchain_core langchain_chains


2. Setup environment variable. (here basically I setu AP key as an environment variable that point to my .env file)



3. Connect to MySQL database. This is how we connect to MySQL database with db_uri string where chinook is my database name.



4. Now we connected to the DB. Let's create a SQL query from user question.



Here I defined the LLM model
"create_sql_query_chain" function generate the SQL query using llm model and db schema as input

as you can see above is generate the SQL query.

5. Now we have to run that SQL query on DB to get the result.


here is you see I use the QuerySQLDataBaseTool class which used to execute query on DB.

and then I create a chain which will invoke using user query and first generate query and then execute it and later I print the result. Here I have 8 employees in employee table.

6. Here everything looks good but we need the output in natural language not like [(8,)]

To do that I created a custom prompt for LLM to use which will take user question, query, result and give answer.

and created another chain which will take the output from step 5.


Here I defined and initialize the custom prompt answer_prompt

and create a chain using RunnablePassthrough where we pass the user question.

first assign save the SQL query into query variable and then second assign get the query and execute it and save the result into result variable.

and then we use the prompt(prompt now have the user question, query and result) and pass to LLM model and StrOutputParser() basically save the natural language output.

When I print the response, you can see the natural language output.

7. I also tried some complex query and it worked like magic :)



Let me know if any question. Thanks.

Start of Advanced Queue job hanging in Oracle 19c

 


Oracle Advanced Queuing (AQ) is a database-integrated messaging infrastructure in Oracle Database. AQ leverages the functionality of the Oracle database to store messages in persistent queues. All operational benefits of the Oracle database such as high availability, scalability and reliability are applicable to the messages and queues in

Analyze Invoices with Oracle Analytics and AI Document Understanding

OCI Document Understanding is an AI service that enables developers to extract text, tables, and other key data from document files through APIs and command line interface tools.


In this blog I will show you how we can visualize invoices in oracle analytics using AI document understanding pre-trained model.

How to Import Custom visualization in Oracle Analytics Cloud to see Images

 


In this Blog I will show you how to download and import Image Gallery Plugin into OCI Oracle Analytics Cloud. using this plugin we can see Images in OAC.

How to Upgrade OCI BaseDB (DBCS) from 19c to 23c

 


Recently there was a requirement to upgrade DBCS PDB from 19c to 23c. There might be other ways to do that but I found the best and easiest way is to create new 23c DBCS and then move 19c PDB using Refreshable clone method and then use Auto upgrade to upgrade it.

ADB App Store - Oracle autonomous database App store and how to deploy application

 


The ADB App store: is an application launchpad for Oracle supported applications. Using ADB app store, tenants can install and manage the life cycle of these applications. 

How to automate start and stop of DBCS node using REST API in OCI

 


Recently we migrated databases from ODA (Oracle database appliance) to OCI DBCS for a client. And client asking to stop the dev DBCS node from 5 PM to 6 AM in the morning to save cost.

How to use Document Understanding AI service in Process Automation

 Info:

Recently, Oracle added new Document Understanding feature with OCI Process Automation.

In Process Automation forms, intelligent document processing is implemented with the Document Understanding control that uses out of the box pretrained AI models from OCI Document Understanding AI service to automatically detect, classify and extract texts and objects from uploaded documents.

How to provision and build a simple business process with OCI Process Automation (OPA)

 Introduction:

OCI Process Automation (OPA) is an OCI PaaS service which enables you to rapidly design, automate, and manage business processes in the cloud.

How to delete Non-CDB or 11g database or 11g Db home from Exacc


Objective: How to delete/remove Non-CDB or 11g database or database home from ExaCC

Prerequisite: Should have Non-CDB or 11g home and database on ExaCC environment.

OCI Full Stack Disaster Recovery - Move/Switchover compute instances between regions

 About Full Stack DR:

Full Stack DR is an Oracle Cloud Infrastructure (OCI) disaster recovery orchestration and management service that provides comprehensive disaster recovery capabilities for all layers of an application stack, including infrastructure, middleware, database, and application.

Automation - Apply Database Release Update patch in Oracle 19c using Ansible



Intro: In this blog I will show you how to use Ansible to automate Oracle database patching. I applied the latest oracle 19c RU patch "Database Release Update 19.21.0.0.231017" on oracle 19c database and also rollback using Ansible.

ODA pre-check report alert (Cluster Ready Services attribute STOP_DEPENDENCIES/START_DEPENDENCIES for database is incorrect)

I am planning to Patch ODA from version 19.11 to 19.15 on X8-2L.



I am not discussing the whole ODA patching here but one of issue during pre-patch report.

When I run the Pre-patch report I got below error/alert.. This is part of pre-check report.

How To Disable Automatic Database Backups Using DBAASCLI on ExaCC

  In this blog post I will show you how to disable Automatic database backups on ExaCC using dbaascli.