-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Inconsistent base_url behavior with module client and OpenAIClient #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reporting, @dramdass. I'm not sure we'd prioritize a fix here, but we'd likely accept a contribution that updates the module client to match the non-module client. |
The right fix seems to be in |
Yes, that would be the correct location. |
Fixes openai#1373 Update `base_url` behavior to enforce trailing slash in module client * Modify `src/openai/__init__.py` to enforce a trailing slash for `base_url` in the `_ModuleClient` class. * Add a helper method `_enforce_trailing_slash` to the `_ModuleClient` class. * Update tests in `tests/test_module_client.py` to verify the consistent behavior of `base_url` in both module client and `OpenAIClient`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/openai/openai-python/issues/1373?shareId=XXXX-XXXX-XXXX-XXXX).
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
The issue is that the
base_url
in theOpenAI
client enforces a trailing slash whereas setting the moduleopenai.base_url
does not enforce.This is 100% reproducible and while it can be worked around, the inconsistency in clients causes issues in scripts that use both clients.
To Reproduce
base_url
without a trailing slash. See error with URL for completionsbase_url
without a trailing slash. See no erros.Code snippets
This works
This does not:
Error:
OS
macOS
Python version
Python v3.12
Library version
openai v1.23.6
The text was updated successfully, but these errors were encountered: