#well as a side note it is to call
25 messages · Page 1 of 1 (latest)
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
You mean locally defined functions for after the callback?
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
the API has no idea if the function exists or not beyond that though.
No. the api has no access to your code and only knows what you pass to it
Right, and you only pass it the function definition (functionDefs).
Right, which is why you need to make the next step that handles it's response
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.
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?
Yeah. It is. Let me try that model instead.
I don't have access to GPT-4 so I can't try the model you were using
lol, that's so weird. It's working with 3.5-turbo, but not gpt-4.
hAHahhah if thats the whole reason it's not trriggering
the weather example works with either.
You probably don't have access to gpt 4 /facepalm
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.
Might be something worth reporting then 😄