Finetuned model chat completions fail when using "None" in arguments for freq + presence penalty

According to the docs, frequency_penalty/presence penalty can be given as number or null (None).

This works fine for regular models, but when using a finetuned model, I get this response.

Error code: 400 - {'error': {'message': "None is not of type 'number' - 'presence_penalty'", 'type': 'invalid_request_error', 'param': None, 'code': None}}

It would be good if this error could be removed for finetuned models for the penalties.

1 Like

Extending this, it’s now also happening for ‘gpt-3.5-turbo-1106’

It’s an optional field. Just don’t send it. Although I too don’t like that they don’t accept null values. I have a Rust openai wrapper and my serializer needs to be nasty filled with annotations to accommodate their specs.

Inb4 “just rewrite it bro” :sob:

1 Like

As much as I’m happy to not send it, I’ve got a specific project for which the code works better if I can send None. And considering it only fails for some models, I’d count that as a bug right?

I’m guessing you’re writing in Python. I found this code on stack overflow. Maybe a solution in the meantime?

def del_none(d):
    Delete keys with the value ``None`` in a dictionary, recursively.

    This alters the input so you may wish to ``copy`` the dict first.
    # For Python 3, write `list(d.items())`; `d.items()` won’t work
    # For Python 2, write `d.items()`; `d.iteritems()` won’t work
    for key, value in list(d.items()):
        if value is None:
            del d[key]
        elif isinstance(value, dict):
    return d  # For convenience

+1 though. I agree that it should be changed

1 Like