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:
try:
return fn(*args, **kwargs)
except:
if x == retries:
raise
sleep = backoff_in_seconds * 2 ** x + random.uniform(0)
time.sleep(sleep)
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(
openai.ChatCompletion.create,
model='gpt-4',
messages=[{'role': 'user', 'content': prompt_solution + f'Question: {question}\nAccepted Answer: ###{accepted_answer}###\nSummary: '}],
temperature=0,
max_tokens=10,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
timeout=100,
stream=False)
but it gives the following exception: Random.uniform() missing 1 required positional argument: 'b'
Any clue?