Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def project(self, value: str | None) -> None: # type: ignore
@override
def base_url(self) -> _httpx.URL:
if base_url is not None:
return _httpx.URL(base_url)
return self._enforce_trailing_slash(_httpx.URL(base_url))

return super().base_url

Expand Down Expand Up @@ -245,6 +245,11 @@ def _client(self, value: _httpx.Client) -> None: # type: ignore

http_client = value

def _enforce_trailing_slash(self, url: _httpx.URL) -> _httpx.URL:
if url.raw_path.endswith(b"/"):
return url
return url.copy_with(raw_path=url.raw_path + b"/")


class _AzureModuleClient(_ModuleClient, AzureOpenAI): # type: ignore
...
Expand Down
4 changes: 2 additions & 2 deletions tests/test_module_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_base_url_option() -> None:

openai.base_url = "http://foo.com"

assert openai.base_url == URL("http://foo.com")
assert openai.completions._client.base_url == URL("http://foo.com")
assert openai.base_url == URL("http://foo.com/")
assert openai.completions._client.base_url == URL("http://foo.com/")


def test_timeout_option() -> None:
Expand Down