#Need someone that understands function-calling properly :D

1 messages · Page 1 of 1 (latest)

fallow umbra
#

I am really unsure if i'm understanding Assistant-API function-calling correctly, that's why i wanted to ask you about it.

  • Where does the Assistant call the function? (In my own hosted code?, which kinda makes no sense :D)
  • Can an Assistant call an API, or just call a function that calls an API?
  • Why is the format that you have to give the Assistant JSON?
wicked obsidian
#

It is indeed in your own hosted code, but custom actions that you make must be accessible as an API for the assistant to call it (you define this yourself)

#

The assistant directly calls the API

#

If you're using function calling with chat completions, the assistant will return what function call to make, and you're responsible for decoding that and executing the function call yourself logically in code

#

It's in JSON because it's been trained on JSON tokens for the function calling part

fallow umbra
wicked obsidian
#

And from there, the assitant will directly call the API, or if using chat completions will return another JSON object with what function to call and their paramters

fallow umbra
wicked obsidian
fallow umbra
#

the assistants API

wicked obsidian
#

got it

#

So this type of function is not something that the assitant will call by itself

#

As you can see there's no API or endpoint defined

#

So, you need to retrieve the decision to make this function call from the assistants API, and then make the call in your own code after you make that determination

fallow umbra
wicked obsidian
#

Let me find a good example I saw earlier

#

about how local function-calling works

#

one moment

fallow umbra
#

great, thanks!

wicked obsidian
#

Take a look at this page

#

This is for chatcompletions but it should be similar for assistants

#

So basically you define functions to call and then you prompt GPT, when GPT returns, it will also return a set of determined function calls for you to use

#

e.g assistant_message.tool_calls[0].function

#

That would denote the first function's name (if .function is not None e.g no function to call determined)

#

And then in your code you'd write some logic to read the .function field and the parameter fields and call the corresponding local function to the function that you defined

#

So basically if you're doing it this way without an API/endpoint, you DEFINE your functions to the OpenAI API, but you also need the IMPLEMENTATIONS for those functions locally in your code

fallow umbra
#

Ohh, so now it makes sense finally

wicked obsidian
#

awesome!

fallow umbra
wicked obsidian
#

It will

#

And then you take those params and the function name and call it locally