OpenAI GPT-3 API error: "InvalidRequestError: Unrecognized request argument supplied"

Question:

import openai

# Set the API key
openai.api_key = "YOUR API KEY"

# Define the conversation memory
conversation_memory = {
    "previous_question": "What is the capital of France?",
    "previous_answer": "The capital of France is Paris."
}

# Make the API request
response = openai.Completion.create(
    model="text-davinci-003",
    prompt="Where is the Eiffel Tower located?",
    temperature=0.5,
    max_tokens=1024,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0,
    conversation_memory=conversation_memory
)

# Print the response
print(response.text)

Why the conversation_memory parameter not being recognize. I try this with serveral different models and they all give me the same error. I have the lastest OpenAi on my computer. I don’t understand.

Here the error:

     InvalidRequestError                       Traceback (most recent call last) <ipython-input-17-ace11d6ce405> in <module>      11      12 # Make the API request ---> 13 response = openai.Completion.create(      14     model="text-babbage-001",      15     prompt="Where is the Eiffel Tower located?", C:ProgramDataAnaconda3libsite-packagesopenaiapi_resourcescompletion.py in create(cls, *args, **kwargs)      23 while True:      24 try: ---> 25 return super().create(*args, **kwargs)      26 except TryAgain as e:      27 if timeout is not None and time.time() > start + timeout: C:ProgramDataAnaconda3libsite-packagesopenaiapi_resourcesabstractengine_api_resource.py in create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)     113         )     114         url = cls.class_url(engine, api_type, api_version) --> 115         response, _, api_key = requestor.request(     116 "post",     117             url, C:ProgramDataAnaconda3libsite-packagesopenaiapi_requestor.py in request(self, method, url, params, headers, files, stream, request_id, request_timeout)     179             request_timeout=request_timeout,     180         ) --> 181 resp, got_stream = self._interpret_response(result, stream)     182 return resp, got_stream, self.api_key     183 C:ProgramDataAnaconda3libsite-packagesopenaiapi_requestor.py in _interpret_response(self, result, stream)     394 else:     395             return ( --> 396                 self._interpret_response_line(     397                     result.content, result.status_code, result.headers, stream=False     398                 ),  C:ProgramDataAnaconda3libsite-packagesopenaiapi_requestor.py in _interpret_response_line(self, rbody, rcode, rheaders, stream)     427         stream_error = stream and "error" in resp.data     428 if stream_error or not 200 <= rcode < 300: --> 429             raise self.handle_error_response(     430                 rbody, rcode, resp.data, rheaders, stream_error=stream_error     431             ) 
 InvalidRequestError: Unrecognized request argument supplied: conversation_memory 
Asked By: Richard Twitty

||

Answers:

The error itself tells you what’s wrong.

You’re trying to pass conversation_memory as a parameter to the Completions endpoint, which the OpenAI API doesn’t recognize as a parameter.

See the complete list of parameters you can pass to the Completions endpoint:

  • model
  • prompt
  • suffix
  • max_tokens
  • temperature
  • top_p
  • n
  • stream
  • logprobs
  • echo
  • stop
  • presence_penalty
  • frequency_penalty
  • best_of
  • logit_bias
  • user
Answered By: Rok Benko