Connect ChatGPT to your SQL Database in 5 minutes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys and girls and kittens and welcome to iron hero in this video I'm going to show something Kick-Ass call which is how to connect charging machine learning and AI to your local database whatever that database happens to be now if you don't have an ex database of yourself or you don't want to connect it to your own private database immediately then you can download an example plugin database here we have three of them I've already installed sakila it takes a couple of minutes so I've already done that before and then I've configured my open AI API key and my recapture key I can't show you this but you go to configuration then you get a button up here that says configure open AI API key and configure recaptcha just click those and you configure both of those if you want to connect to an existing database you can click the connect thing here and then I can choose myscale postgres Gala scale server you paste in your connection string here and then you paste in a name for your connection here at which point you you you gain access to that database assuming it's exposed to the internet somehow if you want to whitelist the IP you can actually find the IP I think you'll find it the server IP it doesn't correctly show now but uh you you can figure that out later now what I want to do is that I want to go to create I want to go to SQL studio now remember I told you I'd already installed a plugin database and I've installed sakila you yet again you can do that from database if you if you want to reproduce What I've done but it takes a couple of minutes to install the database I've kind of like cheated a little bit up front however this is actually an example database published by Oracle that has been ported to sqlite and it's basically a 25 year old DVD rental database believe it or not but it serves the purpose as an example now if you click SQL view here now because the database happens to come with a lot of pre-existing SQL Snippets that I can immediately execute for instance this one that selects the actors um film here right now it basically selects every single film that is in its database and the number of actors that are participating in this particular field now I can do for instance order by actors descending and then I can do limits and now I'm getting the top uh 10 movies from the database with the most number of actors in them now I have a valida scale I can copy this girl you can go to manage I can go to Hype Lambda and I can write data dot connect column two square brackets generic pipe circular can I do data dot select column Alpha two double quotes and I paste in MySQL in between the two double quotes click F5 executes it and immediately now you can see we actually have a semantic return value from our hyper Lambda being a list object naming each film and each actor now what I can do I can now go to manage and I can open my machine learning models in a different window why because I might want to have a look at this structure as I'm editing this machine learning model then I want to create a new machine learning model I'm just going to call mine who right and basically that's it I click save now I click training data then I choose my full machine learning model then I click adds and then I write how many actors played in each sakila movie this becomes kind of like a question notice it is based upon semantic search so you can write anything that like is similar to this question doesn't have to be the exact same question done what I want to do I want to have two of these guys and then I'm pasting in this code here now whoops I need to go back here paste in this code because I need a hyper number code and then let me write a temporary variable dots uh results for each column X colon adds data dot select slash Asterix there's going to be an article associated with this YouTube video or you can copy and paste the code and cash turn three spaces three spaces still next colon at dot result one two three four five six seven eight nine strings.com cats one two three four five six seven eight nine 10 11. well get value I should probably have a colon behind result here otherwise I might get an old result at dot result and then let me just copy these spaces and then [Music] let me see here film um actor counts and then get value column X column at dot DP slash hash slash Asterix slash look film like this and actors I think actors yes and now basically what it is doing let me add one more guy basically what it's doing is constructing a string right single string entity now what I want to do is that I want to go let me see data select let's remove these commands I guess they're not really then we have one two three okay one two three return colon X column at dot resource now what it's basically doing is that it's a returning uh every single film with the name of the film and the number of actors that played in that particular field what I can do now is to save this guy and what I then I can go to my models and then I just click vectorize and I have one training snippet or two which I am now vectorizing and I can now start asking my model questions now if you go to manage and you go to hyper Lambda and then you load Snippets and then write contacts because we might want to test out our context first right and then you write in a prompt who played in what movie question mark hopefully this is going to work and now of course I need to use the model type Foo I won't use text embedding error and then here's my prompt threshold and Max tokens and now I can execute it hopefully if I've done everything correctly you will see here that how many actors played in each sakila movie and we should probably have some spaces here I presume so let's go back to our machine learning model and let's update this particular Snippets and let's add some spaces actor count save it and execute it again see if you now can get some slightly better spacing and here you can see active accounts film mummy creatures actor count 11. now I can actually use this as a machine learning context and I can go to my models and I can ask how many actors played in The Dinosaur movie with a little bit of luck now it's actually going to provide me with the correct uh in the sake dinosaur movie uh the correct answer let me see why it doesn't work change it to Mummy creature thank you and let's try again obviously needs to actually know the answer to the question it's answering correctly in the secular mummy Creatures movie 11 actors played we can actually go through context and verify that mummy creatures 11 if we ask uh submarine beds for instance you probably don't even need to have sakila nine actors so what I've done now is that I've created a hyper Lambda snippet that is being semantically matched towards my question this being my question right that hyperlum the snippet is actually executing SQL towards my local database called sakila and it could be any arbitrary SQL and then it's constructing a string out of MySQL important and it's returning that to the caller and then hyper Lambda is actually submitting that text to Charity as the context for answering my particular question whatever that question is in all sakila movies and of course MySQL can be anything my database can be anything and my question can be anything and here we are exactly correctly adding up the number of actors to in total of course some of these actors were overlapping so but that doesn't matter the point is actually dynamically reaching into my database fetching data from my database and sending it shortcut that is pretty key guys if you ask thank you for watching have a nice day
Info
Channel: AINIRO
Views: 7,986
Rating: undefined out of 5
Keywords:
Id: f3_l5NAQS1U
Channel Id: undefined
Length: 11min 23sec (683 seconds)
Published: Mon Jul 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.