Reputation: 45175
I can't seem to get OpenAI's Chat Completions HTTP API to accept my request. It's stuck on my functions
property.
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "etc"
},
{
"role": "user",
"content": "etc"
}
],
"functions": null,
"function_call": null,
"temperature": null,
"top_p": null,
"n": null,
"stream": null,
"stop": null,
"max_tokens": null,
"user": null
}
Produces a slightly nonsensical error,
{
"error": {
"message": "None is not of type 'array' - 'functions'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
But this JSON sent in,
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "etc"
},
{
"role": "user",
"content": "etc"
}
],
"functions": [],
"function_call": "none",
"temperature": null,
"top_p": null,
"n": null,
"stream": null,
"stop": null,
"max_tokens": null,
"user": null
}
Gives this error:
{
"error": {
"message": "[] is too short - 'functions'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
It doesn't like it either way?!
Funnily enough, I run it past GPT-3.5 itself and it said my JSON looks fine and shouldn't produce this error haha.
Upvotes: 0
Views: 1604
Reputation: 45175
It seems an odd API for the world's smartest people, it works when there is no functions
property at all in the JSON.
This means adding this code for C# folks.
var jsonOptions = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
Upvotes: 0