Open HonXia opened 1 week ago
Hi can I take a look at this issue if no one else is. Thank you
For me it doesn't even work either.
It seems that the current version 0.2.x has introduced this bug. I was upgrading from 0.1.17 which is still running in production well, but 0.2.x doesn't.
My feeling is that the API key is not used at all. The error message is Incorrect API key provided: **********.
whereas if I set an invalid key and try to call the LLM, then the error message is Incorrect API key provided: sk-proj-*********lLAz.
(I removed some *** fro shortness). Do you spot the difference?
Checked other resources
Example Code
The following Langchain code failed to generate image:
The following OpenAI code generated image successfully:
Error Message and Stack Trace (if applicable)
Traceback (most recent call last): File "D:\software\JetBrains\PyCharm Community Edition 2024.2.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec pydev_imports.execfile(file, globals, locals) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\software\JetBrains\PyCharm Community Edition 2024.2.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "E:\workspace\python-projects\AI-Development\agents\dalle_image.py", line 21, in
image_url = DallEAPIWrapper().run(chain.run("halloween night at a haunted museum"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\workspace\python-projects\AI-Development.venv\Lib\site-packages\langchain_community\utilities\dalle_image_generator.py", line 143, in run
response = self.client.generate(
^^^^^^^^^^^^^^^^^^^^^
File "E:\workspace\python-projects\AI-Development.venv\Lib\site-packages\openai\resources\images.py", line 264, in generate
return self._post(
^^^^^^^^^^^
File "E:\workspace\python-projects\AI-Development.venv\Lib\site-packages\openai_base_client.py", line 1270, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\workspace\python-projects\AI-Development.venv\Lib\site-packages\openai_base_client.py", line 947, in request
return self._request(
^^^^^^^^^^^^^^
File "E:\workspace\python-projects\AI-Development.venv\Lib\site-packages\openai_base_client.py", line 1051, in _request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: **. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}
Description
I write a demo following up guideline https://python.langchain.com/docs/integrations/tools/dalle_image_generator/#run-as-a-chain, but it always failed with error :"openai.AuthenticationError: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: **. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}". I debug the program into _base_client.py found the open AI images generations API url is wrong as the screen capture as below. The same OPENAI_API_KEY can success in the OpenAI sample as above.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies