Skip to content

Commit d61305e

Browse files
release: 2.0.0 (#198)
* chore(internal): version bump (#194) * docs(api): updates to API spec (#196) * chore(internal): properly set __pydantic_private__ (#197) * codegen metadata * docs: Add file upload examples to README. (#199) * release: 2.0.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: sstringer <sarah.deaton@writer.com>
1 parent 2f37fd0 commit d61305e

18 files changed

Lines changed: 117 additions & 77 deletions

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.0.0-rc1"
2+
".": "2.0.0"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 29
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-9f17b2629bd54f56bc3e48ec710b11e2ba84302725f8da9e9ed390bbed5d3b5b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-3d3b2fe43375eac35441f6de554253a7dc3eaa5d97c00a5a351ec72d6587eb32.yml

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 2.0.0 (2025-02-26)
4+
5+
Full Changelog: [v2.0.0-rc1...v2.0.0](https://github.com/writer/writer-python/compare/v2.0.0-rc1...v2.0.0)
6+
7+
### Chores
8+
9+
* **internal:** properly set __pydantic_private__ ([#197](https://github.com/writer/writer-python/issues/197)) ([533c0f8](https://github.com/writer/writer-python/commit/533c0f8c14ba78fb827fa494d25a4367612ad0fa))
10+
* **internal:** version bump ([#194](https://github.com/writer/writer-python/issues/194)) ([f75756f](https://github.com/writer/writer-python/commit/f75756f03a1e2083fc9cc6be66596a19606d1312))
11+
12+
13+
### Documentation
14+
15+
* Add file upload examples to README. ([#199](https://github.com/writer/writer-python/issues/199)) ([628cf7f](https://github.com/writer/writer-python/commit/628cf7f3a0047af764d31b156709443175806d59))
16+
* **api:** updates to API spec ([#196](https://github.com/writer/writer-python/issues/196)) ([2867dbb](https://github.com/writer/writer-python/commit/2867dbbefe5b5795f043fc2641a5320e24bf0788))
17+
318
## 2.0.0-rc1 (2025-02-21)
419

520
Full Changelog: [v1.6.1...v2.0.0-rc1](https://github.com/writer/writer-python/compare/v1.6.1...v2.0.0-rc1)

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,27 @@ for graph in first_page.data:
226226
print(graph.id)
227227
```
228228

229+
## File uploads
230+
231+
You can pass file upload parameters as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
232+
233+
The `content_type` parameter is the [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types) of the file being uploaded. The file upload supports `txt`, `doc`, `docx`, `ppt`, `pptx`, `jpg`, `png`, `eml`, `html`, `pdf`, `srt`, `csv`, `xls`, and `xlsx` file extensions.
234+
235+
```python
236+
from pathlib import Path
237+
from writerai import Writer
238+
239+
client = Writer()
240+
241+
client.files.upload(
242+
content=Path("/path/to/file/example.pdf"),
243+
content_disposition="attachment; filename='example.pdf'",
244+
content_type="application/pdf",
245+
)
246+
```
247+
248+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
249+
229250
## Handling errors
230251

231252
When the library is unable to connect to the API (for example, due to network connection problems, a timeout, or a firewall that doesn't allow the connection), a subclass of `writerai.APIConnectionError` is raised.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "writer-sdk"
3-
version = "2.0.0-rc1"
3+
version = "2.0.0"
44
description = "The official Python library for the writer API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/writerai/_base_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
ModelBuilderProtocol,
6565
)
6666
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
67-
from ._compat import model_copy, model_dump
67+
from ._compat import PYDANTIC_V2, model_copy, model_dump
6868
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
6969
from ._response import (
7070
APIResponse,
@@ -208,6 +208,9 @@ def _set_private_attributes(
208208
model: Type[_T],
209209
options: FinalRequestOptions,
210210
) -> None:
211+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
212+
self.__pydantic_private__ = {}
213+
211214
self._model = model
212215
self._client = client
213216
self._options = options
@@ -293,6 +296,9 @@ def _set_private_attributes(
293296
client: AsyncAPIClient,
294297
options: FinalRequestOptions,
295298
) -> None:
299+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
300+
self.__pydantic_private__ = {}
301+
296302
self._model = model
297303
self._client = client
298304
self._options = options

src/writerai/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "writerai"
4-
__version__ = "2.0.0-rc1" # x-release-please-version
4+
__version__ = "2.0.0" # x-release-please-version

src/writerai/resources/applications/graphs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def update(
5959
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
6060
) -> ApplicationGraphsResponse:
6161
"""
62-
Updates the graphs listed and associates them with the no-code chat app to be
63-
used.
62+
Updates the Knowledge Graphs listed and associates them with the no-code chat
63+
app to be used.
6464
6565
Args:
66-
graph_ids: A list of graph IDs to associate with the application. Note that this will
67-
replace the existing list of graphs associated with the application, not add to
68-
it.
66+
graph_ids: A list of Knowledge Graph IDs to associate with the application. Note that this
67+
will replace the existing list of Knowledge Graphs associated with the
68+
application, not add to it.
6969
7070
extra_headers: Send extra headers
7171
@@ -98,7 +98,7 @@ def list(
9898
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
9999
) -> ApplicationGraphsResponse:
100100
"""
101-
Retrieve graphs associated with a no-code chat application.
101+
Retrieve Knowledge Graphs associated with a no-code chat application.
102102
103103
Args:
104104
extra_headers: Send extra headers
@@ -153,13 +153,13 @@ async def update(
153153
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
154154
) -> ApplicationGraphsResponse:
155155
"""
156-
Updates the graphs listed and associates them with the no-code chat app to be
157-
used.
156+
Updates the Knowledge Graphs listed and associates them with the no-code chat
157+
app to be used.
158158
159159
Args:
160-
graph_ids: A list of graph IDs to associate with the application. Note that this will
161-
replace the existing list of graphs associated with the application, not add to
162-
it.
160+
graph_ids: A list of Knowledge Graph IDs to associate with the application. Note that this
161+
will replace the existing list of Knowledge Graphs associated with the
162+
application, not add to it.
163163
164164
extra_headers: Send extra headers
165165
@@ -192,7 +192,7 @@ async def list(
192192
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
193193
) -> ApplicationGraphsResponse:
194194
"""
195-
Retrieve graphs associated with a no-code chat application.
195+
Retrieve Knowledge Graphs associated with a no-code chat application.
196196
197197
Args:
198198
extra_headers: Send extra headers

src/writerai/resources/graphs.py

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ def create(
7676
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
7777
) -> GraphCreateResponse:
7878
"""
79-
Create graph
79+
Create a new Knowledge Graph.
8080
8181
Args:
82-
description: A description of the graph (max 255 characters). Omitting this field leaves the
83-
description unchanged.
82+
description: A description of the Knowledge Graph (max 255 characters). Omitting this field
83+
leaves the description unchanged.
8484
85-
name: The name of the graph (max 255 characters). Omitting this field leaves the name
86-
unchanged.
85+
name: The name of the Knowledge Graph (max 255 characters). Omitting this field leaves
86+
the name unchanged.
8787
8888
extra_headers: Send extra headers
8989
@@ -120,7 +120,7 @@ def retrieve(
120120
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
121121
) -> Graph:
122122
"""
123-
Retrieve graph
123+
Retrieve a Knowledge Graph.
124124
125125
Args:
126126
extra_headers: Send extra headers
@@ -158,11 +158,11 @@ def update(
158158
Update the name and description of a Knowledge Graph.
159159
160160
Args:
161-
description: A description of the graph (max 255 characters). Omitting this field leaves the
162-
description unchanged.
161+
description: A description of the Knowledge Graph (max 255 characters). Omitting this field
162+
leaves the description unchanged.
163163
164-
name: The name of the graph (max 255 characters). Omitting this field leaves the name
165-
unchanged.
164+
name: The name of the Knowledge Graph (max 255 characters). Omitting this field leaves
165+
the name unchanged.
166166
167167
extra_headers: Send extra headers
168168
@@ -203,12 +203,11 @@ def list(
203203
extra_body: Body | None = None,
204204
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
205205
) -> SyncCursorPage[Graph]:
206-
"""List graphs
206+
"""
207+
Retrieve a list of Knowledge Graphs.
207208
208209
Args:
209-
after: The ID of the last object in the previous page.
210-
211-
This parameter instructs the API
210+
after: The ID of the last object in the previous page. This parameter instructs the API
212211
to return the next page of results.
213212
214213
before: The ID of the first object in the previous page. This parameter instructs the
@@ -261,7 +260,7 @@ def delete(
261260
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
262261
) -> GraphDeleteResponse:
263262
"""
264-
Delete graph
263+
Delete a Knowledge Graph.
265264
266265
Args:
267266
extra_headers: Send extra headers
@@ -295,7 +294,7 @@ def add_file_to_graph(
295294
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
296295
) -> File:
297296
"""
298-
Add file to graph
297+
Add a file to a Knowledge Graph.
299298
300299
Args:
301300
file_id: The unique identifier of the file.
@@ -517,7 +516,7 @@ def remove_file_from_graph(
517516
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
518517
) -> GraphRemoveFileFromGraphResponse:
519518
"""
520-
Remove file from graph
519+
Remove a file from a Knowledge Graph.
521520
522521
Args:
523522
extra_headers: Send extra headers
@@ -574,14 +573,14 @@ async def create(
574573
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
575574
) -> GraphCreateResponse:
576575
"""
577-
Create graph
576+
Create a new Knowledge Graph.
578577
579578
Args:
580-
description: A description of the graph (max 255 characters). Omitting this field leaves the
581-
description unchanged.
579+
description: A description of the Knowledge Graph (max 255 characters). Omitting this field
580+
leaves the description unchanged.
582581
583-
name: The name of the graph (max 255 characters). Omitting this field leaves the name
584-
unchanged.
582+
name: The name of the Knowledge Graph (max 255 characters). Omitting this field leaves
583+
the name unchanged.
585584
586585
extra_headers: Send extra headers
587586
@@ -618,7 +617,7 @@ async def retrieve(
618617
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
619618
) -> Graph:
620619
"""
621-
Retrieve graph
620+
Retrieve a Knowledge Graph.
622621
623622
Args:
624623
extra_headers: Send extra headers
@@ -656,11 +655,11 @@ async def update(
656655
Update the name and description of a Knowledge Graph.
657656
658657
Args:
659-
description: A description of the graph (max 255 characters). Omitting this field leaves the
660-
description unchanged.
658+
description: A description of the Knowledge Graph (max 255 characters). Omitting this field
659+
leaves the description unchanged.
661660
662-
name: The name of the graph (max 255 characters). Omitting this field leaves the name
663-
unchanged.
661+
name: The name of the Knowledge Graph (max 255 characters). Omitting this field leaves
662+
the name unchanged.
664663
665664
extra_headers: Send extra headers
666665
@@ -701,12 +700,11 @@ def list(
701700
extra_body: Body | None = None,
702701
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
703702
) -> AsyncPaginator[Graph, AsyncCursorPage[Graph]]:
704-
"""List graphs
703+
"""
704+
Retrieve a list of Knowledge Graphs.
705705
706706
Args:
707-
after: The ID of the last object in the previous page.
708-
709-
This parameter instructs the API
707+
after: The ID of the last object in the previous page. This parameter instructs the API
710708
to return the next page of results.
711709
712710
before: The ID of the first object in the previous page. This parameter instructs the
@@ -759,7 +757,7 @@ async def delete(
759757
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
760758
) -> GraphDeleteResponse:
761759
"""
762-
Delete graph
760+
Delete a Knowledge Graph.
763761
764762
Args:
765763
extra_headers: Send extra headers
@@ -793,7 +791,7 @@ async def add_file_to_graph(
793791
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
794792
) -> File:
795793
"""
796-
Add file to graph
794+
Add a file to a Knowledge Graph.
797795
798796
Args:
799797
file_id: The unique identifier of the file.
@@ -1017,7 +1015,7 @@ async def remove_file_from_graph(
10171015
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
10181016
) -> GraphRemoveFileFromGraphResponse:
10191017
"""
1020-
Remove file from graph
1018+
Remove a file from a Knowledge Graph.
10211019
10221020
Args:
10231021
extra_headers: Send extra headers

src/writerai/types/applications/application_graphs_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
class ApplicationGraphsResponse(BaseModel):
1111
graph_ids: List[str]
12-
"""A list of graphs associated with the application."""
12+
"""A list of Knowledge Graphs associated with the application."""

0 commit comments

Comments
 (0)