How to Build AI ChatBot Using Google Gemini AI with Custom Knowledge Base

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to build this custom AI chat bot you might ask why do we have to create a custom AI when we already have chat gbt Bard Claud and others well these are great general purpose AI chat Bots that have been trained on the data found on the internet if you ask them a general knowledge question you'll get a decent answer based on the information it has seen before on the internet but there's no way for them to answer a specific question about your business let's say for example you have an e-commerce business there's no way for chat gbt or Bard to help a customer on your e-commerce website track their order because that's a specific knowledge therefore in this video we'll also teach our AI to perform specific task based on our use Case by the end of this video you'll be able to create your own personalized AI chat bot that you can teach it to perform a specific task you can do this for your business or other businesses and start making money we'll be using Google Gemini API nodejs and AI Studio to create our chatbot I'll show you how easy it is to build a custom AI chatbot with the power of Gemini AI so without any further Ado let's get [Music] started you can access Gemini API from two places Google AI studio and the vertex AI you'll need a Google account in both cases if you'd like to access Gemini AI from vertex AI you'll need a Google account Google Cloud account with billing enabled if you're just getting started I recommend trying out the API in the Google AI Studio it's easier and when ready for fully managed Enterprise AI platform you'll be able to easily transition your AI Studio code to vertex AI for additional customer customization and Google Cloud features as a prerequisite you'll need a node.js version 18 or above you can download it from nodejs.org and a code editor like Visual Studio code you can download it from code. visual studio.com they are free now that we have covered the prerequisites let's jump into my computer and show you exactly step by step how to use the Gemini API the first thing we need to do is open Google AI studio in the browser that's maker suite. google.com when you log on this page for the first time you need to sign in with your Google account if you don't have a Google account you need to create one and once you sign in you'll get into this interface Google AI studio is a browser-based IDE for prototyping with generative models Google AI Studio lets you quickly try out models and experiment with different prompts when you have built something you're happy with it you can export it to code in your preferred programming language Google AI Studio provides several interfaces for prompts that are designed for different use cases such as free form prompts structure prompts and chat prompts we'll use chat prompts to build conversational experiences the prompting technique allows for multiple input and response turns to generate output currently for chat gimini pro model is available I'm looking forward to gimini my ultra model as capabilities improve these models are going to be able to do so much more and use files and data in multiple formats multiple modality is really going to change the way we interact with AIS temperature is the level of creativity you can adjust the level of creativity that is allowed in the responses from here here we can add stop sequencing and we have safety settings we can adjust How likely you're to see responses that could be harmful content is blocked based on the probability that it is harmful so if you would like to allow for Dangerous content for example because maybe you want to make an AI chat bought for a game you can adjust it or you can allow more dangerous content by setting it here um I'm going to set it to the default settings and close this to build a chat bot you need to provide a custom knowledge context and examples of interaction between a user and a chat bot to guide the model to provide the responses you're looking for to create a chat prompt in the right your prompt example column of the prompt interface you can start providing context and examples of interactions I've already designed a prompt which I'm going to paste in this field I've pasted The Prompt that I designed and I'm going to to explain this prompt in a little bit first I'm going to edit the title in description I'm going to call this coding money chatbot click save here as you can see I'm giving the AI chatbot a name in a Persona in a specific job to perform so here I'm writing your Sam a friendly assistant who works for coding money coding money is a website in YouTube channel that teaches people how to code in make money online your job is to capture user's name and email address don't answer the user's question until they have provided you their name and email address at that point verify the email address is correct thank the user and output their name and email address in this format once you have captured user's name and email address answer users questions related to coding money here I've provided information about the coding money website social media channels the uh videos and at the bottom I've uh mention to encourage users to check out our YouTube channel and follow us on social media I can click on this button to generate example as you can see the model has generated an example for us to see and this is exactly what I want have you want to provide more examples we can do so in the user in the model Fields here we can provide an example of what interactions between a user and your chat bot might look like after youve filled out an example start testing your application by chatting with the model on the right pane of the chat prompt interface so if I type here hi I get hi there thanks for reaching out before I can answer your question I'll need to capture your name and email address can you Prov provide that information as you can see this chatbot is following the instructions that we have provided here in the prompt example we can teach our chat bot to chat better uh by providing a single statement in response example uh we were able to build a basic AI chatbot however a single example is usually not enough to ensure consistency in quality in the model's responses without further input the model's response to a question might be very long or it might sound like it comes out of a textbook um rather than a friendly assistant so we can customize the tone of our chatbot by using the model response and editing it to match the desired tone and style of uh our chatbot we can click this button to add an edit example for the chatbot definition now we can edit the copied input in response to match the intended style and tone of our chatbot uh so here I'm just going to edit this and I'm going to say um thanks for reaching out to coding money you can use this approach to add additional examples ask more questions edit the answers and improve the quality of your chat bot continue to add examples and test how they modify the behavior of your chatbot typically more examples correspond to higher quality chatbot responses under the hood Google AI Studio constructs a prompt by combining dialogue examples in conversation history into a single block of text that's sent to the model to see what the complete prompt looks like click the preview at the bottom of the screen to bring up the preview pan note that because every message between the model and user is included in the prompt this is conversational history conversational prompts can grow quite long as conversation goes on eventually you may hit the model's token limit the maximum length of text the model can accept you can see the complete conversation in token count in the preview tab as you can see we're using 58 tokens out of the over 30,000 tokens we are allowed to use um if you're not getting the desired output from the chatbot you can also try adjusting the model parameters on the right side to see if they produce more appropriate results for your use case after you have filled out an example start testing your application by chatting with the model on the right pan of the chat prompt interface type in a question or observation that a user might make for example what's coding money as you can see it's following the instruction I've given in the chat context in the prompt examples now I can add more and more examples to make this better but it looks like it learned pretty much what I wanted from here one of the great things about Google AI studio is that you can have it generate some sample code for you and you can click on uh get code first let me save this and you can click on git code and you can select your preferred programming language I'm going to select JavaScript and as you can see there are some install ation instructions at the top you need to make sure that your system has those installed and then it's importing some things from the generative AI um Library here the model is specified configuring the application is going to go through the model allow you also to set different safety settings and then also send those examples to model for input so if I want to I can go ahead and copy this it's been copied to the clipboard you can also edit safety settings or some advanced settings right from here and the code would reflect that as well you can see that it allows you to handle some of these different safety settings right in the application however if you want to use this in your own application you're going to need an API key for the project that you're working on get API key and you can see here that I can create an API key in a new project or an existing project I already have an API key that I created earlier so I'm just going to use that for this project if you create an API key is going to be a long string you just copy it and whenever you use the code it provided you let's go back to get the code that it provided you you're going to paste it where it says API key you're going to paste that API key over here now I'll show you one more really interesting thing so when I look at this code it's given me here I know that it's a basic code for a simple node.js application and what I really wanted to do is allow me to add a web interface to this nodejs application so that I can put it on my website and users will be able to interact with it now thankfully Gemini is actually a pretty good coder and we can ask bar to help us rewrite this code let's go to Bard bard. goole.com uh I'm going to go ahead and paste all the code over here and at the very top I'm going to add some instructions I'll say can you modify the code to add a web interface this is a great way to get something like gim and I help you with the code as you can see it has provided me the code and as as instructions on how to set it up I don't want the video to be very long so what I'm going to do is I'm going to go ahead and copy the code that jimini provided me I'll see if it works and then I will improve it and then share the final code with you guys so that you can uh use it on your website or play with it Gemini saved me some time by writing the code for me the code it provided was good it had a very small issue it forgot to include the Json medware here which I fixed and I've also improved it to make it look more attractive I added uh styling to the index uh page and as well as um added loader um I've already created a GitHub repository for this code you can uh access it by going to github.com coding money for/ coding money- chatbot I I've included the installation instruction and as well as I'll include the YouTube url once it's uploaded let's take a look at the final product let's run the code and see it in action no server.js server uh is running on Port 3000 so I'm going to go to Local Host let me start by saying hi the loader is working fine says thanks for reaching out to coding money before I can answer your question I'll need to capture your name an email address can you please provide that information um my name is Ahmed and email address is supercore javain at yahoo.com it's got to verify that email address because that's what I've asked it to do thanks for providing your information Ahmed to verify is your email address super andc Java Man name Ahmed and email address please confirm this information is correct once confirmed I'll be happy to answer your question and provide you with more information about coding money also don't forget to check out our YouTube channel youtube.com/ coding money for more in-depth tutorials and insights we're also on social media so be sure to follow us on uh Facebook okay so it's um it's already started working for me you know the reason I'm outputting the name and email address in this format so that I I can extract the name and email address uh from uh the response put it uh in a database okay I say yes it is correct now you see this is unlike Bard or chat gbt you know I can ask it a specific questions about coding money I cannot ask it other questions we just covered business idea number three from my other video which is called Eight best AI businesses to start using Google gini check out the video if you haven't already this specific video was requested in the comment section by one of my subscribers Enrique Montero 74 I read all of the comments and I'd love to hear your thoughts feel free to share your ideas for upcoming videos if you don't have any question or suggestion you can support my work by just typing coding money in the comments this really helps with the YouTube algorithms if you found this video useful a thumbs up would be highly appreciated stay tuned for exciting new videos to ensure you don't miss out please subscribe and hit the notification Bell until next time thank you for watching watching
Info
Channel: Coding Money
Views: 29,099
Rating: undefined out of 5
Keywords: ai, chatbot, gemini api, node js, ai studio, custom ai, personalized chatbot, artificial intelligence, tutorial, how to, llm, google gemini, gemini ai, google ai studio, gemini coding, artificial intelligence course, ai chatbot, chatbot tutorial, ai for business, openai, gpt4, chatgpt, nodejs, chatbot using gemini api, generative ai coding, google ai studio tutorial, gemini api integration, google gemini coding, ai code generator, how to train chatgpt, gemini api project
Id: _HNMEGkjzsE
Channel Id: undefined
Length: 16min 30sec (990 seconds)
Published: Tue Jan 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.