Skip to content
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

release: 1.6.0 #130

Merged
merged 11 commits into from
Dec 16, 2024
Merged
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.5.0"
".": "1.6.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-82683f2fd5f8778a27960ebabda40d6dc4640bdfb77ac4ec7f173b8bf8076d3c.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-fcd4d82943d0aeefc300520f0ee4684456ef647140f1d6ba9ffcb86278d83d3a.yml
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 1.6.0 (2024-12-16)

Full Changelog: [v1.5.0...v1.6.0](https://github.com/writer/writer-python/compare/v1.5.0...v1.6.0)

### Features

* **api:** add streaming to application generation ([#132](https://github.com/writer/writer-python/issues/132)) ([c142caa](https://github.com/writer/writer-python/commit/c142caa6b2d646b270ec50c800c37effd9b90c49))
* **api:** api update ([#131](https://github.com/writer/writer-python/issues/131)) ([efadeb6](https://github.com/writer/writer-python/commit/efadeb67a868c57775a1205a5765ccc9f45997e2))


### Chores

* **internal:** add support for TypeAliasType ([#137](https://github.com/writer/writer-python/issues/137)) ([4523c9d](https://github.com/writer/writer-python/commit/4523c9dc88771fce1b330fcf57a4499af7606c44))
* **internal:** bump pydantic dependency ([#134](https://github.com/writer/writer-python/issues/134)) ([eb1ebfe](https://github.com/writer/writer-python/commit/eb1ebfe452164409a68fc7c6d83d5fdd9ce3b089))
* **internal:** bump pyright ([#129](https://github.com/writer/writer-python/issues/129)) ([f1b2b64](https://github.com/writer/writer-python/commit/f1b2b6458b47f1861bb7d297b007b6ee09123a85))
* **internal:** bump pyright ([#136](https://github.com/writer/writer-python/issues/136)) ([66af392](https://github.com/writer/writer-python/commit/66af39233901307387129f1eb95859434ad18760))
* **internal:** updated imports ([#138](https://github.com/writer/writer-python/issues/138)) ([fc58a7d](https://github.com/writer/writer-python/commit/fc58a7de32363b013cc390ebc7c237cf74fa4137))
* make the `Omit` type public ([#133](https://github.com/writer/writer-python/issues/133)) ([94b63bb](https://github.com/writer/writer-python/commit/94b63bbc992974c0f794dcfe4ced4d7fb2284c50))


### Documentation

* **readme:** example snippet for client context manager ([#139](https://github.com/writer/writer-python/issues/139)) ([30ae872](https://github.com/writer/writer-python/commit/30ae8729b37d27572eafbd521e52eb114b635f8e))
* **readme:** fix http client proxies example ([#135](https://github.com/writer/writer-python/issues/135)) ([4e39cfe](https://github.com/writer/writer-python/commit/4e39cfec407d89fcbe03e8283e7c7bc499bc7b40))

## 1.5.0 (2024-11-28)

Full Changelog: [v1.4.0...v1.5.0](https://github.com/writer/writer-python/compare/v1.4.0...v1.5.0)
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,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 writerai import Writer, DefaultHttpxClient

client = Writer(
# Or use the `WRITER_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 All @@ -411,6 +412,16 @@ client.with_options(http_client=DefaultHttpxClient(...))

By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

```py
from writerai import Writer

with Writer() as client:
# make requests here
...

# HTTP client is now closed
```

## Versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Types:

```python
from writerai.types import ApplicationGenerateContentResponse
from writerai.types import ApplicationGenerateContentChunk, ApplicationGenerateContentResponse
```

Methods:
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 = "writer-sdk"
version = "1.5.0"
version = "1.6.0"
description = "The official Python library for the writer 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
7 changes: 4 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
pydantic==2.9.2
pydantic==2.10.3
# via writer-sdk
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.380
pyright==1.1.390
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.24.0
Expand Down Expand Up @@ -97,6 +97,7 @@ typing-extensions==4.12.2
# via mypy
# via pydantic
# via pydantic-core
# via pyright
# via writer-sdk
virtualenv==20.24.5
# via nox
Expand Down
4 changes: 2 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ httpx==0.25.2
idna==3.4
# via anyio
# via httpx
pydantic==2.9.2
pydantic==2.10.3
# via writer-sdk
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
sniffio==1.3.0
# via anyio
Expand Down
3 changes: 2 additions & 1 deletion src/writerai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from . import types
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
from ._utils import file_from_path
from ._client import Client, Stream, Writer, Timeout, Transport, AsyncClient, AsyncStream, AsyncWriter, RequestOptions
from ._models import BaseModel
Expand Down Expand Up @@ -36,6 +36,7 @@
"ProxiesTypes",
"NotGiven",
"NOT_GIVEN",
"Omit",
"WriterError",
"APIError",
"APIStatusError",
Expand Down
128 changes: 60 additions & 68 deletions src/writerai/_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 @@ -24,35 +24,27 @@
get_async_library,
)
from ._version import __version__
from .resources import chat, files, graphs, models, completions, applications
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import WriterError, APIStatusError
from ._base_client import (
DEFAULT_MAX_RETRIES,
SyncAPIClient,
AsyncAPIClient,
)
from .resources.tools import tools

__all__ = [
"Timeout",
"Transport",
"ProxiesTypes",
"RequestOptions",
"resources",
"Writer",
"AsyncWriter",
"Client",
"AsyncClient",
]
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Writer", "AsyncWriter", "Client", "AsyncClient"]


class Writer(SyncAPIClient):
applications: resources.ApplicationsResource
chat: resources.ChatResource
completions: resources.CompletionsResource
models: resources.ModelsResource
graphs: resources.GraphsResource
files: resources.FilesResource
tools: resources.ToolsResource
applications: applications.ApplicationsResource
chat: chat.ChatResource
completions: completions.CompletionsResource
models: models.ModelsResource
graphs: graphs.GraphsResource
files: files.FilesResource
tools: tools.ToolsResource
with_raw_response: WriterWithRawResponse
with_streaming_response: WriterWithStreamedResponse

Expand Down Expand Up @@ -112,13 +104,13 @@ def __init__(

self._default_stream_cls = Stream

self.applications = resources.ApplicationsResource(self)
self.chat = resources.ChatResource(self)
self.completions = resources.CompletionsResource(self)
self.models = resources.ModelsResource(self)
self.graphs = resources.GraphsResource(self)
self.files = resources.FilesResource(self)
self.tools = resources.ToolsResource(self)
self.applications = applications.ApplicationsResource(self)
self.chat = chat.ChatResource(self)
self.completions = completions.CompletionsResource(self)
self.models = models.ModelsResource(self)
self.graphs = graphs.GraphsResource(self)
self.files = files.FilesResource(self)
self.tools = tools.ToolsResource(self)
self.with_raw_response = WriterWithRawResponse(self)
self.with_streaming_response = WriterWithStreamedResponse(self)

Expand Down Expand Up @@ -228,13 +220,13 @@ def _make_status_error(


class AsyncWriter(AsyncAPIClient):
applications: resources.AsyncApplicationsResource
chat: resources.AsyncChatResource
completions: resources.AsyncCompletionsResource
models: resources.AsyncModelsResource
graphs: resources.AsyncGraphsResource
files: resources.AsyncFilesResource
tools: resources.AsyncToolsResource
applications: applications.AsyncApplicationsResource
chat: chat.AsyncChatResource
completions: completions.AsyncCompletionsResource
models: models.AsyncModelsResource
graphs: graphs.AsyncGraphsResource
files: files.AsyncFilesResource
tools: tools.AsyncToolsResource
with_raw_response: AsyncWriterWithRawResponse
with_streaming_response: AsyncWriterWithStreamedResponse

Expand Down Expand Up @@ -294,13 +286,13 @@ def __init__(

self._default_stream_cls = AsyncStream

self.applications = resources.AsyncApplicationsResource(self)
self.chat = resources.AsyncChatResource(self)
self.completions = resources.AsyncCompletionsResource(self)
self.models = resources.AsyncModelsResource(self)
self.graphs = resources.AsyncGraphsResource(self)
self.files = resources.AsyncFilesResource(self)
self.tools = resources.AsyncToolsResource(self)
self.applications = applications.AsyncApplicationsResource(self)
self.chat = chat.AsyncChatResource(self)
self.completions = completions.AsyncCompletionsResource(self)
self.models = models.AsyncModelsResource(self)
self.graphs = graphs.AsyncGraphsResource(self)
self.files = files.AsyncFilesResource(self)
self.tools = tools.AsyncToolsResource(self)
self.with_raw_response = AsyncWriterWithRawResponse(self)
self.with_streaming_response = AsyncWriterWithStreamedResponse(self)

Expand Down Expand Up @@ -411,46 +403,46 @@ def _make_status_error(

class WriterWithRawResponse:
def __init__(self, client: Writer) -> None:
self.applications = resources.ApplicationsResourceWithRawResponse(client.applications)
self.chat = resources.ChatResourceWithRawResponse(client.chat)
self.completions = resources.CompletionsResourceWithRawResponse(client.completions)
self.models = resources.ModelsResourceWithRawResponse(client.models)
self.graphs = resources.GraphsResourceWithRawResponse(client.graphs)
self.files = resources.FilesResourceWithRawResponse(client.files)
self.tools = resources.ToolsResourceWithRawResponse(client.tools)
self.applications = applications.ApplicationsResourceWithRawResponse(client.applications)
self.chat = chat.ChatResourceWithRawResponse(client.chat)
self.completions = completions.CompletionsResourceWithRawResponse(client.completions)
self.models = models.ModelsResourceWithRawResponse(client.models)
self.graphs = graphs.GraphsResourceWithRawResponse(client.graphs)
self.files = files.FilesResourceWithRawResponse(client.files)
self.tools = tools.ToolsResourceWithRawResponse(client.tools)


class AsyncWriterWithRawResponse:
def __init__(self, client: AsyncWriter) -> None:
self.applications = resources.AsyncApplicationsResourceWithRawResponse(client.applications)
self.chat = resources.AsyncChatResourceWithRawResponse(client.chat)
self.completions = resources.AsyncCompletionsResourceWithRawResponse(client.completions)
self.models = resources.AsyncModelsResourceWithRawResponse(client.models)
self.graphs = resources.AsyncGraphsResourceWithRawResponse(client.graphs)
self.files = resources.AsyncFilesResourceWithRawResponse(client.files)
self.tools = resources.AsyncToolsResourceWithRawResponse(client.tools)
self.applications = applications.AsyncApplicationsResourceWithRawResponse(client.applications)
self.chat = chat.AsyncChatResourceWithRawResponse(client.chat)
self.completions = completions.AsyncCompletionsResourceWithRawResponse(client.completions)
self.models = models.AsyncModelsResourceWithRawResponse(client.models)
self.graphs = graphs.AsyncGraphsResourceWithRawResponse(client.graphs)
self.files = files.AsyncFilesResourceWithRawResponse(client.files)
self.tools = tools.AsyncToolsResourceWithRawResponse(client.tools)


class WriterWithStreamedResponse:
def __init__(self, client: Writer) -> None:
self.applications = resources.ApplicationsResourceWithStreamingResponse(client.applications)
self.chat = resources.ChatResourceWithStreamingResponse(client.chat)
self.completions = resources.CompletionsResourceWithStreamingResponse(client.completions)
self.models = resources.ModelsResourceWithStreamingResponse(client.models)
self.graphs = resources.GraphsResourceWithStreamingResponse(client.graphs)
self.files = resources.FilesResourceWithStreamingResponse(client.files)
self.tools = resources.ToolsResourceWithStreamingResponse(client.tools)
self.applications = applications.ApplicationsResourceWithStreamingResponse(client.applications)
self.chat = chat.ChatResourceWithStreamingResponse(client.chat)
self.completions = completions.CompletionsResourceWithStreamingResponse(client.completions)
self.models = models.ModelsResourceWithStreamingResponse(client.models)
self.graphs = graphs.GraphsResourceWithStreamingResponse(client.graphs)
self.files = files.FilesResourceWithStreamingResponse(client.files)
self.tools = tools.ToolsResourceWithStreamingResponse(client.tools)


class AsyncWriterWithStreamedResponse:
def __init__(self, client: AsyncWriter) -> None:
self.applications = resources.AsyncApplicationsResourceWithStreamingResponse(client.applications)
self.chat = resources.AsyncChatResourceWithStreamingResponse(client.chat)
self.completions = resources.AsyncCompletionsResourceWithStreamingResponse(client.completions)
self.models = resources.AsyncModelsResourceWithStreamingResponse(client.models)
self.graphs = resources.AsyncGraphsResourceWithStreamingResponse(client.graphs)
self.files = resources.AsyncFilesResourceWithStreamingResponse(client.files)
self.tools = resources.AsyncToolsResourceWithStreamingResponse(client.tools)
self.applications = applications.AsyncApplicationsResourceWithStreamingResponse(client.applications)
self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat)
self.completions = completions.AsyncCompletionsResourceWithStreamingResponse(client.completions)
self.models = models.AsyncModelsResourceWithStreamingResponse(client.models)
self.graphs = graphs.AsyncGraphsResourceWithStreamingResponse(client.graphs)
self.files = files.AsyncFilesResourceWithStreamingResponse(client.files)
self.tools = tools.AsyncToolsResourceWithStreamingResponse(client.tools)


Client = Writer
Expand Down
3 changes: 3 additions & 0 deletions src/writerai/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
strip_not_given,
extract_type_arg,
is_annotated_type,
is_type_alias_type,
strip_annotated_type,
)
from ._compat import (
Expand Down Expand Up @@ -429,6 +430,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
Loading
Loading