today I'm going to try and build an AI business in just 24 hours to show that it's possible the first thing I'm going to do is write up some ideas and sketch them down so that I know what kind of project I'm going to work on so my first idea was to create a Chrome extension it could use AI to maybe do some Auto completes for people when they're writing in text Fields but then I thought large companies like grammarly already have this space covered another idea I liked was creating a startup that would search
through documentation of popular libraries and languages and use AI as a chatbot to be able to give you answers from that documentation brainstorming some more I came up with the idea to use AI for image processing but large companies like mid Journey already have this covered quite well let's enhance for example lets you upscale your images with AI really well and Adobe have released their recent update which brings even more AI features to things like Photoshop and illustrator with so much competition in the AI space right now I needed to Pivot and change my idea
I'm not crazy this is what a lot of startup culture is is all about fail fast and pivot fast so I remembered one of the best ways to come up with ideas is to try and remember past problems and here's one I had just a few weeks ago this right here is the line of code that's stuffing me up you see I was doing this tutorial on free code camp and I had gotten stuck during the video which was like 8 hours long and I thought there must be a better way to do this and
I came up with an idea the problem I'm having is if I'm searching for something specific in a long video I want to download the trash transcript of that video and then search through that transcript and see if I can find the answer in there and so what I'm thinking is I'm going to see if I can use the YouTube API to download the transcript and then see if I can plug that into a database that a chat GPT can use and then find the answer for me I had already been looking at the YouTube
captions API but I was having some problems where I couldn't really download it so I decided to do some Googling to see if I could fix this if I have a look I think the script is right there and the problem right now I'm having is that it needs the API key so so I don't think this address Works back then I gave up on this idea but now I'm thinking what if I took another look what if I connect directly to the YouTube API and connect that directly to Chad GPT so I gave it
another try I headed over to Google and loaded up the YouTube data API the first step is to see if I can download a YouTube transcript and while searching for Content or uploading it is quite simple properly finding the caption section and downloading a transcript wasn't as easy however eventually I found a section that covers it it wasn't going to be simple though I needed to load up vs code and start writing some functions for it there were quite a few different options to try out and I tested out this one called YouTube caption scraper
which came up with this simple function but it didn't work every time I tried to run it I had some kind of Errors pop up and I decided that maybe this is too complicated to solve and it's time to try out a new library I came across YouTube transcripts this this was the syntax additionally it actually worked I got a full list of the transcript with timestamps and durations feeling pretty excited I think I'm actually going to be able to make this idea happen I wanted to connect this up to open AI I jumped into
their documentation for GPT and had a look at their new chat GPT API I wanted to copy out this function just over here and test it out in my own code I've got my API key here please don't copy it I'll delete this later but I created a file called comments. JS that pulled out the captions for our YouTube video this didn't look very pretty so I beautified it so I could take a closer look here it is but this wouldn't go into Chad GPT so I merged all the text together into a file called
merge. txt doesn't look that great but Chad GPT could use this as part of the transcript then I plug this all into a prompt with a specific question called what is this video about I crossed my fingers I opened up console I ran node and waited for the response and chat GPD answered my question it answered it accurately so I wanted to test just what kind of questions I could ask I ask questions like what's the biggest takeaway from this video as a web designer as well as what might be missing from this video chat
GPT replied that while the transcript is great the visuals are kind of missing I'm sorry chat GPT next time I'll try to pass those through I've got most of this idea working now well the individual Parts which is usually the most important thing when building a project I can download transcripts from YouTube I can then plug those transcripts into chat GPT and communicate with Chad GPT about the video itself I'd love to be able to get access to Del 3 where I could even give it a screenshots of the video to maybe communicate even more
but I don't have access to that API just now the next thing I want to do is plug this all into a database so I can store and communicate with it a little bit better I'm going to be using a vector database because that is what is best now especially when you're trying to use large language models so I'm going to be using Astra DB because they've recently introduced Vector databases as part of their database Suite it was a lunchtime so I thought I would use this time to take a look at how Astro DB
actually works there was this great video by Anna it was kind of a crash course on using astrab with Vector databases I'll link it in the description below because it was useful enough for me to feel comfortable to create my own Astra database and get started with this idea I headed to data Stacks here I went to create a new free account and create a new database on the dashboard there was already an option waiting to create a vector search database so I selected to create that for the database name I called it YouTube transcripts
and then I filled out some other basic information such as the provider being on Google Cloud as well as the region being Us West I created the database and now I'm ready to test it out but I've got one problem now I'm up to the hard part of this project so I'm going to this point where I need to build this but putting it all together and interconnecting all the files sometimes can get complicated I'm looking for a template or something to get me started and and I found the perfect boiler plate it was made
by none other than astrab themselves and it comes with a Json API with mongus set up and the database connected and it works pretty much the same as my system except with movies and then you can talk to chat GPT about those movies so I'm going to see if I can pull that out and use YouTube transcripts instead and see if all that connects together it was time to do some refactoring what I decided to do was merge the two projects together my local project and this template file then I created very good semantic naming
for each one of my functions and had them placed in an individual file so that each function had one specific job and I could link them all together I created this model here in mongus for videos it would collect the title description URL the transcript as well as the vector that I would get later from open AI the next thing I needed to do was collect the URL and the individual unique ID for that URL from a video so I had a script that would pull out the ID from the Val value that gets get
passed in the header tested whether this was saving in my database and it wasn't I kept getting this era with an empty array this was because the original template was actually dropping the collection which wasn't useful for me I needed that collection to stay in there even when I reran the app so I commented at this line tested it again and now the actual videos were being placed in the database and I was storing and being able to retrieve all the information I needed like the URL title description and transcript what's cool is that I
could actually collect up way more information that I needed I actually could pull out all the related videos all the thumbnails what length the video is what other kind of thumbnail sizes there are and much much more but I really didn't need to store that much I only needed to store the basics which were these right over here as well as the embedding which I actually generated from open Ai and now this project is almost ready to use I just need a nice web user interface on a website that I can actually communicate here with
this back end and here it is it's a nice and simple interface but I'll show you how it works it pulls a YouTube URL and grabs all the detail populating it in the astrab database then the transcript asks one question what's this video about to get you started this one here is about nextjs and versel but then I can ask additional questions like what would I learn by watching this video and does this video give me a tutorial on how to deploy a nextjs project in this case no it doesn't so yes I've kind of
got this working let me try with one more video I'll try this one from fireship I always like his content here is one he made about why big projects are ditching typescript instead of watching the video I'll just ask Chad GPT to tell me and here it tells me it's because it's just too hard so how's this all working I put together an index.html file it was some simple front-end code I used Tailwind CSS for the user interface and then I use some JavaScript to essentially render out different types of UI based on messages from
the back end the messages I get from chat GPT I would Loop through here and print out HTML content almost like react the back end was quite simple I just grabbed the URL address of the video as well as the messages passed from the client these would be sent to astrab as well as chat GPT then I would pass this information back to the front end and the front end would update its state based on the data that was sent the end result is a project that's working exactly how I intended I can now plug
URLs in anything new will get saved in the database on astb and a vector will be created anything existing will be pulled across and now I can chat with chat GPT based on the transcript of the video and this is pretty cool though there are some limitations such as if the video is a few hours long I might not be able to fit the entire transcript into a chat GPT message and this is where I think it'd be useful to split the actual transcript into small sections and then save those in Astro DB and pull
out the only sections that you need based on the question that the user asks this is as much as I can do in 24 hours but it's an MVP that's working if you guys want to check this project out I'm going to link it in the description below and I'd like to thank Astro DB for sponsoring today's video they make videos like this happen on the channel and I'll link them in the description below as well