Skip to content

Commit

Permalink
release: 0.0.19 (#75)
Browse files Browse the repository at this point in the history
* chore(internal): bump pydantic dependency (#74)

* docs(readme): fix http client proxies example (#76)

* chore(internal): bump pyright (#77)

* chore(internal): add support for TypeAliasType (#78)

* chore(internal): codegen related update (#79)

* chore(internal): codegen related update (#80)

* chore(internal): codegen related update (#81)

* feat(api): api update (#82)

* release: 0.0.19

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
  • Loading branch information
stainless-app[bot] authored Dec 16, 2024
1 parent f740d11 commit 89e06c3
Show file tree
Hide file tree
Showing 40 changed files with 614 additions and 224 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.0.18"
".": "0.0.19"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 40
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-e4c301de216e3c01c130dfbf82f7d5272939867cc4b452aa00d6f0e081767bec.yml
configured_endpoints: 41
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-9c89a1623da5f8289d05c3c8a8fa7778d7d89f8679e4e8a3589c1cb2735c70aa.yml
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.0.19 (2024-12-16)

Full Changelog: [v0.0.18...v0.0.19](https://github.com/plastic-labs/honcho-python/compare/v0.0.18...v0.0.19)

### Features

* **api:** api update ([#82](https://github.com/plastic-labs/honcho-python/issues/82)) ([f295a74](https://github.com/plastic-labs/honcho-python/commit/f295a748dd5a168878b14515b5601d462f56a9d8))


### Chores

* **internal:** add support for TypeAliasType ([#78](https://github.com/plastic-labs/honcho-python/issues/78)) ([66e0d96](https://github.com/plastic-labs/honcho-python/commit/66e0d96e66ec4981bf2cd31eb717eff80fde9041))
* **internal:** bump pydantic dependency ([#74](https://github.com/plastic-labs/honcho-python/issues/74)) ([43ea1de](https://github.com/plastic-labs/honcho-python/commit/43ea1dec3ad6e2a28fd5cbe101a63201c8937f8a))
* **internal:** bump pyright ([#77](https://github.com/plastic-labs/honcho-python/issues/77)) ([b613832](https://github.com/plastic-labs/honcho-python/commit/b613832984ab0dbb5f82dc83808b679e87e6944e))
* **internal:** codegen related update ([#79](https://github.com/plastic-labs/honcho-python/issues/79)) ([62d7c38](https://github.com/plastic-labs/honcho-python/commit/62d7c38c172a8761b880a0eb7996d01737d3786f))
* **internal:** codegen related update ([#80](https://github.com/plastic-labs/honcho-python/issues/80)) ([e5b574e](https://github.com/plastic-labs/honcho-python/commit/e5b574e0b9897036ff2f06e725dc86492973a893))
* **internal:** codegen related update ([#81](https://github.com/plastic-labs/honcho-python/issues/81)) ([9a4cd72](https://github.com/plastic-labs/honcho-python/commit/9a4cd72e6225d2a70870b2f1853e98039747e55c))


### Documentation

* **readme:** fix http client proxies example ([#76](https://github.com/plastic-labs/honcho-python/issues/76)) ([30cacbf](https://github.com/plastic-labs/honcho-python/commit/30cacbf37ea84226175ccc1dcef2964a8e7392ad))

## 0.0.18 (2024-12-04)

Full Changelog: [v0.0.17...v0.0.18](https://github.com/plastic-labs/honcho-python/compare/v0.0.17...v0.0.18)
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ client = Honcho(
)

app = client.apps.create(
name="name",
name="x",
)
print(app.id)
```
Expand Down Expand Up @@ -62,7 +62,7 @@ client = AsyncHoncho(

async def main() -> None:
app = await client.apps.create(
name="name",
name="x",
)
print(app.id)

Expand Down Expand Up @@ -169,7 +169,7 @@ client = Honcho()

try:
client.apps.create(
name="name",
name="x",
)
except honcho.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -214,7 +214,7 @@ client = Honcho(

# Or, configure per-request:
client.with_options(max_retries=5).apps.create(
name="name",
name="x",
)
```

Expand All @@ -239,7 +239,7 @@ client = Honcho(

# Override per-request:
client.with_options(timeout=5.0).apps.create(
name="name",
name="x",
)
```

Expand Down Expand Up @@ -282,7 +282,7 @@ from honcho import Honcho

client = Honcho()
response = client.apps.with_raw_response.create(
name="name",
name="x",
)
print(response.headers.get('X-My-Header'))

Expand All @@ -302,7 +302,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi

```python
with client.apps.with_streaming_response.create(
name="name",
name="x",
) as response:
print(response.headers.get("X-My-Header"))

Expand Down Expand Up @@ -351,18 +351,19 @@ can also get all the extra fields on the Pydantic model as a dict with

You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:

- Support for proxies
- Custom transports
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
import httpx
from honcho import Honcho, DefaultHttpxClient

client = Honcho(
# Or use the `HONCHO_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Expand Down
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ Methods:
Types:

```python
from honcho.types.apps.users.sessions import Message, PageMessage
from honcho.types.apps.users.sessions import Message, PageMessage, MessageBatchResponse
```

Methods:

- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">create</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_create_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>
- <code title="put /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">update</a>(message_id, \*, app_id, user_id, session_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_update_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>
- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/list">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">list</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_list_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">SyncPage[Message]</a></code>
- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">batch</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_batch_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message_batch_response.py">MessageBatchResponse</a></code>
- <code title="get /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">get</a>(message_id, \*, app_id, user_id, session_id) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>

#### Metamessages
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "honcho-ai"
version = "0.0.18"
version = "0.0.19"
description = "The official Python library for the honcho API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -10,7 +10,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.7, <5",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
pydantic==2.9.2
pydantic==2.10.3
# via honcho-ai
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.389
pyright==1.1.390
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.24.0
Expand Down
4 changes: 2 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ httpx==0.25.2
idna==3.4
# via anyio
# via httpx
pydantic==2.9.2
pydantic==2.10.3
# via honcho-ai
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
sniffio==1.3.0
# via anyio
Expand Down
20 changes: 10 additions & 10 deletions src/honcho/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import httpx

from . import resources, _exceptions
from . import _exceptions
from ._qs import Querystring
from ._types import (
NOT_GIVEN,
Expand All @@ -31,14 +31,14 @@
SyncAPIClient,
AsyncAPIClient,
)
from .resources.apps import apps

__all__ = [
"ENVIRONMENTS",
"Timeout",
"Transport",
"ProxiesTypes",
"RequestOptions",
"resources",
"Honcho",
"AsyncHoncho",
"Client",
Expand All @@ -52,7 +52,7 @@


class Honcho(SyncAPIClient):
apps: resources.AppsResource
apps: apps.AppsResource
with_raw_response: HonchoWithRawResponse
with_streaming_response: HonchoWithStreamedResponse

Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.apps = resources.AppsResource(self)
self.apps = apps.AppsResource(self)
self.with_raw_response = HonchoWithRawResponse(self)
self.with_streaming_response = HonchoWithStreamedResponse(self)

Expand Down Expand Up @@ -244,7 +244,7 @@ def _make_status_error(


class AsyncHoncho(AsyncAPIClient):
apps: resources.AsyncAppsResource
apps: apps.AsyncAppsResource
with_raw_response: AsyncHonchoWithRawResponse
with_streaming_response: AsyncHonchoWithStreamedResponse

Expand Down Expand Up @@ -322,7 +322,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.apps = resources.AsyncAppsResource(self)
self.apps = apps.AsyncAppsResource(self)
self.with_raw_response = AsyncHonchoWithRawResponse(self)
self.with_streaming_response = AsyncHonchoWithStreamedResponse(self)

Expand Down Expand Up @@ -437,22 +437,22 @@ def _make_status_error(

class HonchoWithRawResponse:
def __init__(self, client: Honcho) -> None:
self.apps = resources.AppsResourceWithRawResponse(client.apps)
self.apps = apps.AppsResourceWithRawResponse(client.apps)


class AsyncHonchoWithRawResponse:
def __init__(self, client: AsyncHoncho) -> None:
self.apps = resources.AsyncAppsResourceWithRawResponse(client.apps)
self.apps = apps.AsyncAppsResourceWithRawResponse(client.apps)


class HonchoWithStreamedResponse:
def __init__(self, client: Honcho) -> None:
self.apps = resources.AppsResourceWithStreamingResponse(client.apps)
self.apps = apps.AppsResourceWithStreamingResponse(client.apps)


class AsyncHonchoWithStreamedResponse:
def __init__(self, client: AsyncHoncho) -> None:
self.apps = resources.AsyncAppsResourceWithStreamingResponse(client.apps)
self.apps = apps.AsyncAppsResourceWithStreamingResponse(client.apps)


Client = Honcho
Expand Down
3 changes: 3 additions & 0 deletions src/honcho/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
strip_not_given,
extract_type_arg,
is_annotated_type,
is_type_alias_type,
strip_annotated_type,
)
from ._compat import (
Expand Down Expand Up @@ -428,6 +429,8 @@ def construct_type(*, value: object, type_: object) -> object:
# we allow `object` as the input type because otherwise, passing things like
# `Literal['value']` will be reported as a type error by type checkers
type_ = cast("type[object]", type_)
if is_type_alias_type(type_):
type_ = type_.__value__ # type: ignore[unreachable]

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(type_):
Expand Down
20 changes: 10 additions & 10 deletions src/honcho/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pydantic

from ._types import NoneType
from ._utils import is_given, extract_type_arg, is_annotated_type, extract_type_var_from_base
from ._utils import is_given, extract_type_arg, is_annotated_type, is_type_alias_type, extract_type_var_from_base
from ._models import BaseModel, is_basemodel
from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER
from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type
Expand Down Expand Up @@ -126,9 +126,15 @@ def __repr__(self) -> str:
)

def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to = to if to is not None else self._cast_to

# unwrap `TypeAlias('Name', T)` -> `T`
if is_type_alias_type(cast_to):
cast_to = cast_to.__value__ # type: ignore[unreachable]

# unwrap `Annotated[T, ...]` -> `T`
if to and is_annotated_type(to):
to = extract_type_arg(to, 0)
if cast_to and is_annotated_type(cast_to):
cast_to = extract_type_arg(cast_to, 0)

if self._is_sse_stream:
if to:
Expand Down Expand Up @@ -164,18 +170,12 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
return cast(
R,
stream_cls(
cast_to=self._cast_to,
cast_to=cast_to,
response=self.http_response,
client=cast(Any, self._client),
),
)

cast_to = to if to is not None else self._cast_to

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(cast_to):
cast_to = extract_type_arg(cast_to, 0)

if cast_to is NoneType:
return cast(R, None)

Expand Down
6 changes: 2 additions & 4 deletions src/honcho/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ def get(self, __key: str) -> str | None: ...
StrBytesIntFloat = Union[str, bytes, int, float]

# Note: copied from Pydantic
# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
IncEx: TypeAlias = Union[
Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
]
# https://github.com/pydantic/pydantic/blob/6f31f8f68ef011f84357330186f603ff295312fd/pydantic/main.py#L79
IncEx: TypeAlias = Union[Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]]]

PostParser = Callable[[Any], Any]

Expand Down
1 change: 1 addition & 0 deletions src/honcho/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
is_iterable_type as is_iterable_type,
is_required_type as is_required_type,
is_annotated_type as is_annotated_type,
is_type_alias_type as is_type_alias_type,
strip_annotated_type as strip_annotated_type,
extract_type_var_from_base as extract_type_var_from_base,
)
Expand Down
Loading

0 comments on commit 89e06c3

Please sign in to comment.