Get set up and running quick using babyagi + langchain in javascript (node.js)
--- type: transcript date: 2023-05-01 youtube_id: qXnUWj-n2aw --- # Transcript: BabyAGI, Langchain, JavaScript: Quickstart Guide in this video I'm going to show you how to set up baby AGI with Lang chain in node.js in just a few minutes so the first thing that we're going to do is we're going to head over to the openai website so if you haven't made an account already just go over to platform.openai.com once you made an account go to the top right hand corner click view API keys and then from there you'll be on this page simply create a new API key and then copy that into your clipboard so once you've done that we're going to go over to a new project so here I already have some of it initialized but what you're going to do is right off the bat you're going to npm init Dash Y and click enter so that will give you your package Json so once you have your package Json set up just go in there and make sure that you add the type of modules since we're going to be adding Imports so just add this one line here so once we've done that we're going to go ahead and install our dependencies so we're going to npmi dot EnV and line chain so those are going to be the two dependencies that we use for this so once you've done that you're going to make an index.html and a DOT EnV so if you want to do that from the terminal we can just say touch dot EnV and index.js so once we've done that we're going to go into our DOT EnV I'm not going to pull that up on my screen but what you're going to do is you're going to type in all caps open AI underscore API underscore key equals and then paste in that value that you have in your clipboard so once we have that set up we're just going to go into our index.js and the first thing that I'm going to have you do is import the dependencies so as you see here we have dot EnV and then blank chain as well as we're just structuring a couple or a handful of things rather from their Library so we're going to be using the experimental baby AGI implementation that they have we're going to be including the vector stores that we're going to use in memory we're going to be using the embeddings from openai in this example and then we're also going to be leveraging open ai's lln in this example we actually don't need the fs I'll just leave that for now but in case you do want to interact with your file system you can include that as well and then just continue on from this example once uh once you're done here so the first thing that I'm going to have you do is create a new Vector store instance so in this case we're not going to be tying in Pine Cone or any external database we're just going to create the vector store locally in memory so what do I mean by that so instead of actually calling a database or writing to a file to our system we're going to have the vectors and what what do I mean by that if you're not familiar with vectors so vectors are a numerical representation of the relatedness between two words so if you think about a number if you say let's say two zoo animals those would have a higher relay in this presumably than say animals and copy machine for instance so that's a little bit under the hood how this is actually going to work but not a rest on this too long then the next thing that we're going to do is we're just going to create our new baby AGI instance and it's as simple as us so in this case like I mentioned we're going to use open ai's model for this but you can use other models if you want we're going to use our Vector store like we have declared above and like I just talked about and then I'm just going to set the max iterations to five so this is a nice feature or implementation in the library where you can specify okay I only want it to go five iterations of what it's going to do so it doesn't run recursively and you run up some gigantic charge on your API key and whatnot and then from there we're just going to Simply call Baby AGI so in this one I'm going to say return me the temperature in New York today in Celsius so if I just go ahead and go to our terminal here type node index.js we can just ignore this fetch warning here but you'll see right off the bat we say okay it's gonna it's next task is to make a to-do list you can see the task result and we can just watch this for a minute and see see what it generates so it's less about the example of um you know trying to have an impressive example to show you but once you have it you can start to play around with us so a couple things I've noticed is if you put in the objective that you want to have this done in as few tasks as possible I've found that to help speed things up because sometimes even for simple questions it will run through like a very verbose list and a list rather and go through quite a few tasks for something that might seem pretty simple so if I look today we can see okay in New York today that temperature is 26.7 degrees so hopefully you found this useful if you did please like comment share and subscribe and until the next one
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Weekly deep dives on AI agents, coding tools, and building with LLMs - delivered to your inbox.
Free forever. No spam.
Subscribe FreeNew tutorials, open-source projects, and deep dives on coding agents - delivered weekly.