OpenAI Assistants API ๐Ÿคฏ Function Calling + Node.js ๐Ÿš€ How to get started? AMAZING!! (Full Tutorial)

Mervin Praison ยท Beginner ยท๐Ÿง  Large Language Models ยท2y ago

Key Takeaways

Enhances OpenAI Assistants API with Node.js function calling to integrate real-time stock data from Yahoo Finance into the application

Full Transcript

this is huge what if you can add function calling to your assistant's API what if you can integrate that in your nodejs application that's exactly what we're going to see today let's get [Music] started hi everyone I'm really excited to show you about assistance API with function calling in a node.js application I'm going to take you through step by step on how to run this and code yourself before going into that I regularly create videos in regards to artificial intellig so do subscribe and stay tuned coming to assistant API the first step is create your assistant that is data analyst next you're creating a thread third you're creating a message finally you're running the code with custom instructions I have already covered this in the previous video which I will link that in the description below so it basically contains assistant thread and then we create a message then we run it message is when the user asks question to the data analyst now we're going to run this code without fun function calling the question we going to ask the data analyst is what is the stock price of Apple that is the message now we're going to run this code in your terminal note function calling. JS you can see the status is queued now now the status got completed and we got the answer here assistant I'm sorry mvin praison but I don't have the capability to provide a real-time stock market data or updates Chad GPT doesn't have the capability to get the realtime stock price this is when the function calling comes in function calling is nothing but a function or a software or a tool which can be integrated with assistant API imagine you have a function which gets the stocks price in real time now we are going to see how we are going to integrate that with this application I'm going to use Yahoo finance to get the realtime stock price so it's npm install yaho iPhone Finance 2 and click enter going back to the code you are importing Yahoo finance from Yahoo finance 2 we going to create Asing function with get stock price and pausing the symbol as the parameter and it Returns the real-time stock price now we're going to integrate this function in assistant API using function calling to do that first we going to create tools list constant tools equals and then you're adding the list here you're mentioning type is function and the function name is get stock price that's what we defined previously then we are providing the parameters that is the symbol and symbol is the only required parameter now we're going to pause this tool when weate create an assistant so tools equals tools we have done two things one is creating a function called get stock price and then we created a tools list and added that to the assistants create function if you see the list of steps without function calling there are four steps but when you add function calling you're adding one more step which is requires action now we're going to add this in the code in the code while checking the status of the run here we mention completed there is one more status called required action I'm going to add that else if run status. status equals requires action then console.log requires action just for our reference then constant required actions equals run status. required action do submit tool outputs. tool calls this is where you retrieve your required actions and now we're going to print the required actions and now we're going to run the code in your terminal note function calling. Js first it get cued the status then here the status becomes requires action and you can see there's a Json called required action and we are printing the required action here the required action constant contains a function get stock price and the symbol AAPL so this symbol need to go into get stock price and we need to return that back to assistant API this Loop will keep on continuing until we return the stock price so I'm going to cancel this one and going back to the code I'm going to Define let tools output equals to a list then I'm going to Loop through this required action for constant action of required action opening the bracket constant function name equals action do function. name which you can see here the action. function. name next we going to get action. function. arguments that's where you'll have the symbol AAPL function arguments equals action do function. arguments now we're going to pass this Json because that is a Json output IF function name equals get stock price constant output equals await get stock price and passing the symbol next Tool output. Push tool call id action. id comma output colon json. stringify output now closing the brackets else console.log unknown function and closing the overall bracket now we got the tools output with the required stock price now we need to return that back to assistant API that is the final step the way we do it is await open ai. beta. threads. runs do submit tool outputs you're passing the thread ID run ID and the tools output this we can consider as the final fifth step that's it we checked if the status is requires action then we par the required action output check if the function is get stock price run the function and then we finally return the tools output back to submit tools output now we're going to run this code in your terminal node function calling. JS now the status got cued now we can see the status requires action then we are parsing this Json which contains this function and the parameter now our function is running which is yahooo finance and finally the status completed and we got a response here as a user we asked what is the stock price of Apple and the assistant replied the stock price of Apple is 1 8744 USD that's it as simple as that now you are able to integrate any function in your assistant API using function calling there is one more thing I want to tell you if you want me to present your work or your code like this do submit your code in the URL shown in the screen m.v n/s submit work I'm going to create more videos in regards to assistant API so stay tuned I hope you like this video do like share and subscribe and thanks for watching

Original Description

๐ŸŒŸ Learn how to enhance your assistant's API using Node.js function calling! ๐Ÿš€ Discover the steps to integrate real-time stock data from Yahoo Finance into your application. ๐Ÿ‘จโ€๐Ÿ’ป Step-by-step guide to creating functions, managing tool lists, and handling API statuses. ๐Ÿ“ˆ Example: Querying Apple's stock price with your assistant. โš™๏ธ Troubleshooting tips and in-depth code walkthrough. ๐Ÿ”” Subscribe for more AI and Node.js tutorials! Timestamps: 0:00 - Function Calling in Assistant API with Node.js 1:00 - Example Query: Apple Stock Price 1:31 - Integrating Yahoo Finance for Real-Time Data 2:06 - Coding Tutorial: Adding Function to Assistant API 3:00 - Handling 'Requires Action' Status in API 4:01 - Outputting Stock Price and Final Integration Steps 5:33 - Final Run: Getting Real-Time Stock Price ๐Ÿ”— Previous Video Link: ChatGPT Tutorials Playlist: https://www.youtube.com/playlist?list=PLYQsp-tXX9w62Lgpvx2JMBvKAAi7rfb_t ChatGPT Beginners Guide: https://www.youtube.com/watch?v=_E9rqrnPzWI GPT-4 Assistants API + Python: https://www.youtube.com/watch?v=pZUDEQs89zc GPT-4 Assistants API +Node: https://www.youtube.com/watch?v=CPlwcY5mQ_4 OpenAI Assistants API + Retrieval: https://www.youtube.com/watch?v=Wh727dL-Ql4 OpenAI Assistants API Function Calling: https://www.youtube.com/watch?v=UkLUSjOneXc GPT-4 Turbo: https://www.youtube.com/watch?v=Fo0KEPP7Nt4 GPT-4 Seed: https://www.youtube.com/watch?v=q5o8n1_jQb4 GPT-4 JSON: https://www.youtube.com/watch?v=9FZSA2UzXL0 ChatGPT Text to Speech API: https://www.youtube.com/watch?v=LWfE-j_V2J0 Dall-e 3 API: https://www.youtube.com/watch?v=eKCLFY5_NZI Whisper API: https://www.youtube.com/watch?v=B9AuQ3jpwrA GPT-4 Vision API Image: https://www.youtube.com/watch?v=xtdQb7-bv7E GPT-4 Vision API Video: https://www.youtube.com/watch?v=QyqnR3bBMDs Code: https://mer.vin/2023/11/assistants-api-function-calling-in-node-js/ Submit Work: https://mer.vin/submitwork/ #OpenAIAssistantsAPI, #AssistantsAPI, #NodejsAssistantsAPI, #Nodejs, #NodeJ
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Playlist

Uploads from Mervin Praison ยท Mervin Praison ยท 0 of 60

โ† Previous Next โ†’
1 Build GCP Infra using Pulumi in YAML format
Build GCP Infra using Pulumi in YAML format
Mervin Praison
2 How to Convert a Pulumi YAML File to Python Format
How to Convert a Pulumi YAML File to Python Format
Mervin Praison
3 Speed Up AWS EKS: A Complete Guide to Performance Tuning & Debugging!
Speed Up AWS EKS: A Complete Guide to Performance Tuning & Debugging!
Mervin Praison
4 Learn GCP GKE to AWS EKS Migration in Just 5 Minutes: Quick Guide
Learn GCP GKE to AWS EKS Migration in Just 5 Minutes: Quick Guide
Mervin Praison
5 AWS & Kubernetes: The Definitive Guide to Data Persistence with PV and PVC
AWS & Kubernetes: The Definitive Guide to Data Persistence with PV and PVC
Mervin Praison
6 ChatGPT Voice Conversation RELEASED! It's AMAZING!! (Demo)
ChatGPT Voice Conversation RELEASED! It's AMAZING!! (Demo)
Mervin Praison
7 How to Install Mistral 7B in Minutes: Quick & Easy Guide! โœ…
How to Install Mistral 7B in Minutes: Quick & Easy Guide! โœ…
Mervin Praison
8 Code Llama Install Locally: ๐Ÿ๐Ÿ’ป Elevate Your Python Skills!
Code Llama Install Locally: ๐Ÿ๐Ÿ’ป Elevate Your Python Skills!
Mervin Praison
9 Orca Mini: Your Ultimate Guide to Install and Test on Mac & Linux ๐Ÿ’ป
Orca Mini: Your Ultimate Guide to Install and Test on Mac & Linux ๐Ÿ’ป
Mervin Praison
10 Quick & Easy Vicuna Setup on Mac and Linux ๐Ÿ’ป
Quick & Easy Vicuna Setup on Mac and Linux ๐Ÿ’ป
Mervin Praison
11 Quick Guide: Llama2 Local Installation and ChatGPT with pip! Python๐Ÿ› ๏ธ
Quick Guide: Llama2 Local Installation and ChatGPT with pip! Python๐Ÿ› ๏ธ
Mervin Praison
12 Query PDFs Like a Pro with Local GPT: Full Setup Guide! ๐Ÿ“œ
Query PDFs Like a Pro with Local GPT: Full Setup Guide! ๐Ÿ“œ
Mervin Praison
13 LM Studio: EASIEST way to Run Large Language Models Locally!
LM Studio: EASIEST way to Run Large Language Models Locally!
Mervin Praison
14 AMAZING ChatGPT Vision is OUT! ๐Ÿคฏ 14+ Examples (Step-by-Step) FULL Tutorial
AMAZING ChatGPT Vision is OUT! ๐Ÿคฏ 14+ Examples (Step-by-Step) FULL Tutorial
Mervin Praison
15 Unbelievable! Build ANY App Instantly with Smol AI! ๐Ÿ˜ฒ๐Ÿ”ฅ
Unbelievable! Build ANY App Instantly with Smol AI! ๐Ÿ˜ฒ๐Ÿ”ฅ
Mervin Praison
16 Amazing! AutoGen Made Easy: A Step-by-Step Beginners Guide ๐Ÿ“š
Amazing! AutoGen Made Easy: A Step-by-Step Beginners Guide ๐Ÿ“š
Mervin Praison
17 How to Set Up LoLLMS and Run LLMs Locally! ๐Ÿš€ Step-by-Step Tutorial
How to Set Up LoLLMS and Run LLMs Locally! ๐Ÿš€ Step-by-Step Tutorial
Mervin Praison
18 GPT4All: INSANE Way to Run Large Language Models Locally! ๐Ÿ˜ฒ Step-By-Step Tutorial
GPT4All: INSANE Way to Run Large Language Models Locally! ๐Ÿ˜ฒ Step-By-Step Tutorial
Mervin Praison
19 Incredible AI-Powered NPCs in Unity Game Engine: Step by Step Tutorial!๐Ÿคฏ
Incredible AI-Powered NPCs in Unity Game Engine: Step by Step Tutorial!๐Ÿคฏ
Mervin Praison
20 MemGPT ๐Ÿง  LLM as Operating System. It's INSANE! Step-by-Step Tutorial ๐Ÿคฏ
MemGPT ๐Ÿง  LLM as Operating System. It's INSANE! Step-by-Step Tutorial ๐Ÿคฏ
Mervin Praison
21 Text Generation Web UI: MIND-BLOWING Way to Run LLM Locally! ๐Ÿคฏ
Text Generation Web UI: MIND-BLOWING Way to Run LLM Locally! ๐Ÿคฏ
Mervin Praison
22 Unlock the INSANE Power of OpenAI GPT-4 with C#/.NET! ๐Ÿ˜ฒ
Unlock the INSANE Power of OpenAI GPT-4 with C#/.NET! ๐Ÿ˜ฒ
Mervin Praison
23 Integrate Langchain and Ollama for Local AI Power ๐Ÿคฏ Indeed POWERFUL!
Integrate Langchain and Ollama for Local AI Power ๐Ÿคฏ Indeed POWERFUL!
Mervin Praison
24 ChatDev: INSANE Virtual AI Agents! Future of Software Development ๐Ÿ˜ฒ
ChatDev: INSANE Virtual AI Agents! Future of Software Development ๐Ÿ˜ฒ
Mervin Praison
25 Query PDFs Using Mistral: Unlock INSANE Power! ๐Ÿคฏ
Query PDFs Using Mistral: Unlock INSANE Power! ๐Ÿคฏ
Mervin Praison
26 AutoGen + Open-Source LLMs: UNBELIEVABLE! Step-by-Step Tutorial You Can't Miss! ๐Ÿคฏ
AutoGen + Open-Source LLMs: UNBELIEVABLE! Step-by-Step Tutorial You Can't Miss! ๐Ÿคฏ
Mervin Praison
27 AutoGen + Text Generation WebUI: Unbelievable 100% Local Private Setup ๐Ÿคฏ
AutoGen + Text Generation WebUI: Unbelievable 100% Local Private Setup ๐Ÿคฏ
Mervin Praison
28 MemGPT: Amazing! External Context for LLM #ai #llm #memgpt  #generativeai #mem #gpt #openai #chatgpt
MemGPT: Amazing! External Context for LLM #ai #llm #memgpt #generativeai #mem #gpt #openai #chatgpt
Mervin Praison
29 GeniA: Kubernetes + AI for MIND-BLOWING Operational Efficiency! ๐Ÿคฏ FULL Tutorial
GeniA: Kubernetes + AI for MIND-BLOWING Operational Efficiency! ๐Ÿคฏ FULL Tutorial
Mervin Praison
30 VertexAI Meets LangChain for Mind-Blowing AI Conversations! ๐Ÿ˜ฒ Step by Step Tutorial
VertexAI Meets LangChain for Mind-Blowing AI Conversations! ๐Ÿ˜ฒ Step by Step Tutorial
Mervin Praison
31 Simplified ChatGPT API Setup on Node.js for Newbies! ๐Ÿ˜ Step by Step Tutorial
Simplified ChatGPT API Setup on Node.js for Newbies! ๐Ÿ˜ Step by Step Tutorial
Mervin Praison
32 Autogen: Ollama integration ๐Ÿคฏ Step by Step Tutorial. Mind-blowing!
Autogen: Ollama integration ๐Ÿคฏ Step by Step Tutorial. Mind-blowing!
Mervin Praison
33 LiteLLM: One-Function Call to ANY Large Language Model! ๐Ÿคฏ UNBELIEVABLE!
LiteLLM: One-Function Call to ANY Large Language Model! ๐Ÿคฏ UNBELIEVABLE!
Mervin Praison
34 ChatGPT Chatbot in Less Time Than You Think! ๐Ÿš€๐Ÿ˜Ž Step-by-Step Tutorial
ChatGPT Chatbot in Less Time Than You Think! ๐Ÿš€๐Ÿ˜Ž Step-by-Step Tutorial
Mervin Praison
35 LiteLLM Chatbot: Build Your Own in MINUTES! INSANE! ๐Ÿค–๐Ÿ”ฅ
LiteLLM Chatbot: Build Your Own in MINUTES! INSANE! ๐Ÿค–๐Ÿ”ฅ
Mervin Praison
36 Create Chatbot: Turn ANY Open-Source LLM into a Conversation Pro! ๐Ÿค–
Create Chatbot: Turn ANY Open-Source LLM into a Conversation Pro! ๐Ÿค–
Mervin Praison
37 Create Chatbot: Ollama Integration Made UNBELIEVABLY Easy! ๐ŸŽ‰
Create Chatbot: Ollama Integration Made UNBELIEVABLY Easy! ๐ŸŽ‰
Mervin Praison
38 LlamaIndex + ChatGPT: Ingest Data and Experience UNBELIEVABLE Query Results! ๐ŸŒŸ
LlamaIndex + ChatGPT: Ingest Data and Experience UNBELIEVABLE Query Results! ๐ŸŒŸ
Mervin Praison
39 INSANE! OpenAgents: Automated Data Analysis with Kaggle ๐Ÿคฏ
INSANE! OpenAgents: Automated Data Analysis with Kaggle ๐Ÿคฏ
Mervin Praison
40 React.js LLM Agent for Next-Gen Coding using ChatGPT ๐Ÿš€ Mind-Blowing ๐Ÿคฏ
React.js LLM Agent for Next-Gen Coding using ChatGPT ๐Ÿš€ Mind-Blowing ๐Ÿคฏ
Mervin Praison
41 MemGPT + Any LLM ๐Ÿš€ 100% Local & Private Integration Unveiled! Unlimited Memory
MemGPT + Any LLM ๐Ÿš€ 100% Local & Private Integration Unveiled! Unlimited Memory
Mervin Praison
42 MemGPT  + AutoGen ๐Ÿง ๐Ÿค– Unlimited Memory & Autonomous AI Agents! INSANE๐Ÿคฏ
MemGPT + AutoGen ๐Ÿง ๐Ÿค– Unlimited Memory & Autonomous AI Agents! INSANE๐Ÿคฏ
Mervin Praison
43 AutoGen + Google's Palm LLM & More! Revolutionary AI Integration ๐Ÿš€
AutoGen + Google's Palm LLM & More! Revolutionary AI Integration ๐Ÿš€
Mervin Praison
44 MemGPT & LM Studio Integration Revealed! ๐Ÿ”ฅ Next-Level AI
MemGPT & LM Studio Integration Revealed! ๐Ÿ”ฅ Next-Level AI
Mervin Praison
45 ๐Ÿš€ AutoLLM: Unlock the Power of 100+ Language Models! Step-by-Step Tutorial
๐Ÿš€ AutoLLM: Unlock the Power of 100+ Language Models! Step-by-Step Tutorial
Mervin Praison
46 AutoLLM & Gradio Integration You Won't Believe! ๐Ÿคฏ Mind-Blowing
AutoLLM & Gradio Integration You Won't Believe! ๐Ÿคฏ Mind-Blowing
Mervin Praison
47 AutoLLM & FastAPI Tutorial: Query 100+ Language Models! ๐Ÿ˜ฑ
AutoLLM & FastAPI Tutorial: Query 100+ Language Models! ๐Ÿ˜ฑ
Mervin Praison
48 Quivr: LLM's Second Brain - Transforming Data Management & Advanced Query with AI! ๐Ÿคฏ
Quivr: LLM's Second Brain - Transforming Data Management & Advanced Query with AI! ๐Ÿคฏ
Mervin Praison
49 AutoGen & MemGPT with Local LLM: A Complete Setup Tutorial! ๐Ÿง  AMAZING ๐Ÿคฏ
AutoGen & MemGPT with Local LLM: A Complete Setup Tutorial! ๐Ÿง  AMAZING ๐Ÿคฏ
Mervin Praison
50 LocalAI: Free, Open Source OpenAI Alternative ๐Ÿš€ INSANE ๐Ÿคฏ Step-by-Step Tutorial
LocalAI: Free, Open Source OpenAI Alternative ๐Ÿš€ INSANE ๐Ÿคฏ Step-by-Step Tutorial
Mervin Praison
51 Yarn Mistral 7B 128k LARGE context window, Small size ๐Ÿคฏ INSANE ๐Ÿš€ Setup Tutorial!
Yarn Mistral 7B 128k LARGE context window, Small size ๐Ÿคฏ INSANE ๐Ÿš€ Setup Tutorial!
Mervin Praison
52 Zephyr-7B: The Small and Mighty LLM ๐Ÿคฏ Step by Step Tutorial! ๐Ÿ“˜
Zephyr-7B: The Small and Mighty LLM ๐Ÿคฏ Step by Step Tutorial! ๐Ÿ“˜
Mervin Praison
53 Promptfoo: How to Test Your LLM ? ๐Ÿš€  VERY EASY!
Promptfoo: How to Test Your LLM ? ๐Ÿš€ VERY EASY!
Mervin Praison
54 Pydantic: How to Validate LLM Responses? ๐Ÿš€ Quality Response. VERY EASY!!!!
Pydantic: How to Validate LLM Responses? ๐Ÿš€ Quality Response. VERY EASY!!!!
Mervin Praison
55 Pydantic: FORCE Your AI to Respond Back in UPPERCASE! ๐Ÿคฏ Step-by-Step Tutorial ๐Ÿ”ฅ
Pydantic: FORCE Your AI to Respond Back in UPPERCASE! ๐Ÿคฏ Step-by-Step Tutorial ๐Ÿ”ฅ
Mervin Praison
56 Pydantic: How to use LLM to convert unstructured data to structured data?
Pydantic: How to use LLM to convert unstructured data to structured data?
Mervin Praison
57 AutoGen Function Calling: INSANE ๐Ÿš€ Custom Integrations! Step-by-Step Tutorial ๐Ÿคฏ
AutoGen Function Calling: INSANE ๐Ÿš€ Custom Integrations! Step-by-Step Tutorial ๐Ÿคฏ
Mervin Praison
58 OpenAI Assistants API + Python ๐Ÿค– How to get started? (FULL Tutorial) ๐Ÿคฏ INSANE
OpenAI Assistants API + Python ๐Ÿค– How to get started? (FULL Tutorial) ๐Ÿคฏ INSANE
Mervin Praison
59 GPT-4 Vision API ๐Ÿคฏ INSANE Video Recognition Powers! Step-by-Step Tutorial ๐Ÿš€
GPT-4 Vision API ๐Ÿคฏ INSANE Video Recognition Powers! Step-by-Step Tutorial ๐Ÿš€
Mervin Praison
60 GPT-4 Vision API ๐Ÿš€ The Future of Image Recognition! ๐Ÿคฏ Step-by-Step Tutorial
GPT-4 Vision API ๐Ÿš€ The Future of Image Recognition! ๐Ÿคฏ Step-by-Step Tutorial
Mervin Praison

Related Reads

๐Ÿ“ฐ
I Added Observability to My AI PR Agent and It Was Silently Failing the Whole Time
Add observability to AI-powered tools to detect silent failures, as seen in an AI PR agent using Groq's Llama 3.3
Medium ยท Python
๐Ÿ“ฐ
Anthropic Academy: Free AI Courses With a Certificate, Straight From the Maker of Claude
Get free AI courses with a certificate from Anthropic Academy, the maker of Claude AI, to enhance your AI skills and knowledge
Medium ยท AI
๐Ÿ“ฐ
The Machine Accent Travels: AI Text Is Rhythmically Monotone in 70/70 Cells Across 3 Languages
Discover how AI-generated text has a rhythmically monotone pattern across languages, and why this matters for natural language processing
Dev.to AI
๐Ÿ“ฐ
SynapseAI: What Happened When I Stopped Trusting Just One LLM
Learn how to stop relying on a single LLM and explore alternative AI models for more accurate results
Medium ยท LLM

Chapters (7)

Function Calling in Assistant API with Node.js
1:00 Example Query: Apple Stock Price
1:31 Integrating Yahoo Finance for Real-Time Data
2:06 Coding Tutorial: Adding Function to Assistant API
3:00 Handling 'Requires Action' Status in API
4:01 Outputting Stock Price and Final Integration Steps
5:33 Final Run: Getting Real-Time Stock Price
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch โ†’