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 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.