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)
为什么conversation_memory参数不能被识别。我用几个不同的模型尝试了这个,他们都给我同样的错误。我的电脑上有最新的OpenAi。我不明白。
这里的错误:
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:\ProgramData\Anaconda3\lib\site-packages\openai\api_resources\completion.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:\ProgramData\Anaconda3\lib\site-packages\openai\api_resources\abstract\engine_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:\ProgramData\Anaconda3\lib\site-packages\openai\api_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:\ProgramData\Anaconda3\lib\site-packages\openai\api_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:\ProgramData\Anaconda3\lib\site-packages\openai\api_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
1条答案
按热度按时间pjngdqdw1#
错误本身就告诉你出了什么问题。
您试图将
conversation_memory
作为参数传递给完成函数,OpenAI API无法将其识别为参数。查看可以传递给完成函数的完整list of parameters。