#well as a side note it is to call

25 messages · Page 1 of 1 (latest)

golden arch
#

I do have functions defined.

wet shale
#

You have a description for a function

#

in the example

    function_call = ai_response["choices"][0]["message"]["function_call"]
    function_name = function_call["name"]
    arguments = function_call["arguments"]
    
    if function_name == "function_1":
        one = eval(arguments).get("one")
        print(f"Function 1 {one}")
        return
     
    if function_name == "function_2":
        print('Function 2')
        one = eval(arguments).get("one")
        two = eval(arguments).get("two")
        print(f"Function 2 {one}{two}")
        return
    
    else: 
        return```

This is where it would take the definition and pass the information to the actual functions
golden arch
#

You mean locally defined functions for after the callback?

wet shale
#

all this does

        {
            "name": "validate_haiku",
            "description": "Validate the correctness of an AI generated haiku.",
            "parameters": {
                "type": "object",
                "properties": {
                    "text": {
                        "type": "string",
                        "description": "The haiku text, with newline characters after lines."
                    }
                },
                "required": ["text"]
            }
        },
    ];```
is put together the variables to pass to the next step
golden arch
#

the API has no idea if the function exists or not beyond that though.

wet shale
#

No. the api has no access to your code and only knows what you pass to it

golden arch
#

Right, and you only pass it the function definition (functionDefs).

wet shale
#

Right, which is why you need to make the next step that handles it's response

golden arch
#

I know, but there's no point in doing that if I can't get the API call to work. Handling it afterwards will be trivial.

tidal bison
#

I just tried your code in JS and it works for me Justin, but I am using gpt-3.5-turbo-0613

#

your code is wrapped in an async function right?

golden arch
#

Yeah. It is. Let me try that model instead.

tidal bison
#

I don't have access to GPT-4 so I can't try the model you were using

golden arch
#

lol, that's so weird. It's working with 3.5-turbo, but not gpt-4.

wet shale
#

hAHahhah if thats the whole reason it's not trriggering

golden arch
#

the weather example works with either.

wet shale
#

You probably don't have access to gpt 4 /facepalm

golden arch
#

So it seems like gpt-4 works worse for function calling in at least this particular instance.

#

No, i do have access.

#

I regularly use gpt-4 and the weather example works for function calling with gpt-4.

tidal bison
#

Might be something worth reporting then 😄

golden arch
#

Yeah. Thanks for helping me figure it out. It's so weird.

#

Have never really found 3.5 to work better than 4 for anything before.