Skip to content

Commit

Permalink
fix: make verify a client parameter (openai#1204)
Browse files Browse the repository at this point in the history
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
  • Loading branch information
tdene committed Mar 1, 2024
1 parent e41abf7 commit 33b12c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
_base_url: URL
max_retries: int
timeout: Union[float, Timeout, None]
verify: httpx._types.VerifyTypes = True
_limits: httpx.Limits
_proxies: ProxiesTypes | None
_transport: Transport | AsyncTransport | None
Expand All @@ -343,6 +344,7 @@ def __init__(
_strict_response_validation: bool,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
verify: httpx._types.VerifyTypes = True,
limits: httpx.Limits,
transport: Transport | AsyncTransport | None,
proxies: ProxiesTypes | None,
Expand All @@ -353,6 +355,7 @@ def __init__(
self._base_url = self._enforce_trailing_slash(URL(base_url))
self.max_retries = max_retries
self.timeout = timeout
self.verify = verify
self._limits = limits
self._proxies = proxies
self._transport = transport
Expand Down Expand Up @@ -727,6 +730,7 @@ def __init__(
base_url: str | URL,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
verify: httpx._types.VerifyTypes = True,
transport: Transport | None = None,
proxies: ProxiesTypes | None = None,
limits: Limits | None = None,
Expand Down Expand Up @@ -786,6 +790,7 @@ def __init__(
base_url=base_url,
transport=transport,
max_retries=max_retries,
verify=verify,
custom_query=custom_query,
custom_headers=custom_headers,
_strict_response_validation=_strict_response_validation,
Expand All @@ -794,6 +799,7 @@ def __init__(
base_url=base_url,
# cast to a valid type because mypy doesn't understand our type narrowing
timeout=cast(Timeout, timeout),
verify=verify,
proxies=proxies,
transport=transport,
limits=limits,
Expand Down Expand Up @@ -1270,6 +1276,7 @@ def __init__(
_strict_response_validation: bool,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
verify: httpx._types.VerifyTypes = True,
transport: AsyncTransport | None = None,
proxies: ProxiesTypes | None = None,
limits: Limits | None = None,
Expand Down Expand Up @@ -1328,6 +1335,7 @@ def __init__(
proxies=proxies,
transport=transport,
max_retries=max_retries,
verify=verify,
custom_query=custom_query,
custom_headers=custom_headers,
_strict_response_validation=_strict_response_validation,
Expand All @@ -1336,6 +1344,7 @@ def __init__(
base_url=base_url,
# cast to a valid type because mypy doesn't understand our type narrowing
timeout=cast(Timeout, timeout),
verify=verify,
proxies=proxies,
transport=transport,
limits=limits,
Expand Down
8 changes: 8 additions & 0 deletions src/openai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
verify: httpx._types.VerifyTypes = True,
default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
Expand Down Expand Up @@ -114,6 +115,7 @@ def __init__(
base_url=base_url,
max_retries=max_retries,
timeout=timeout,
verify=verify,
http_client=http_client,
custom_headers=default_headers,
custom_query=default_query,
Expand Down Expand Up @@ -165,6 +167,7 @@ def copy(
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
max_retries: int | NotGiven = NOT_GIVEN,
verify: httpx._types.VerifyTypes = None,
default_headers: Mapping[str, str] | None = None,
set_default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
Expand Down Expand Up @@ -200,6 +203,7 @@ def copy(
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
verify=verify or self.verify,
default_headers=headers,
default_query=params,
**_extra_kwargs,
Expand Down Expand Up @@ -270,6 +274,7 @@ def __init__(
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
verify: httpx._types.VerifyTypes = True,
default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
Expand Down Expand Up @@ -312,6 +317,7 @@ def __init__(
base_url=base_url,
max_retries=max_retries,
timeout=timeout,
verify=verify,
http_client=http_client,
custom_headers=default_headers,
custom_query=default_query,
Expand Down Expand Up @@ -363,6 +369,7 @@ def copy(
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
max_retries: int | NotGiven = NOT_GIVEN,
verify: httpx._types.VerifyTypes = None,
default_headers: Mapping[str, str] | None = None,
set_default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
Expand Down Expand Up @@ -398,6 +405,7 @@ def copy(
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
verify=verify or self.verify,
default_headers=headers,
default_query=params,
**_extra_kwargs,
Expand Down

0 comments on commit 33b12c9

Please sign in to comment.