chat_gpt_sdk
chat_gpt_sdk copied to clipboard
Function Calling: None is not of type 'object' - 'messages.0.function_call
Hello! Im trying function calling feature with this example:
void gptFunctionCalling() async {
final request = ChatCompleteText(
messages: [
Messages(
role: Role.user,
content: "What is the weather like in Boston?",
name: "get_current_weather"),
],
maxToken: 200,
model: GptTurbo0631Model(),
functions: [
FunctionData(
name: "get_current_weather",
description: "Get the current weather in a given location",
parameters: {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
})
],
functionCall: FunctionCall.auto);
ChatCTResponse? response = await openAI.onChatCompletion(request: request);
debugPrint("$response");
}
But dont work, i'm getting this error: Unhandled Exception: status code :400 message :{message: None is not of type 'object' - 'messages.0.function_call', code: null, type: invalid_request_error}
@ChargerMc you have to backend api