Merge pull request #18 from hanzoai/release-please--branches--main--changes--next

release: 2.0.1
This commit is contained in:
2025-03-27 19:26:16 -05:00
committed by GitHub
9 changed files with 129 additions and 20 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
{
".": "2.0.0"
".": "2.0.1"
}
+3 -3
View File
@@ -1,4 +1,4 @@
configured_endpoints: 188
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-d52d95e1cfea66db609fe20a4ebf5612dbb3b8f6bd1d444f43953dedf8fe55c5.yml
openapi_spec_hash: cab16da993c22dfa62f6e845990ff29f
config_hash: ba350ab5c18ad5058636cd0062736ace
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-ec4be99f95dc46e9442eb60f233b2bff271d6f5bf57d7c61a52bc4804f55bbd1.yml
openapi_spec_hash: 87bc62c36bb6028ffd1f3e54a2809099
config_hash: 830747463ff4d018b5633ce511e88558
+8
View File
@@ -1,5 +1,13 @@
# Changelog
## 2.0.1 (2025-03-28)
Full Changelog: [v2.0.0...v2.0.1](https://github.com/hanzoai/python-sdk/compare/v2.0.0...v2.0.1)
### Chores
* update SDK settings ([#17](https://github.com/hanzoai/python-sdk/issues/17)) ([01f71f1](https://github.com/hanzoai/python-sdk/commit/01f71f1ddb19bae7479b1375bfc247ce0e74802e))
## 2.0.0 (2025-03-27)
Full Changelog: [v1.1.0...v2.0.0](https://github.com/hanzoai/python-sdk/compare/v1.1.0...v2.0.0)
+4
View File
@@ -27,6 +27,8 @@ from hanzoai import Hanzo
client = Hanzo(
api_key=os.environ.get("HANZO_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="sandbox",
)
response = client.get_home()
@@ -48,6 +50,8 @@ from hanzoai import AsyncHanzo
client = AsyncHanzo(
api_key=os.environ.get("HANZO_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="sandbox",
)
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "hanzoai"
version = "2.0.0"
version = "2.0.1"
description = "The official Python library for the Hanzo API"
dynamic = ["readme"]
license = "Apache-2.0"
+13 -1
View File
@@ -3,7 +3,18 @@
from . import types
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
from ._utils import file_from_path
from ._client import Hanzo, Client, Stream, Timeout, Transport, AsyncHanzo, AsyncClient, AsyncStream, RequestOptions
from ._client import (
ENVIRONMENTS,
Hanzo,
Client,
Stream,
Timeout,
Transport,
AsyncHanzo,
AsyncClient,
AsyncStream,
RequestOptions,
)
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
@@ -59,6 +70,7 @@ __all__ = [
"AsyncStream",
"Hanzo",
"AsyncHanzo",
"ENVIRONMENTS",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
+80 -13
View File
@@ -3,8 +3,8 @@
from __future__ import annotations
import os
from typing import Any, Union, Mapping
from typing_extensions import Self, override
from typing import Any, Dict, Union, Mapping, cast
from typing_extensions import Self, Literal, override
import httpx
@@ -92,7 +92,22 @@ from .resources.responses import responses
from .resources.fine_tuning import fine_tuning
from .resources.organization import organization
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Hanzo", "AsyncHanzo", "Client", "AsyncClient"]
__all__ = [
"ENVIRONMENTS",
"Timeout",
"Transport",
"ProxiesTypes",
"RequestOptions",
"Hanzo",
"AsyncHanzo",
"Client",
"AsyncClient",
]
ENVIRONMENTS: Dict[str, str] = {
"production": "https://api.hanzo.ai",
"sandbox": "https://api.sandbox.hanzo.ai",
}
class Hanzo(SyncAPIClient):
@@ -150,11 +165,14 @@ class Hanzo(SyncAPIClient):
# client options
api_key: str
_environment: Literal["production", "sandbox"] | NotGiven
def __init__(
self,
*,
api_key: str | None = None,
base_url: str | httpx.URL | None = None,
environment: Literal["production", "sandbox"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
@@ -185,10 +203,31 @@ class Hanzo(SyncAPIClient):
)
self.api_key = api_key
if base_url is None:
base_url = os.environ.get("HANZO_BASE_URL")
if base_url is None:
base_url = f"https://api.hanzo.ai"
self._environment = environment
base_url_env = os.environ.get("HANZO_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `HANZO_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)
try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"
try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
super().__init__(
version=__version__,
@@ -276,6 +315,7 @@ class Hanzo(SyncAPIClient):
self,
*,
api_key: str | None = None,
environment: Literal["production", "sandbox"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
@@ -311,6 +351,7 @@ class Hanzo(SyncAPIClient):
return self.__class__(
api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
environment=environment or self._environment,
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,
@@ -431,11 +472,14 @@ class AsyncHanzo(AsyncAPIClient):
# client options
api_key: str
_environment: Literal["production", "sandbox"] | NotGiven
def __init__(
self,
*,
api_key: str | None = None,
base_url: str | httpx.URL | None = None,
environment: Literal["production", "sandbox"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
@@ -466,10 +510,31 @@ class AsyncHanzo(AsyncAPIClient):
)
self.api_key = api_key
if base_url is None:
base_url = os.environ.get("HANZO_BASE_URL")
if base_url is None:
base_url = f"https://api.hanzo.ai"
self._environment = environment
base_url_env = os.environ.get("HANZO_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `HANZO_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)
try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"
try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
super().__init__(
version=__version__,
@@ -557,6 +622,7 @@ class AsyncHanzo(AsyncAPIClient):
self,
*,
api_key: str | None = None,
environment: Literal["production", "sandbox"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
@@ -592,6 +658,7 @@ class AsyncHanzo(AsyncAPIClient):
return self.__class__(
api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
environment=environment or self._environment,
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,
+1 -1
View File
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
__title__ = "hanzoai"
__version__ = "2.0.0" # x-release-please-version
__version__ = "2.0.1" # x-release-please-version
+18
View File
@@ -556,6 +556,14 @@ class TestHanzo:
client = Hanzo(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"
# explicit environment arg requires explicitness
with update_env(HANZO_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
Hanzo(api_key=api_key, _strict_response_validation=True, environment="production")
client = Hanzo(base_url=None, api_key=api_key, _strict_response_validation=True, environment="production")
assert str(client.base_url).startswith("https://api.hanzo.ai")
@pytest.mark.parametrize(
"client",
[
@@ -1306,6 +1314,16 @@ class TestAsyncHanzo:
client = AsyncHanzo(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"
# explicit environment arg requires explicitness
with update_env(HANZO_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
AsyncHanzo(api_key=api_key, _strict_response_validation=True, environment="production")
client = AsyncHanzo(
base_url=None, api_key=api_key, _strict_response_validation=True, environment="production"
)
assert str(client.base_url).startswith("https://api.hanzo.ai")
@pytest.mark.parametrize(
"client",
[