Random.uniform() missing 1 required positional argument: 'b'

Hi, there.

I encountered a problem when I feed my prompt into gpt-4 via API, here is my code:

import openai
import random

openai.api_key = os.getenv('OPENAI_API_KEY')

# expential backoff
def retry_with_backoff(fn, retries=2, backoff_in_seconds=1, *args, **kwargs):
    x = 0
    if args is None:
        args = []
    if kwargs is None:
        kwargs = {}

    while True:
            return fn(*args, **kwargs)
            if x == retries:

            sleep = backoff_in_seconds * 2 ** x + random.uniform(0)
            x += 1

prompt_solution = f'''Summarize the major proposed resolution using a "verb + (optional adjective) + noun" structure based on the post, abiding by these rules:
        1. Keep within three words.
        2. Do not include any form of punctuation.
        3. Abstract any programming-specific identifier with a high-level concept in your summary if any. Programming-specific identifiers **include but are not limited to**: software platform name (e.g. {tools}), software package name, directory name, file name, algorithm name, benchmark name, metric name, instance name, process name, job name, class name, module namecommand name, method name, function name, variable name, argument name, parameter name.
        4. Do not use any form of compound terms (e.g. camel, snake, hyphenated, slash, dot notation). All potential compound terms should be transformed or decomposed into simpler common words in your summary if any.
        Be sure to follow the above rules in summarization.
question = 'Colleague deleted projects by mistake, can they be recovered?'
accepted_answer = '<p>Please check the names of the project. By username I meant the entity name where the projects were logged. If these were team projects then I need the team name.</p>'
response = retry_with_backoff(
                messages=[{'role': 'user', 'content': prompt_solution + f'Question: {question}\nAccepted Answer: ###{accepted_answer}###\nSummary: '}],

but it gives the following exception: Random.uniform() missing 1 required positional argument: 'b'

Any clue?

Do you have a full stacktrace? Does it work if you remove the retry_with_backoff wrapper?

Edit: Based on your edit, the issue is in your retry_with_backoff function. Looks like it needs two arguments.

Thanks for any reply. Eventually, I found my key is invalid anymore. But it is so weird that the error message is so irrelevant.