Connect ChatGPT to your SQL Database
With our latest real time information release, we're now able to connect ChatGPT to any SQL database you have, and transmit the result of your SQL to ChatGPT, for then to have it analyse your data, answer your question, and return an answer accordingly.
Edit - We now have multiple better ways to achieve this. You can find some of these below.
- Wrap your SQL Database inside an AI Chatbot
- Resurrecting the AI Expert System
- Creating an AGI Assistant in 22 minutes
However, before I start explaining the process, let's first enjoy a screenshot 😁
What you're looking at
The above ChatGPT answer was created by executing the following SQL
select f.title as Film, count(fa.actor_id) as Actors
from film as f
join film_actor as fa on f.film_id = fa.film_id
group by f.title
order by Actors desc
limit 10
The above SQL of course is a part of a Hyperlambda snippet, that looks as follows;
data.connect:[generic|sakila]
data.select:@"select f.title as Film, count(fa.actor_id) as Actors
from film as f
join film_actor as fa on f.film_id = fa.film_id
group by f.title
order by Actors desc
limit 10;"
.result:
for-each:x:@data.select/*
set-value:x:@.result
strings.concat
get-value:x:@.result
.:"Film "
get-value:x:@.dp/#/*/Film
.:" "
.:"Actor count "
get-value:x:@.dp/#/*/Actors
.:"\r\n"
return:x:@.result
The above Hyperlambda snippet again is using the Hyperlambda [strings.mixin] slot, which combines natural language text with the result of executing Hyperlambda code. Below is a screenshot of the complete training snippet if you're interested.
Once the context is semantically matched towards the query, being e.g.
How many actors played in the movie MUMMY CREATURES?
The SQL extracts the following data;
Film MUMMY CREATURES Actor count 11
Film BOONDOCK BALLROOM Actor count 11
Film LAMBS CINCINATTI Actor count 10
Film HELLFIGHTERS SIERRA Actor count 10
Film ARABIA DOGMA Actor count 10
Film WIZARD COLDBLOODED Actor count 9
Film SUBMARINE BED Actor count 9
Film RANDOM GO Actor count 9
Film LESSON CLEOPATRA Actor count 9
Film IMAGE PRINCESS Actor count 9
Then our OpenAI machine learning functions submits the above data to OpenAI's APIs, which then uses the above as its "real time data foundation for answering the question", the end result being something such as follows;
There was 11 actors playing in the movie MUMMY CREATURES
In the video below I am walking you through the entire process
Pretty kick ass if you ask me 😁
Have a Custom AI Solution
At AINIRO we specialise in delivering custom AI solutions and AI chatbots. If you want to talk to us about how we can help you implement your next custom AI solution, you can reach out to us below.