Function Call Description Max Length

Have been running into a 400 BadRequestError due to too long description:

openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: ‘“…” is too long - 'functions.2.description'’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}

What is the function call description token limit?

3 Likes

We don’t get a limit given to us in API reference specification, except for an array of a maximum of 128 functions, and a limit of the function name.

Your further investigation will provide insight. If rejected by the API endpoint, it is probably based on characters and not tokens.

“name”: {
“type”: “string”,
“description”: “The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.”

From my exploring the Azure REST API specs for 2023-12-01-preview, we do get other insights.
“seed”: {
“type”: “integer”,
“minimum”: -9223372036854775808,
“maximum”: 9223372036854775807,

And Azure extensions usurping OpenAI API capabilities: The ability to receive a vision grounding (bounding boxes locating items), or even explicitly requesting OCR.

Hi @andersskog @_j
I got the same error when put a long description.

I tested it a bit–try to make description a bit longer and shorter. Then find the limitation is 1027 characters including space. You can try a bit. If the description is longer than 1027 characters, you can repro this error.

Here is the structure of my request:

Blockquote
{
“max_tokens”: 10000,
“temperature”: 0.0,
“presence_penalty”: 0.0,
“frequency_penalty”: 0.0,
“messages”: [
{
“role”: “system”,
“content”: “xxxxxxxxxxxxxxxx”
},
{
“role”: “user”,
“content”: “xxxxxxxxxxxxxxxx”
}
],
“functions”: [
{
// this is a short description function
“name”: “function1”,
“description”: “xxxxxxxxxxx”,
“parameters”: {
“type”: “object”,
“properties”: {
“source_input”: {
“type”: “string”,
“description”: “xxxx”
}
}
}
},
{
// this is the function with the long description
“name”: “function2”,
“description”: “xxxxxxLONG-DESCRIPTIONxxxxxxx”,
“parameters”: {
“type”: “object”,
“properties”: {
“results”: {
“type”: “array”,
“description”: “xxxxxx”,



},
“required”: [
“xxx”
]
}
}
},
“required”: [
“xxx”
]
}
}
],
“function_call”: “auto”
}

1 Like

Hi @_j
Is this by design?
Why we cannot add long descrioption? It doesn’t make sence.
We don’t want to put everything in the system prompt…

Is this 128 functions at max a hard limit? Can it be increased? Also how is the underlying model programmed to-

  1. understand what functions are available
  2. Reference to the function
  3. Return the function and its arguments
    Basically curious to have a deeper understanding on what happens under the hood?

I have same issue, but the limitation is 1024 characters including space.

1 Like

You can also diversify the description: put the parts that are appropriate to the function call parameters themselves as descriptions of the parameter properties.

Anyone found any workaround (except shortening description or moving things around like parameters, …)
This “bug” (I don’t believe this was intended as design) is particularly annoying when using also other frameworks (LangChain, Llama Index) where we can’t control where something goes where)

2 Likes