Azure OpenAI does not work because of wrong initialization order (getting list of models because it is set to the Azure OpenAI client)
imWildCat opened this issue · comments
Mike Chong commented
$ bbook_maker --book_name "./xxx.epub" --openai_key xxx --api_base 'https://xxx/' --deployment_id 'gpt-4' -m 'gpt4'
Traceback (most recent call last):
File "/Users/kitten/Downloads/temp/venv/bin/bbook_maker", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/book_maker/cli.py", line 362, in main
e = book_loader(
^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/book_maker/loader/epub_loader.py", line 39, in __init__
self.translate_model = model(
^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/book_maker/translator/chatgptapi_translator.py", line 71, in __init__
i["id"] for i in self.openai_client.models.list().model_dump()["data"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/openai/resources/models.py", line 79, in list
return self._get_api_list(
^^^^^^^^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1229, in get_api_list
return self._request_api_list(model, page, opts)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1074, in _request_api_list
return self.request(page, options, stream=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/openai/_base_client.py", line 869, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/kitten/Downloads/temp/venv/lib/python3.11/site-packages/openai/_base_client.py", line 960, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
yihong commented
will take a look today thanks
yihong commented
@imWildCat fixed can you take a look?
need update to the latest version
Mike Chong commented
@yihong0618 thank you so much! it works now!
yihong commented
@yihong0618 thank you so much! it works now!
FYI I did some trick to avoid limit, so OpenAI is faster...you can check this commit to check out why 365d662
Mike Chong commented
@yihong0618 thanks!
I gave up Azure immediately after their content filter blocked me several times.