manateelazycat / mind-wave

Emacs AI plugin based on ChatGPT API
GNU General Public License v3.0
159 stars 26 forks source link

fix azure openai model openai.error.InvalidRequestError, by change parameter `model` to `engine` when openai.api_type == 'azure' #37

Closed sawyerzheng closed 1 year ago

sawyerzheng commented 1 year ago

The azure openai model using engine parameter to set the model name. This PR will fix errors as following:


[Mind-Wave] Traceback (most recent call last):
  File "/home/sawyer/.emacs.d.clean/straight/build/mind-wave/mind_wave.py", line 35, in wrapper
    return func(*args, **kwargs)
  File "/home/sawyer/.emacs.d.clean/straight/build/mind-wave/mind_wave.py", line 128, in send_stream_request
    temperature=0,
  File "/home/sawyer/.local/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/home/sawyer/.local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 149, in create
    ) = cls.__prepare_create_request(
  File "/home/sawyer/.local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 83, in __prepare_create_request
    raise error.InvalidRequestError(
openai.error.InvalidRequestError: Must provide an ’engine’ or ’deployment_id’ parameter to create a <class ’openai.api_resources.chat_completion.ChatCompletion’>
manateelazycat commented 1 year ago

thanks