First things first. I’m writing an app with Flutter and chat gpt. I’m using “model”: “gpt-3.5-turbo”. But every time I’m trying to include parameter “functions” or “tools” to my request I’m getting an error NoSuchMethodError: The method ‘’ was called on null. Without this parameter everything works as expected.
My request is
final response = await http.post(
Uri.parse('https://api.openai.com/v1/chat/completions'),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer .....'
},
body: jsonEncode(
{
"model": "gpt-3.5-turbo",
"messages": dialogueHistory,
"functions": [
{
"name": "throwDice",
"description": "Throw dice to work out the result of a check.",
"parameters": {
"type": "object",
"properties": {
"modifier": {
"type": "number",
"description": "Check modifier that increases or decreases result of check."
},
},
},
}
],
"function_call": "auto"
},
),
);
I have also tried
"tools": [
{
"type": "function",
"function": {
"name": "throwDice",
"description": "Throw dice to work out the result of a check.",
"parameters": {
"type": "object",
"properties": {
"modifier": {
"type": "number",
"description": "Check modifier that increases or decreases result of check."
},
},
}
}
}
]
But got the same error. What am I doing wrong?