gpt4 book ai didi

python - OpenAI GPT-3 API 错误 : "InvalidRequestError: Unrecognized request argument supplied"

转载 作者:行者123 更新时间:2023-12-02 22:45:36 26 4
gpt4 key购买 nike

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

最佳答案

错误本身会告诉您出了什么问题。

您正在尝试将 conversation_memory 作为参数传递给 Completions 端点,OpenAI API 无法将其识别为参数。

参见 complete list您可以传递给完成端点的参数:

  • 模型
  • 提示
  • 后缀
  • max_tokens
  • 温度
  • top_p
  • n
  • logprobs
  • 回显
  • 停止
  • presence_penalty
  • frequency_penalty
  • best_of
  • logit_bias
  • 用户

关于python - OpenAI GPT-3 API 错误 : "InvalidRequestError: Unrecognized request argument supplied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74978793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com