
In this video I am introducing the new FunctionChain which is a no-dependency Node.js library to get up and running with using the new OpenAI Function Calling feature. https://github.com/developersdigest/FunctionChain
--- type: transcript date: 2023-06-29 youtube_id: jmrFG7n3Nt8 --- # Transcript: FunctionChain: OpenAI Function Calling Simplified in Node.js in this video I'm going to be showing you function chain so function chain is a tool that I built to make interacting with the new openai function calling feature in node.js super simple so the way that this works is you simply need to import the library you need to point the directory of where your functions that you have that you want to use within your application are and then from there you can within one line specify the query that you have that you want to have the function call invoked on so as you see in this example there's three different examples so one's getting the latest price of Bitcoin so it's going to reach out uh to a free API that doesn't need an API key and it's going to get that and then with the same function it's going to get the price of ethereum but then in between you see there's also the ability to control aspects of your computer so this is opening up the calculator app as a small example so finally within example three there you do see that there is the functions array so say if you have a folder of 50 functions and you only want to use say two there is that ability where you can specify you only want certain functions to be passed for that particular invocation so just to get into this what I'm going to be covering I'm going to be showing you how to install this how to set it up and then finally how to actually add your custom functions here so this will just take a few minutes to get set up but without further Ado let's get going so first we're just going to go to the repository and actually just pull it down here so we're going to head over to vs code I'm going to paste this within my vs code and then I'm going to go into the directory here so once you're within the directory you can go ahead and npm install and then from there we're going to go to our DOT EnV and then just remove example from it and now within our DOT EnV you can head over to the openai website and get an API key I already have one super simple make an account you'll get some credits for free off the bat you don't need a ton of credit card if you haven't used their API yet and then from there we can open up our index.js which is the same file that you saw in the GitHub repository there so we'll go ahead and run this we can npm run Dev and you can see just like that it's going to go ahead and start to query the llm for what you're asking so you can see here okay the calculator has been open successfully the price of Bitcoin is ETC so that's pretty much it to get it up and running but the one thing that you will or are going to have to do is as you add your own functions is scaffold out this directory so you can add simply add the function file that you have encapsulated within its own file within this directory and all you have to do is follow the structure so there there's a similar structure that you can see within both of these and I'll just run through it quickly here so the first thing is if you have any dependencies so in this example I have a dependency the other one doesn't just say import your dependency as you typically would then what you'll have to do is you'll have to wrap your function code within this execute function and then for your details of the mapping of what your function actually does for the llm so the description of the function itself the description of the arguments whether it's a string or an object or a number all of that good stuff you can put within the details so these are just a couple small examples of how to set this up and if you just follow this simple structure wrap it with an execute put the details of the function within this object here you should be off and running so that's really it to get this up and running if you have any ideas or suggestions open an issue or a pull request to the repository but otherwise if you found this video useful 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.