OpenAI Assistant Function Calling Tutorial For Beginners (App With Source Code Included)

  Рет қаралды 7,864

codewithbrandon

codewithbrandon

Күн бұрын

Welcome to this OpenAI Assistant API Function Calling tutorial. If you're interested in AI and web development, this video is for you.
Source Code:
brandonhancock.io/openai-func...
Resources:
- platform.openai.com/docs/assi...
- platform.openai.com/docs/assi...
- platform.openai.com/docs/guid...
- finnhub.io/docs/api/stock-sym...
Timestamps
00:00 Introduction
00:30 What is function calling + Use Cases
02:05 Quick Assistant Crash Course
04:51 Assistant Run Life Cycles
08:34 High Level Code Overview
10:04 Assistants - Code Deep Dive
15:52 Threads - Code Deep Dive
17:56 Messages - Code Deep Dive
22:44 Runs - Code Deep Dive
26:40 Function Calling [IMPORTANT]
33:34 Code Recap
34:51 Outro

Пікірлер: 29
@beetz12
@beetz12 27 күн бұрын
Thanks for the fantastic tutorial Brandon. I watched 5 other videos to learn function calling and this was hands down the best explanation! And I appreciate you providing the code for testing your assistant. If I hadn't come across your video, I would have written one myself. You saved me at least 5+ hours!
@maximusmadman
@maximusmadman 2 ай бұрын
Excellent Tutorial
@romanbolshiyanov
@romanbolshiyanov 10 күн бұрын
i thinks it is a bast ai channel, thanks
@Thatswhatshesaidnumberone
@Thatswhatshesaidnumberone 3 ай бұрын
A big thank you for the great tutorial, and excellent working code.
@bhancock_ai
@bhancock_ai 3 ай бұрын
Hey Rushy! The next full stack video I'm going to work on will have some stateful processing and event-driven architecture so I think you'll really like it! Soon, I will be releasing more info about the next full stack tutorial I'm making for you guys!
@owaisjavaid8110
@owaisjavaid8110 4 ай бұрын
Really appreciate the effort you put into the box so anyone can find out the what they are looking inside if the box. Can you add more details of the usage and pricing related stuff so we can have an eagle eye overview as well, and we can actually make it useful for any business solution.
@bhancock_ai
@bhancock_ai 3 ай бұрын
Hey Owais! Great question! If I were you, I'd checkout this page here: openai.com/pricing The short answer to your question is that OpenAI is going to charge your everything. Every time you use ChatGPT 4, it costs you a few pennies.When you use the code interpreter, it costs a few more pennies. When you use the retrieval functionality, it costs a few more pennies.
@carloseduardolandeiraribei5302
@carloseduardolandeiraribei5302 2 ай бұрын
Thanks for this, just one question, what if the message is too long and exceeds URI length limit when setting a message to a thread?
@mingchi21
@mingchi21 2 ай бұрын
Very good explanation, I have a question, can the API remember the context? For example: User=>Hey what is the price of tesla? Resp=>The price is ... User=>How about Apple? Resp=>The price is ... User=>Google? Resp=>The price is ...
@RoniBliss
@RoniBliss 4 ай бұрын
The concept I don't understand yet is, I get the coding part, but say I have a [ search_web ] Python code, where would I host that code so the Assistant can call it? Then let's say I have the code hosted, and I go over to the OpenAI assistants dashboard > under functions say I have a function with Name: [ search_web ] (3:28 in your video)and I hit the test button. How does the Assistant know where my hosted Python code is? There is no endpoint set up there? Im so confused on this part. Its the last piece of the puzzle for me. Your help would be so greatly appreciated!
@normanhome7017
@normanhome7017 2 ай бұрын
Hi Brandon a big thanks for the video I have same questions similar to one of the comments which you did not answer can you please answer it thanks. The following is the question Can the API remember the context? For example: User=>Hey what is the price of tesla? Resp=>The price is ... User=>How about Apple? Resp=>The price is ... User=>Google? Resp=>The price is ...
@AlphasoundSchool
@AlphasoundSchool 5 ай бұрын
Thanks for your content bro! I wonder if there is a way to create the assistant using server actions instead of api?
@bhancock_ai
@bhancock_ai 5 ай бұрын
Hmmmm great question! You should definitely be able to create the assistant using only server actions. I think this article will show you how to start using server functions instead of the api calls in the video: auth0.com/blog/amp/using-nextjs-server-actions-to-call-external-apis/
@AlphasoundSchool
@AlphasoundSchool 4 ай бұрын
@@bhancock_ai Thank you! I will check it out 😄
@pkundr
@pkundr 3 ай бұрын
Hey, thanks for this great tutorial! One question I have is why do we need to pass the stock data back to the assistant? In your example, the objective is to show the user the stock prices he requested. Once the Assistant sends us the stock tickers, we can already do so by calling the finance API. Why is it necessary to inform the Assistant about the prices?
@bhancock_ai
@bhancock_ai 3 ай бұрын
Great question Phillip! This confused me too at first. The reason we need to pass back the stock prices to the Assistant is because we want to complete our `runs`. If we didn't pass back the results to our run, the run would eventually time out because they waited on us too long to give them the information they needed to complete. Here's what the OpenAI docs say about the requires_action state: When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. If you want to check out the full webpage, you can see it here: platform.openai.com/docs/api-reference/runs/submitToolOutputs I hope that helps!
@JonathanPohlner
@JonathanPohlner 5 ай бұрын
do I need to clear cookies? how do I get the new code if I already got the code from a previous video?
@bhancock_ai
@bhancock_ai 5 ай бұрын
Hey! I just shot you an email with more info!
@Aaron-md2eo
@Aaron-md2eo 7 күн бұрын
Great tutorial! Would you (or anyone else) have an idea how to handle sequential function calls where the 2nd function call requires the results of the first one? For example, if you integrate an assistant with a calendar API and you tell it to delete your 2 o'clock appointment. It would first need to list your events (function call 1) and then delete the event (function call 2) with the event ID retrieved from the first call.
@codewitheric8800
@codewitheric8800 3 күн бұрын
i need this too, did you find any solutions?
@bhancock_ai
@bhancock_ai Күн бұрын
I would use LangGraph to achieve what you’re trying to do. LangGraph allows you to manage state and do operations in a sequential manner like you’re trying to do! I have a video on my channel so I definitely recommend trying that out!
@bhancock_ai
@bhancock_ai Күн бұрын
Hey Eric! Please check out the comment I added on this thread for Eric to see my suggestion!
@Aaron-md2eo
@Aaron-md2eo Күн бұрын
​@@bhancock_ai @codewitheric8800 Thanks, that's an awesome approach. For my use case, however, I managed to find a simpler solution. You can actually achieve this by using prompting (ideally both in the assistant instructions and in the function call descriptions), believe it or not. I had a little problem where the EventHanlder was not correctly initialized in the submit tool outputs function. If the loop is handled correctly, it should re-enter the requires action run state after submitting the outputs from the first function call and can call the next function based on the results from the first function call outputs. You can test this first in the playground with clear instructions to call functions sequentially and then provide some mock data for the tool outputs. This is a really powerful tool, I think. I'm working an a general AI assistant which I hooked up to Google Mail, Calendar, Tasks, Contacts, Drive, and also services for sending texts and placing phone calls on the user's behalf along with some other basic stuff like google search, news and weather. If you get it right, the assistant can intelligently decide which functions to call for almost any prompt, and in any order. For example, you can tell it to make reservations at the restaurant XYZ and it will first look up the phone number of the restaurant using google search, place the call to make the reservations, and then finally, add it to your calendar, all in one response based on one simple prompt. This works for plenty of other use cases for handling emails, calendars, and so on as well. 🙃
@Ourworldbyade
@Ourworldbyade 4 ай бұрын
I signed up for your code resource but it's not sending me the email. Thanks!
@bhancock_ai
@bhancock_ai 4 ай бұрын
Hey! I apologize that it didn't get sent to you. Could you please check your spam folder because I know a few people have experienced that issue in the past. If it's not there, could you DM me your email on X or email me at brandon@brandonhancock.io and I'll be sure to get it over to you!
@eliskucevic340
@eliskucevic340 Ай бұрын
Why cant you just share the source code? Why do i have to sign up for it? Enough with the email farming.
@DevNieriDantas
@DevNieriDantas 5 күн бұрын
ingrato
@clamhammer2463
@clamhammer2463 3 ай бұрын
Once I saw next.js I stopped watching. Not everything should be made with react/next etc...
@DevNieriDantas
@DevNieriDantas 5 күн бұрын
pense fora da caixa e replique pro seu cenário!!! voce não é o sol, o mundo nao gira ao seu redor
OpenAI Assistant API Tutorial With Code Examples
21:52
codewithbrandon
Рет қаралды 18 М.
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 52 МЛН
GPT4o + CrewAI: Twice as fast? Half the Cost?
13:30
codewithbrandon
Рет қаралды 12 М.
CrewAI Tutorial: Complete Crash Course for Beginners
1:05:43
codewithbrandon
Рет қаралды 135 М.
LangGraph + CrewAI: Crash Course for Beginners [Source Code Included]
53:34
OpenAI GPT-4 Function Calling: Unlimited Potential
23:49
sentdex
Рет қаралды 226 М.
LangChain Explained in 13 Minutes | QuickStart Tutorial for Beginners
12:44
GPTs vs Assistants API - which one is best for you?
13:09
How to AUTOMATE LINKEDIN POSTS with CrewAI | CrewAI Tutorial
22:39
The Neural Maze
Рет қаралды 5 М.
GPT function calling in a nutshell
15:36
Henrik Kniberg
Рет қаралды 35 М.
Fullstack NextJS & CrewAI Crash Course For Beginners [Source Code Included]
2:49:27
Huawei который почти как iPhone
0:53
Romancev768
Рет қаралды 618 М.
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 387 М.