This PR addresses a bug where the API_KEY was erroneously included in the parameters of the chat.completions.create() method, leading to a TypeError. The error in question:
Traceback (most recent call last):
File "/Users/easto/Library/Mobile Documents/com~apple~CloudDocs/Projects/spine-reader/better.py", line 4, in <module>
text = betterocr.detect_text(
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/easto/Library/Mobile Documents/com~apple~CloudDocs/Projects/spine-reader/venv/lib/python3.11/site-packages/betterocr/detect.py", line 83, in detect_text
completion = client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/easto/Library/Mobile Documents/com~apple~CloudDocs/Projects/spine-reader/venv/lib/python3.11/site-packages/openai/_utils/_utils.py", line 299, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: Completions.create() got an unexpected keyword argument 'API_KEY'
The provided fix prioritizes the user-specified API_KEY when initializing the OpenAI client and ensures that the API_KEY is not passed along with other options to the completions.create() call.
This PR addresses a bug where the
API_KEY
was erroneously included in the parameters of the chat.completions.create() method, leading to aTypeError
. The error in question:The provided fix prioritizes the user-specified
API_KEY
when initializing the OpenAI client and ensures that the API_KEY is not passed along with other options to thecompletions.create()
call.