How can I pass my own python function to openai in openai playground not the json one but actual function that I wrotem

Can anyone help me with function calling in openai

I wrote a custom function python function

def function():
pass

I want this function to be called in openai playground.
How can I do that

Function Calling will not literally call your python function. Function Calling will call the Function You define in either your assistant or while using chat completion API. When its called, it will output a JSON Object which you’ll use to manually call your python function.

I’ve created a video on Function Calling using Assistant API

If you still have confusion, reply here and I will try to explain in easy terms.

2 Likes

I have worked with other models like mistral instruct, llama instruct where I can write a function and call them.

But for openai I only pass a the function name in json but I don’t know where to write that function and how openai will call them.

But as per your reply you are saying that the openai will only output the function name.

But the question is where will I write the actual function. Like in mistral and llama I can write the function in the same file.

While retrieving the RUN status, you’ll see ‘Require_action’ in the response. If that is not null that means a function is called. There you will write your custom code. Check the video I mentioned, I’ve explained this in details.