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!
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.
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.
This was an absolutely awesome explanation and just what I was looking for! Any plans for something with Vercel AI SDK to build generative UI? Started exploring the useAssistant hook they have and seems pretty awesome so far.
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!
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 ...
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.
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 @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. 🙃
Awesome content man! Have any tutorials allowing us to do this from functions from within open ai assistants directly out to sources and back, removing the need for these manual inputs? Example, Open AI, with ability to call to Dumpling AI and web scrape vs call to a native API?
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?
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!
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 ...
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/
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!
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!
Excellent Tutorial
i thinks it is a bast ai channel, thanks
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.
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.
This was an absolutely awesome explanation and just what I was looking for! Any plans for something with Vercel AI SDK to build generative UI? Started exploring the useAssistant hook they have and seems pretty awesome so far.
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!
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 ...
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.
i need this too, did you find any solutions?
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!
Hey Eric! Please check out the comment I added on this thread for Eric to see my suggestion!
@@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. 🙃
Awesome content man! Have any tutorials allowing us to do this from functions from within open ai assistants directly out to sources and back, removing the need for these manual inputs? Example, Open AI, with ability to call to Dumpling AI and web scrape vs call to a native API?
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?
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!
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 ...
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?
😂😂😂 When people just give the sec code I really feel like I have to subescribe and leave a star
Thanks for your content bro! I wonder if there is a way to create the assistant using server actions instead of api?
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/
@@bhancock_ai Thank you! I will check it out 😄
do I need to clear cookies? how do I get the new code if I already got the code from a previous video?
Hey! I just shot you an email with more info!
I signed up for your code resource but it's not sending me the email. Thanks!
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!
Why cant you just share the source code? Why do i have to sign up for it? Enough with the email farming.
ingrato
Once I saw next.js I stopped watching. Not everything should be made with react/next etc...
pense fora da caixa e replique pro seu cenário!!! voce não é o sol, o mundo nao gira ao seu redor