How to Use The GPT-4 API With Function Calling | Your Own ChatGPT Plugins | TypeScript

preview_player
Показать описание
OpenAI just released a massive update to the GPT-3.5 and GPT-4 API's!

Just like you have plugins in ChatGPT, now this functionality is available to all developers. You do it by giving the API a list of functions that it can invoke. Then, the assistant response can either be a direct response or a function cal. You then execute the function, give back the results into another call to GPT and you can use the final result as an natural language response.

In this video I'll show you what changed in the API and how you can use it, in TypeScript.

00:00 - Introduction: What Happened?
00:41 - How It Used To Be
03:17 - Using the updated Chat Completion API
03:49 - New request parameters: functions and function_call
04:33 - The functions array
05:56 - New return value: assistant message with function_call
07:23 - Adding your function results back into the AI
07:58 - Gotcha: Repeating the function_call message
08:59 - Recap
09:58 - Conlusion
Рекомендации по теме
Комментарии
Автор

Wow you are fast, thank you very well explained l subscribed and shared it on reddit!

BrutalStrike
Автор

I really like your style.. calm, clear, concise. Don’t change :)

dynasty
Автор

Brilliant my dear sir! As someone who doesn't code, your way and style of explaining was engaging and helped me understand something I'm not well versed in.  👍🏼

gusdv_
Автор

can you release this brave search gpt thing

sidhys
Автор

hey, thanks for this, helps to untangle all the hype and the buzz there is around this new feature.
Question: Did you try with an actual array of functions and how well did it behave ?
My understanding is that base on the description of the function you're giving and the question your sending, GPT will try to predict which function should be called.
What happens if it can't find any function to call ?
Thanks again for this and any time you'd take to answer this.

MaximeFAYEMaxouMask
Автор

Really good. Would help me if you did a more extensive job of explaining the problem and how it solved it. Very nice, thanks,

sandiegoman
Автор

I got an email saying this works for gpt-4-0613. Question: in playground, I don't understand what the 'System' is for. Why is there a user, then a response, but an assistant on the side? I don't get that.

GershonBenYitzhak
Автор

Interestingly, the assistant seems to just use the function output almost "as is". I'm unable to get the assistant to use the function output as context only and focus on the users actual question...

Example: my function returns all the information about a property, and the assistant seems to just output the whole block of information instead of using it as a context/knowledge base to answer the users question. Nothing I put in the system message affects how the assistant uses the information from the function call.

Any idea how this could be achieved?

matemarschalko
Автор

Very timely, thank you, is this not implementable through python by the way?

CrunchyMind
Автор

Thanks & Superb.Can explain how to use ask pdf plugin through open Ai api?

anjulawijesundara
Автор

7:58 I think that's a problem with the OpenAI library you're using. The Python package allowed me to send the {content: null, function_call: function_name} as a message. Although it didn't allow empty parameters for functions, even though it is listed as optional in the API documentation. I guess it's still a work in progress. Also the content can be a message even if there is a function call associated with the response. It's not always null.

unconv
Автор

Can we trust OpenAI to reliably call the function when needed?

wryltxw
Автор

How can I pass an array as a parameter? :)

SinanAkkoyun